[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | package gov.hhs.fha.nhinc.gateway.policyenginetransformation;
|
---|
| 7 | import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
|
---|
| 8 | import gov.hhs.fha.nhinc.common.eventcommon.DocRetrieveEventType;
|
---|
| 9 | import gov.hhs.fha.nhinc.common.eventcommon.DocRetrieveMessageType;
|
---|
| 10 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
|
---|
| 11 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
|
---|
| 12 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
|
---|
| 13 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
|
---|
| 14 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType;
|
---|
| 15 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType.DocumentRequest;
|
---|
| 16 | import java.util.List;
|
---|
| 17 | import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
|
---|
| 18 | import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
|
---|
| 19 | import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
| 22 | *
|
---|
| 23 | * @author svalluripalli
|
---|
| 24 | */
|
---|
| 25 | public class DocRetrieveTransformHelper {
|
---|
| 26 | private static final String ActionValue = "DocumentRetrieveIn";
|
---|
| 27 |
|
---|
| 28 | public static CheckPolicyRequestType transformDocRetrieveToCheckPolicy(DocRetrieveEventType event) {
|
---|
| 29 | CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
|
---|
| 30 | //TODO: Need to handle DocumentSet
|
---|
| 31 | //DocRetrieveMessageType docRetrieve = event.getMessage();
|
---|
| 32 | RequestType request = new RequestType();
|
---|
| 33 | request.setAction(ActionHelper.actionFactory(ActionValue));
|
---|
| 34 | SubjectType subject = SubjectHelper.subjectFactory(event.getSendingHomeCommunity() , event.getMessage().getAssertion());
|
---|
| 35 | request.getSubject().add(subject);
|
---|
| 36 | DocRetrieveMessageType docMessage = event.getMessage();
|
---|
| 37 | RetrieveDocumentSetRequestType retrieveDocumentSetRequest = docMessage.getRetrieveDocumentSetRequest();
|
---|
| 38 | List<DocumentRequest> docRequestList = retrieveDocumentSetRequest.getDocumentRequest();
|
---|
| 39 | if(docRequestList != null && docRequestList.size() > 0)
|
---|
| 40 | {
|
---|
| 41 | for(DocumentRequest docReq : docRequestList)
|
---|
| 42 | {
|
---|
| 43 | request.getResource().add(getResource(docReq));
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | genericPolicyRequest.setRequest(request);
|
---|
| 47 | return genericPolicyRequest;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | private static ResourceType getResource(DocumentRequest documentRequest)
|
---|
| 51 | {
|
---|
| 52 | String homeCommunityId = documentRequest.getHomeCommunityId();
|
---|
| 53 | String repositoryUniqueId = documentRequest.getRepositoryUniqueId();
|
---|
| 54 | String documentId = documentRequest.getDocumentUniqueId();
|
---|
| 55 | ResourceType resource = new ResourceType();
|
---|
| 56 | resource.getAttribute().add(AttributeHelper.attributeFactory(Constants.HomeCommunityAttributeId, Constants.DataTypeString, homeCommunityId));
|
---|
| 57 | resource.getAttribute().add(AttributeHelper.attributeFactory(Constants.RespositoryAttributeId, Constants.DataTypeString, repositoryUniqueId));
|
---|
| 58 | resource.getAttribute().add(AttributeHelper.attributeFactory(Constants.DocumentAttributeId, Constants.DataTypeString, documentId));
|
---|
| 59 | return resource;
|
---|
| 60 | }
|
---|
| 61 | }
|
---|