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.core.atna;
17  
18  import org.openehealth.ipf.commons.ihe.core.atna.custom.*;
19  import org.openhealthtools.ihe.atna.auditor.*;
20  import org.openhealthtools.ihe.atna.auditor.context.AuditorModuleConfig;
21  import org.openhealthtools.ihe.atna.auditor.context.AuditorModuleContext;
22  
23  import java.net.InetAddress;
24  import java.net.UnknownHostException;
25  
26  /**
27   * Access synchronizer for OHT ATNA Auditor singletons.
28   *
29   * @deprecated to be removed
30   */
31  public abstract class AuditorManager {
32      private static final Object sync = new Object();
33  
34      private AuditorManager() {
35          throw new IllegalStateException("Static helper class cannot be instantiated");
36      }
37  
38      /**
39       * Generic method which supports third-party auditors as well
40       *
41       * @param auditorClass class of the auditor to retrieve
42       * @param <T>          type of the auditor to retrieve
43       * @return auditor instance
44       */
45      @SuppressWarnings("unchecked")
46      public static <T extends IHEAuditor> T getAuditor(Class<T> auditorClass) {
47          synchronized (sync) {
48              AuditorModuleContext ctx = AuditorModuleContext.getContext();
49              return (T) ctx.getAuditor(auditorClass);
50          }
51      }
52  
53      public static XDSRegistryAuditor getRegistryAuditor() {
54          synchronized (sync) {
55              return XDSRegistryAuditor.getAuditor();
56          }
57      }
58  
59      public static XDSRepositoryAuditor getRepositoryAuditor() {
60          synchronized (sync) {
61              return XDSRepositoryAuditor.getAuditor();
62          }
63      }
64  
65      public static XDSConsumerAuditor getConsumerAuditor() {
66          synchronized (sync) {
67              XDSConsumerAuditor auditor = XDSConsumerAuditor.getAuditor();
68  
69              // for ITI-16 and ITI-17
70              AuditorModuleConfig config = auditor.getConfig();
71              if (config.getSystemUserId() == null) {
72                  try {
73                      config.setSystemUserId(InetAddress.getLocalHost().getHostAddress());
74                  } catch (UnknownHostException e) {
75                      config.setSystemUserId("unknown");
76                  }
77              }
78              return auditor;
79          }
80      }
81  
82      public static XDSSourceAuditor getSourceAuditor() {
83          synchronized (sync) {
84              return XDSSourceAuditor.getAuditor();
85          }
86      }
87  
88      public static PIXManagerAuditor getPIXManagerAuditor() {
89          synchronized (sync) {
90              return PIXManagerAuditor.getAuditor();
91          }
92      }
93  
94      public static PIXSourceAuditor getPIXSourceAuditor() {
95          synchronized (sync) {
96              return PIXSourceAuditor.getAuditor();
97          }
98      }
99  
100     public static PIXConsumerAuditor getPIXConsumerAuditor() {
101         synchronized (sync) {
102             return PIXConsumerAuditor.getAuditor();
103         }
104     }
105 
106     public static PDQConsumerAuditor getPDQConsumerAuditor() {
107         synchronized (sync) {
108             return PDQConsumerAuditor.getAuditor();
109         }
110     }
111 
112     public static PAMSourceAuditor getPAMSourceAuditor() {
113         synchronized (sync) {
114             return PAMSourceAuditor.getAuditor();
115         }
116     }
117 
118     public static Hl7v3Auditor getHl7v3Auditor() {
119         synchronized (sync) {
120             return Hl7v3Auditor.getAuditor();
121         }
122     }
123 
124     public static FhirAuditor getFhirAuditor() {
125         synchronized (sync) {
126             return FhirAuditor.getAuditor();
127         }
128     }
129 
130     public static CustomXdsAuditor getCustomXdsAuditor() {
131         synchronized (sync) {
132             return CustomXdsAuditor.getAuditor();
133         }
134     }
135 
136     public static CustomPixAuditor getCustomPixAuditor() {
137         synchronized (sync) {
138             return CustomPixAuditor.getAuditor();
139         }
140     }
141 
142     public static XCAInitiatingGatewayAuditor getXCAInitiatingGatewayAuditor() {
143         synchronized (sync) {
144             return XCAInitiatingGatewayAuditor.getAuditor();
145         }
146     }
147 
148     public static XCARespondingGatewayAuditor getXCARespondingGatewayAuditor() {
149         synchronized (sync) {
150             return XCARespondingGatewayAuditor.getAuditor();
151         }
152     }
153 
154     public static HpdAuditor getHpdAuditor() {
155         synchronized (sync) {
156             return HpdAuditor.getAuditor();
157         }
158     }
159 }