View Javadoc
1   /*
2    * Copyright 2017 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.audit;
17  
18  import org.openehealth.ipf.commons.audit.codes.EventOutcomeIndicator;
19  import org.openehealth.ipf.commons.ihe.xds.core.audit.XdsNonconstructiveDocumentSetRequestAuditDataset.Document;
20  import org.openehealth.ipf.commons.ihe.xds.core.audit.XdsNonconstructiveDocumentSetRequestAuditDataset.Status;
21  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetRequestType;
22  
23  import java.util.Map;
24  
25  /**
26   * Basis for Strategy pattern implementation for ATNA Auditing in ebXML 3.0-based XDS transactions
27   * related to non-constructive operations (Read+Delete as opposed to Create+Update in CRUD)
28   * on document sets in an XDS Repository.
29   *
30   * @author Dmytro Rud
31   */
32  public abstract class XdsNonconstructiveDocumentSetRequestAuditStrategy30 extends XdsAuditStrategy<XdsNonconstructiveDocumentSetRequestAuditDataset> {
33  
34      public XdsNonconstructiveDocumentSetRequestAuditStrategy30(boolean serverSide) {
35          super(serverSide);
36      }
37  
38      /**
39       * Specifies status of newly registered documents.
40       * For retrieval operations, this status is NOT_SUCCESSFUL, and will be changed to SUCCESSFUL for actually delivered documents.
41       * For removal operations, this status is SUCCESSFUL, and will be changed to NOT_SUCCESSFUL for documents mentioned in
42       * {@link org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryErrorList}.
43       */
44      abstract public Status getDefaultDocumentStatus();
45  
46      @Override
47      public XdsNonconstructiveDocumentSetRequestAuditDataset enrichAuditDatasetFromRequest(XdsNonconstructiveDocumentSetRequestAuditDataset auditDataset, Object pojo, Map<String, Object> parameters) {
48          RetrieveDocumentSetRequestType request = (RetrieveDocumentSetRequestType) pojo;
49          if (request.getDocumentRequest() != null) {
50              request.getDocumentRequest().forEach(document ->
51                      auditDataset.getDocuments().add(new Document(
52                              document.getDocumentUniqueId(),
53                              document.getRepositoryUniqueId(),
54                              document.getHomeCommunityId(),
55                              null,
56                              null,
57                              getDefaultDocumentStatus())));
58          }
59          return auditDataset;
60      }
61  
62      @Override
63      public XdsNonconstructiveDocumentSetRequestAuditDataset createAuditDataset() {
64          return new XdsNonconstructiveDocumentSetRequestAuditDataset(isServerSide());
65      }
66  
67      /**
68       * This method is not used, because the outcome code will be determined
69       * based on the statuses of individual {@link Document Document}s.
70       */
71      @Override
72      public EventOutcomeIndicator getEventOutcomeIndicator(Object response) {
73          return null;
74      }
75  }