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.core.atna.custom;
17  
18  import org.openhealthtools.ihe.atna.auditor.IHEAuditor;
19  import org.openhealthtools.ihe.atna.auditor.events.ihe.GenericIHEAuditEventMessage;
20  import org.openhealthtools.ihe.atna.auditor.models.rfc3881.CodedValueType;
21  import org.openhealthtools.ihe.atna.auditor.utils.EventUtils;
22  
23  import java.util.List;
24  
25  /**
26   * @author Dmytro Rud
27   * @deprecated
28   */
29  abstract class CustomAuditorUtils {
30  
31      public static void configureEvent(
32              IHEAuditor auditor,
33              boolean serverSide,
34              GenericIHEAuditEventMessage event,
35              String sourceUserId,
36              String userName,
37              String destinationUserId,
38              String destinationUri,
39              String sourceIpAddress,
40              List<CodedValueType> userRoles) {
41  
42          event.setAuditSourceId(
43                  auditor.getAuditSourceId(),
44                  auditor.getAuditEnterpriseSiteId());
45  
46          // Set the source active participant
47          event.addSourceActiveParticipant(
48                  sourceUserId,
49                  serverSide ? null : auditor.getSystemAltUserId(),
50                  null,
51                  serverSide ? sourceIpAddress : auditor.getSystemNetworkId(),
52                  true);
53  
54          // Set the human requestor active participant (from XUA)
55          if (!EventUtils.isEmptyOrNull(userName)) {
56              event.addHumanRequestorActiveParticipant(userName, null, userName, userRoles);
57          }
58  
59          // Set the destination active participant
60          event.addDestinationActiveParticipant(
61                  destinationUserId,
62                  serverSide ? auditor.getSystemAltUserId() : null,
63                  null,
64                  EventUtils.getAddressForUrl(destinationUri, false),
65                  false);
66      }
67  }