use of org.nhindirect.config.model.CertPolicyGroup in project nhin-d by DirectProject.
the class EntityModelConversion method toEntityCertPolicyGroup.
public static org.nhindirect.config.store.CertPolicyGroup toEntityCertPolicyGroup(CertPolicyGroup group) {
if (group == null)
return null;
final org.nhindirect.config.store.CertPolicyGroup retVal = new org.nhindirect.config.store.CertPolicyGroup();
final Collection<org.nhindirect.config.store.CertPolicyGroupReltn> reltns = new ArrayList<org.nhindirect.config.store.CertPolicyGroupReltn>();
if (group.getPolicies() != null) {
for (CertPolicyGroupUse use : group.getPolicies()) {
org.nhindirect.config.store.CertPolicyGroupReltn reltn = new org.nhindirect.config.store.CertPolicyGroupReltn();
reltn.setCertPolicy(toEntityCertPolicy(use.getPolicy()));
reltn.setCertPolicyGroup(retVal);
reltn.setIncoming(use.isIncoming());
reltn.setOutgoing(use.isOutgoing());
if (use.getPolicyUse() != null)
reltn.setPolicyUse(org.nhindirect.config.store.CertPolicyUse.valueOf(use.getPolicyUse().toString()));
reltns.add(reltn);
}
}
retVal.setPolicyGroupName(group.getPolicyGroupName());
retVal.setCreateTime(group.getCreateTime());
retVal.setCertPolicyGroupReltn(reltns);
return retVal;
}
use of org.nhindirect.config.model.CertPolicyGroup in project nhin-d by DirectProject.
the class EntityModelConversion method toModelCertPolicyGroup.
public static CertPolicyGroup toModelCertPolicyGroup(org.nhindirect.config.store.CertPolicyGroup group) {
if (group == null)
return null;
final CertPolicyGroup retVal = new CertPolicyGroup();
final Collection<CertPolicyGroupUse> uses = new ArrayList<CertPolicyGroupUse>();
if (group.getCertPolicyGroupReltn() != null) {
for (org.nhindirect.config.store.CertPolicyGroupReltn reltn : group.getCertPolicyGroupReltn()) {
final CertPolicyGroupUse use = new CertPolicyGroupUse();
use.setPolicy(toModelCertPolicy(reltn.getCertPolicy()));
if (reltn.getPolicyUse() != null)
use.setPolicyUse(CertPolicyUse.valueOf(reltn.getPolicyUse().toString()));
use.setIncoming(reltn.isIncoming());
use.setOutgoing(reltn.isOutgoing());
uses.add(use);
}
}
retVal.setPolicyGroupName(group.getPolicyGroupName());
retVal.setCreateTime(group.getCreateTime());
retVal.setPolicies(uses);
return retVal;
}
use of org.nhindirect.config.model.CertPolicyGroup in project nhin-d by DirectProject.
the class CertPolicyResource method getPolicyGroupByName.
/**
* Gets a policy group name.
* @param groupName The name of the policy group to retrieve.
* @return A JSON representation of the policy group. Returns a status of 404 if a policy group with the given name does
* not exist.
*/
@Path("groups/{groupName}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPolicyGroupByName(@PathParam("groupName") String groupName) {
try {
final org.nhindirect.config.store.CertPolicyGroup retGroup = policyDao.getPolicyGroupByName(groupName);
if (retGroup == null)
return Response.status(Status.NOT_FOUND).cacheControl(noCache).build();
final CertPolicyGroup modelGroup = EntityModelConversion.toModelCertPolicyGroup(retGroup);
return Response.ok(modelGroup).cacheControl(noCache).build();
} catch (Throwable e) {
log.error("Error looking up cert policy group", e);
return Response.serverError().cacheControl(noCache).build();
}
}
Aggregations