*/
public static RequestType createRequestType(Principal principal, String resourceId,
List<String> confidentialityCodes, List<String> consentedIds, String resourceType,
List<String> resourcePermissions)
{
RequestType requestType = new RequestType();
//create the Subject of the request
SubjectType subject = new SubjectType();
subject.getAttribute().add(
RequestAttributeFactory.createStringAttributeType(XACMLConstants.ATTRIBUTEID_SUBJECT_ID, null, principal
.getName()));
requestType.getSubject().add(subject);
//create the Resource of the request
ResourceType resource = new ResourceType();
resource.getAttribute()
.add(
RequestAttributeFactory.createStringAttributeType(XACMLConstants.ATTRIBUTEID_RESOURCE_ID, null,
resourceId));
for (String confidentialityCode : confidentialityCodes)
{
resource.getAttribute().add(
RequestAttributeFactory.createStringAttributeType(CONFIDENTIALITY_CODE, null, confidentialityCode));
}
for (String consentedId : consentedIds)
{
resource.getAttribute().add(
RequestAttributeFactory.createStringAttributeType(CONSENTED_SUBJECT_ID, null, consentedId));
}
resource.getAttribute().add(RequestAttributeFactory.createStringAttributeType(RESOURCE_TYPE, null, resourceType));
for (String resourcePermission : resourcePermissions)
{
resource.getAttribute().add(
RequestAttributeFactory.createStringAttributeType(HL7_RESOURCE_PERMISSION, null, resourcePermission));
}
requestType.getResource().add(resource);
//create the Action of the request - avoid NPE
requestType.setAction(new ActionType());
return requestType;
}