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.ToString;
20  
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlElementRef;
24  import javax.xml.bind.annotation.XmlRootElement;
25  import javax.xml.bind.annotation.XmlType;
26  import java.io.Serializable;
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  /**
31   * Documents returned by the Retrieve Document Set transaction.
32   * <p>
33   * Lists are pre-created and can therefore never be <code>null</code>.
34   * @author Jens Riemschneider
35   */
36  @XmlAccessorType(XmlAccessType.FIELD)
37  @XmlType(name = "RetrievedDocumentSet")
38  @XmlRootElement(name = "retrievedDocumentSet")
39  @EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
40  @ToString(callSuper = true, doNotUseGetters = true)
41  public class RetrievedDocumentSet extends Response implements Serializable {    
42      private static final long serialVersionUID = 4389321453383292730L;
43      
44      @XmlElementRef
45      private final List<RetrievedDocument> documents = new ArrayList<>();
46  
47      /**
48       * Constructs the response.
49       */
50      public RetrievedDocumentSet() {}
51      
52      /**
53       * Constructs the response.
54       * @param status
55       *          the status of the request execution.
56       */
57      public RetrievedDocumentSet(Status status) {        
58          super(status);
59      }
60      
61      /**
62       * Constructs the response.
63       * @param status
64       *          the status of the request execution.
65       * @param documents
66       *          the documents to add to this set.
67       */
68      public RetrievedDocumentSet(Status status, List<RetrievedDocument> documents) {        
69          super(status);
70          this.documents.addAll(documents);
71      }
72      
73      /**
74       * Constructs an error response object with the data from an exception.
75       * @param throwable
76       *          the exception that occurred.
77       * @param defaultMetaDataError
78       *          the default error code for {@link org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException}.
79       * @param defaultError
80       *          the default error code for any other exception.
81       * @param location
82       *          error location.
83       */
84      public RetrievedDocumentSet(
85              Throwable throwable,
86              ErrorCode defaultMetaDataError,
87              ErrorCode defaultError,
88              String location) {
89          super(throwable, defaultMetaDataError, defaultError, location);
90      }
91  
92      /**
93       * @return the documents.
94       */
95      public List<RetrievedDocument> getDocuments() {
96          return documents;
97      }
98  
99  }