View Javadoc
1   /*
2    * Copyright 2012 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.AuditContext;
19  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetResponseType;
20  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetResponseType.DocumentResponse;
21  import org.openehealth.ipf.commons.ihe.xds.core.audit.XdsNonconstructiveDocumentSetRequestAuditDataset.Status;
22  
23  /**
24   * Basis for Strategy pattern implementation for ATNA Auditing
25   * in ebXML 3.0-based retrieval-related XDS transactions.
26   *
27   * @author Dmytro Rud
28   */
29  public abstract class XdsRetrieveAuditStrategy30 extends XdsNonconstructiveDocumentSetRequestAuditStrategy30 {
30  
31      public XdsRetrieveAuditStrategy30(boolean serverSide) {
32          super(serverSide);
33      }
34  
35      /**
36       * These transactions defines the source user NOT as being the requestor. This could be a
37       * specification mistake.
38       *
39       * @return audit dataset
40       */
41      @Override
42      public XdsNonconstructiveDocumentSetRequestAuditDataset createAuditDataset() {
43          XdsNonconstructiveDocumentSetRequestAuditDataset auditDataset = super.createAuditDataset();
44          auditDataset.setSourceUserIsRequestor(false);
45          return auditDataset;
46      }
47  
48      @Override
49      public boolean enrichAuditDatasetFromResponse(XdsNonconstructiveDocumentSetRequestAuditDataset auditDataset, Object pojo, AuditContext auditContext) {
50          RetrieveDocumentSetResponseType response = (RetrieveDocumentSetResponseType) pojo;
51          if (response.getDocumentResponse() != null) {
52              for (DocumentResponse documentResponse : response.getDocumentResponse()) {
53                  auditDataset.registerProcessedDocument(
54                          documentResponse.getDocumentUniqueId(),
55                          documentResponse.getRepositoryUniqueId(),
56                          documentResponse.getHomeCommunityId());
57              }
58          }
59  
60          // These transactions define source and destination userID the inverted way. This could be a
61          // specification mistake.
62          String sourceUserId = auditDataset.getSourceUserId();
63          auditDataset.setSourceUserId(auditDataset.getDestinationUserId());
64          auditDataset.setDestinationUserId(sourceUserId);
65          return true;
66      }
67  
68      @Override
69      public Status getDefaultDocumentStatus() {
70          return Status.NOT_SUCCESSFUL;
71      }
72  
73  }