[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 | package gov.hhs.fha.nhinc.gateway.policyenginetransformation;
|
---|
| 6 |
|
---|
| 7 | import com.services.nhinc.schema.auditmessage.FindAuditEventsType;
|
---|
| 8 | import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
|
---|
| 9 | import gov.hhs.fha.nhinc.common.eventcommon.FindAuditEventsEventType;
|
---|
| 10 | import gov.hhs.fha.nhinc.common.eventcommon.FindAuditEventsMessageType;
|
---|
| 11 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
|
---|
| 12 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
|
---|
| 13 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
|
---|
| 14 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.InboundOutboundChecker;
|
---|
| 15 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
|
---|
| 16 | import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
|
---|
| 17 | import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
|
---|
| 18 | import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
|
---|
| 19 |
|
---|
| 20 | /**
|
---|
| 21 | *
|
---|
| 22 | * @author svalluripalli
|
---|
| 23 | */
|
---|
| 24 | public class FindAuditEventsTransformHelper {
|
---|
| 25 |
|
---|
| 26 | private static final String ActionInValue = "AuditLogQueryIn";
|
---|
| 27 | private static final String ActionOutValue = "AuditLogQueryOut";
|
---|
| 28 | private static final String PatientIdAttributeId = Constants.ResourceIdAttributeId;
|
---|
| 29 |
|
---|
| 30 | public static CheckPolicyRequestType transformFindAuditEventsToCheckPolicy(FindAuditEventsEventType event) {
|
---|
| 31 | CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
|
---|
| 32 | RequestType request = new RequestType();
|
---|
| 33 |
|
---|
| 34 | if (event != null) {
|
---|
| 35 | if (InboundOutboundChecker.IsInbound(event.getDirection())) {
|
---|
| 36 | request.setAction(ActionHelper.actionFactory(ActionInValue));
|
---|
| 37 | }
|
---|
| 38 | if (InboundOutboundChecker.IsOutbound(event.getDirection())) {
|
---|
| 39 | request.setAction(ActionHelper.actionFactory(ActionOutValue));
|
---|
| 40 | }
|
---|
| 41 | SubjectType subject = SubjectHelper.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
|
---|
| 42 | request.getSubject().add(subject);
|
---|
| 43 | FindAuditEventsMessageType message = event.getMessage();
|
---|
| 44 | if (message != null) {
|
---|
| 45 | FindAuditEventsType findAudit = message.getFindAuditEvents();
|
---|
| 46 | if(findAudit != null)
|
---|
| 47 | {
|
---|
| 48 | findAudit.getPatientId();
|
---|
| 49 | ResourceType resource = new ResourceType();
|
---|
| 50 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientIdAttributeId, Constants.DataTypeString, findAudit.getPatientId()));
|
---|
| 51 | request.getResource().add(resource);
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 | genericPolicyRequest.setRequest(request);
|
---|
| 56 | return genericPolicyRequest;
|
---|
| 57 | }
|
---|
| 58 | }
|
---|