PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/VeyoHealth/dcm4che-2.0.27/dcm4che-audit/src/main/java/org/dcm4che2/audit/message/AuditEvent.java

https://bitbucket.org/masoudn/veyohealth
Java | 444 lines | 201 code | 83 blank | 160 comment | 4 complexity | 1f948500f4fea6b80e996b18e2b3982a MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
  15. * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Gunter Zeilinger, Huetteldorferstr. 24/10, 1150 Vienna/Austria/Europe.
  19. * Portions created by the Initial Developer are Copyright (C) 2002-2005
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * See listed authors below.
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. package org.dcm4che2.audit.message;
  39. import java.io.IOException;
  40. import java.io.Writer;
  41. import java.util.ArrayList;
  42. import java.util.Collections;
  43. import java.util.Date;
  44. import java.util.List;
  45. /**
  46. * Event Identification. Identifies the name, action type, time, and
  47. * disposition of the audited event.
  48. *
  49. * @author Gunter Zeilinger <gunterze@gmail.com>
  50. * @version $Revision: 14557 $ $Date: 2010-12-16 13:10:55 +0100 (Thu, 16 Dec 2010) $
  51. * @since Nov 17, 2006
  52. */
  53. public class AuditEvent extends BaseElement {
  54. private final ID eventID;
  55. private final ArrayList<TypeCode> eventTypeCodes = new ArrayList<TypeCode>(
  56. 1);
  57. public AuditEvent(ID eventID, ActionCode action) {
  58. super("EventIdentification");
  59. if (eventID == null) {
  60. throw new NullPointerException();
  61. }
  62. this.eventID = eventID;
  63. addAttribute("EventActionCode", action, true);
  64. setEventDateTime(new Date());
  65. setOutcomeIndicator(OutcomeIndicator.SUCCESS);
  66. }
  67. public ID getEventID() {
  68. return eventID;
  69. }
  70. public ActionCode getEventActionCode() {
  71. return (ActionCode) getAttribute("EventActionCode");
  72. }
  73. public Date getEventDateTime() {
  74. return (Date) getAttribute("EventDateTime");
  75. }
  76. public AuditEvent setEventDateTime(Date datetime) {
  77. addAttribute("EventDateTime", datetime, false);
  78. return this;
  79. }
  80. public OutcomeIndicator getEventOutcomeIndicator() {
  81. return (OutcomeIndicator) getAttribute("EventOutcomeIndicator");
  82. }
  83. public AuditEvent setOutcomeIndicator(OutcomeIndicator outcome) {
  84. addAttribute("EventOutcomeIndicator", outcome, false);
  85. return this;
  86. }
  87. public List<TypeCode> getEventTypeCodes() {
  88. return Collections.unmodifiableList(eventTypeCodes);
  89. }
  90. public AuditEvent addEventTypeCode(TypeCode code) {
  91. if (code == null) {
  92. throw new NullPointerException("code");
  93. }
  94. eventTypeCodes.add(code);
  95. return this;
  96. }
  97. @Override
  98. protected boolean isEmpty() {
  99. return false;
  100. }
  101. @Override
  102. protected void outputContent(Writer out) throws IOException {
  103. eventID.output(out);
  104. outputChilds(out, eventTypeCodes);
  105. }
  106. /**
  107. * Identifier for a specific audited event, e.g., a menu item, program,
  108. * rule, policy, function code, application name, or URL.
  109. * It identifies the performed function.
  110. * <p>
  111. * Extended by DICOM defining a list of codes for event ids.
  112. */
  113. public static class ID extends CodeElement {
  114. /**
  115. * Event ID of {@link ApplicationActivityMessage}.
  116. */
  117. public static final ID APPLICATION_ACTIVITY =
  118. new ID("110100", "DCM", "Application Activity");
  119. /**
  120. * Event ID of {@link AuditLogUsedMessage}.
  121. */
  122. public static final ID AUDIT_LOG_USED =
  123. new ID("110101", "DCM", "Audit Log Used");
  124. /**
  125. * Event ID of {@link BeginTransferringMessage}.
  126. */
  127. public static final ID BEGIN_TRANSFERRING_DICOM_INSTANCES =
  128. new ID("110102", "DCM", "Begin Transferring DICOM Instances");
  129. /**
  130. * Event ID of {@link InstancesAccessedMessage}.
  131. */
  132. public static final ID DICOM_INSTANCES_ACCESSED =
  133. new ID("110103", "DCM", "DICOM Instances Accessed");
  134. /**
  135. * Event ID of {@link InstancesTransferredMessage}.
  136. */
  137. public static final ID DICOM_INSTANCES_TRANSFERRED =
  138. new ID("110104", "DCM", "DICOM Instances Transferred");
  139. /**
  140. * Event ID of {@link StudyDeletedMessage}.
  141. */
  142. public static final ID DICOM_STUDY_DELETED =
  143. new ID("110105", "DCM", "DICOM Study Deleted");
  144. /**
  145. * Event ID of {@link DataExportMessage}.
  146. */
  147. public static final ID EXPORT = new ID("110106", "DCM", "Export");
  148. /**
  149. * Event ID of {@link DataImportMessage}.
  150. */
  151. public static final ID IMPORT = new ID("110107", "DCM", "Import");
  152. /**
  153. * Event ID of {@link NetworkEntryMessage}.
  154. */
  155. public static final ID NETWORK_ENTRY =
  156. new ID("110108", "DCM", "Network Entry");
  157. /**
  158. * Event ID of {@link OrderRecordMessage}.
  159. */
  160. public static final ID ORDER_RECORD =
  161. new ID("110109", "DCM", "Order Record");
  162. /**
  163. * Event ID of {@link PatientRecordMessage}.
  164. */
  165. public static final ID PATIENT_RECORD =
  166. new ID("110110", "DCM", "Patient Record");
  167. /**
  168. * Event ID of {@link ProcedureRecordMessage}.
  169. */
  170. public static final ID PROCEDURE_RECORD =
  171. new ID("110111", "DCM", "Procedure Record");
  172. /**
  173. * Event ID of {@link QueryMessage}.
  174. */
  175. public static final ID QUERY = new ID("110112", "DCM", "Query");
  176. /**
  177. * Event ID of {@link SecurityAlertMessage}.
  178. */
  179. public static final ID SECURITY_ALERT =
  180. new ID("110113", "DCM", "Security Alert");
  181. /**
  182. * Event ID used for {@link UserAuthenticationMessage}.
  183. */
  184. public static final ID USER_AUTHENTICATION =
  185. new ID("110114", "DCM", "User Authentication");
  186. /**
  187. * Event ID used for {@link HealthServicesProvisionEventMessage}.
  188. */
  189. public static final ID HEALTH_SERVICE_PROVISION_EVENT =
  190. new ID("IHE0001", "IHE", "Health Services Provision Event");
  191. /**
  192. * Event ID used for {@link MedicationEventMessage}.
  193. */
  194. public static final ID MEDICATION_EVENT =
  195. new ID("IHE0002", "IHE", "Medication Event");
  196. /**
  197. * Event ID used for {@link PatientCareResourceAssignmentMessage}.
  198. */
  199. public static final ID PATIENT_CARE_RESOURCE_ASSIGNMENT =
  200. new ID("IHE0003", "IHE", "Patient Care Resource Assignment");
  201. /**
  202. * Event ID used for {@link PatientCareEpisodeMessage}.
  203. */
  204. public static final ID PATIENT_CARE_EPISODE =
  205. new ID("IHE0004", "IHE", "Patient Care Episode");
  206. /**
  207. * Event ID used for {@link PatientCareProtocolMessage}.
  208. */
  209. public static final ID PATIENT_CARE_PROTOCOL =
  210. new ID("IHE0005", "IHE", "Patient Care Protocol");
  211. public ID(String code) {
  212. super("EventID", code);
  213. }
  214. public ID(String code, String codeSystemName,
  215. String displayName) {
  216. super("EventID", code, codeSystemName, displayName);
  217. }
  218. }
  219. /**
  220. * Enumeration of types of action performed during the event that
  221. * generated the audit.
  222. */
  223. public static class ActionCode {
  224. /**
  225. * Create, e.g: create a new database object, such as Placing an Order.
  226. */
  227. public static final ActionCode CREATE = new ActionCode("C");
  228. /**
  229. * Read/View/Print/Query, e.g: sisplay or print data, such as a Doctor
  230. * Census.
  231. */
  232. public static final ActionCode READ = new ActionCode("R");
  233. /**
  234. * Update, e.g: Update data, such as Revise Patient Information.
  235. */
  236. public static final ActionCode UPDATE = new ActionCode("U");
  237. /**
  238. * Delete, e.g: Delete items, such as a doctor master file record.
  239. */
  240. public static final ActionCode DELETE = new ActionCode("D");
  241. /**
  242. * Execute, e.g: Perform a system or application function such as
  243. * log-on, program execution, or use of an object's method.
  244. */
  245. public static final ActionCode EXECUTE = new ActionCode("E");
  246. private final String value;
  247. private ActionCode(final String value) {
  248. this.value = value;
  249. }
  250. @Override
  251. public String toString() {
  252. return value;
  253. }
  254. }
  255. /**
  256. * Enumeration of values to indicate whether the event succeeded or
  257. * failed.
  258. */
  259. public static class OutcomeIndicator {
  260. private final String value;
  261. /**
  262. * Success.
  263. */
  264. public static final OutcomeIndicator SUCCESS =
  265. new OutcomeIndicator("0");
  266. /**
  267. * Minor failure; action restarted, e.g., invalid password with first
  268. * retry.
  269. */
  270. public static final OutcomeIndicator MINOR_FAILURE =
  271. new OutcomeIndicator("4");
  272. /**
  273. * Serious failure; action terminated, e.g., invalid password with
  274. * excess retries.
  275. */
  276. public static final OutcomeIndicator SERIOUS_FAILURE =
  277. new OutcomeIndicator("8");
  278. /**
  279. * Major failure; action made unavailable, e.g., user account
  280. * disabled due to excessive invalid log-on attempts.
  281. */
  282. public static final OutcomeIndicator MAJOR_FAILURE =
  283. new OutcomeIndicator("12");
  284. private OutcomeIndicator(final String value) {
  285. this.value = value;
  286. }
  287. @Override
  288. public String toString() {
  289. return value;
  290. }
  291. }
  292. /**
  293. * Identifier for the category of event.
  294. * <p>
  295. * Extended by DICOM defining a list of event type codes.
  296. */
  297. public static class TypeCode extends CodeElement {
  298. /**
  299. * Application Start.
  300. */
  301. public static final TypeCode APPLICATION_START =
  302. new TypeCode("110120", "DCM", "Application Start");
  303. public static final TypeCode APPLICATION_STOP =
  304. new TypeCode("110121", "DCM", "Application Stop");
  305. public static final TypeCode LOGIN =
  306. new TypeCode("110122", "DCM", "Login");
  307. public static final TypeCode LOGOUT =
  308. new TypeCode("110123", "DCM", "Logout");
  309. public static final TypeCode ATTACH =
  310. new TypeCode("110124", "DCM", "Attach");
  311. public static final TypeCode DETACH =
  312. new TypeCode("110125", "DCM", "Detach");
  313. public static final TypeCode NODE_AUTHENTICATION =
  314. new TypeCode("110126", "DCM", "Node Authentication");
  315. public static final TypeCode EMERGENCY_OVERRIDE_STARTED =
  316. new TypeCode("110127", "DCM", "Emergency Override Started");
  317. public static final TypeCode NETWORK_CONFIGURATION =
  318. new TypeCode("110128", "DCM", "Network Configuration");
  319. public static final TypeCode SECURITY_CONFIGURATION =
  320. new TypeCode("110129", "DCM", "Security Configuration");
  321. public static final TypeCode HARDWARE_CONFIGURATION =
  322. new TypeCode("110130", "DCM", "Hardware Configuration");
  323. public static final TypeCode SOFTWARE_CONFIGURATION =
  324. new TypeCode("110131", "DCM", "Software Configuration");
  325. public static final TypeCode USE_OF_RESTRICTED_FUNCTION =
  326. new TypeCode("110132", "DCM", "Use of Restricted Function");
  327. public static final TypeCode AUDIT_RECORDING_STOPPED =
  328. new TypeCode("110133", "DCM", "Audit Recording Stopped");
  329. public static final TypeCode AUDIT_RECORDING_STARTED =
  330. new TypeCode("110134", "DCM", "Audit Recording Started");
  331. public static final TypeCode OBJECT_SECURITY_ATTRIBUTES_CHANGED =
  332. new TypeCode("110135", "DCM",
  333. "Object Security Attributes Changed");
  334. public static final TypeCode SECURITY_ROLES_CHANGED =
  335. new TypeCode("110136", "DCM", "Security Roles Changed");
  336. public static final TypeCode USER_SECURITY_ATTRIBUTES_CHANGED =
  337. new TypeCode("110137", "DCM",
  338. "User security Attributes Changed");
  339. public static final TypeCode EMERGENCY_OVERRIDE_STOPPED =
  340. new TypeCode("110138", "DCM", "Emergency Override Stopped");
  341. public static final TypeCode REMOTE_SERVICE_OPERATION_STARTED =
  342. new TypeCode("110139", "DCM",
  343. "Remote Service Operation Started");
  344. public static final TypeCode REMOTE_SERVICE_OPERATION_STOPPED =
  345. new TypeCode("110140", "DCM",
  346. "Remote Service Operation Stopped");
  347. public static final TypeCode LOCAL_SERVICE_OPERATION_STARTED =
  348. new TypeCode("110141", "DCM",
  349. "Local Service Operation Started");
  350. public static final TypeCode LOCAL_SERVICE_OPERATION_STOPPED =
  351. new TypeCode("110142", "DCM",
  352. "Local Service Operation Stopped");
  353. public TypeCode(String code) {
  354. super("EventTypeCode", code);
  355. }
  356. public TypeCode(String code, String codeSystemName,
  357. String displayName) {
  358. super("EventTypeCode", code, codeSystemName, displayName);
  359. }
  360. }
  361. }