View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.responses;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.Setter;
21  import lombok.ToString;
22  import org.openehealth.ipf.commons.ihe.xds.core.requests.DocumentReference;
23  
24  import javax.activation.DataHandler;
25  import javax.xml.bind.annotation.XmlAccessType;
26  import javax.xml.bind.annotation.XmlAccessorType;
27  import javax.xml.bind.annotation.XmlElementRef;
28  import javax.xml.bind.annotation.XmlRootElement;
29  import javax.xml.bind.annotation.XmlType;
30  import java.io.Serializable;
31  
32  /**
33   * A single document retrieved from the repository.
34   * <p>
35   * All members of this class are allowed to be <code>null</code>.
36   * @author Jens Riemschneider
37   */
38  @XmlAccessorType(XmlAccessType.FIELD)
39  @XmlType(name = "RetrievedDocument", propOrder = {"requestData", "mimeType", "newRepositoryUniqueId",
40          "newDocumentUniqueId"})
41  @XmlRootElement(name = "retrievedDocument")
42  @EqualsAndHashCode(doNotUseGetters = true)
43  @ToString(doNotUseGetters = true)
44  public class RetrievedDocument implements Serializable {
45      private static final long serialVersionUID = -3950026651885804263L;
46      
47      @Getter @Setter private transient DataHandler dataHandler;
48      @XmlElementRef
49      @Getter @Setter private DocumentReference requestData;
50      @Getter @Setter private String mimeType;
51      @Getter @Setter private String newRepositoryUniqueId;
52      @Getter @Setter private String newDocumentUniqueId;
53  
54      /**
55       * Constructs the retrieved document.
56       */
57      public RetrievedDocument() {}
58  
59      /**
60       * Constructs the retrieved document.
61       * @param dataHandler
62       *          the data handler allowing access to the content of the document. 
63       * @param requestData
64       *          the data specified in the request.
65       * @param newRepositoryUniqueId
66       *          ID of the Document Repository that will support retrieval of the
67       *          document created as a result of retrieval of the On-Demand Document
68       *          (required when the On-Demand Document Source supports the Persistence
69       *          of Retrieved Documents Option).
70       * @param newDocumentUniqueId
71       *          ID of the document created as a result of retrieval
72       *          of the On-Demand Document.
73       * @param mimeType
74       *          MIME type of the document.
75       */
76      public RetrievedDocument(
77              DataHandler dataHandler,
78              DocumentReference requestData,
79              String newRepositoryUniqueId,
80              String newDocumentUniqueId,
81              String mimeType)
82      {
83          this.dataHandler = dataHandler;
84          this.requestData = requestData;
85          this.newRepositoryUniqueId = newRepositoryUniqueId;
86          this.newDocumentUniqueId = newDocumentUniqueId;
87          this.mimeType = mimeType;
88      }
89  
90  }