use of org.nhindirect.config.store.CertPolicyGroup in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method associatePolicyGroupToDomain.
@Override
@Transactional(readOnly = false)
public void associatePolicyGroupToDomain(long domainId, long policyGroupId) throws ConfigurationStoreException {
validateState();
// make sure the domain exists
final Domain domain = domainDao.getDomain(domainId);
if (domain == null)
throw new ConfigurationStoreException("Domain with id " + domainId + " does not exist");
// make sure the policy group exists
final CertPolicyGroup policyGroup = this.getPolicyGroupById(policyGroupId);
if (policyGroup == null)
throw new ConfigurationStoreException("Policy group with id " + policyGroup + " does not exist");
try {
final CertPolicyGroupDomainReltn policyGroupDomainAssoc = new CertPolicyGroupDomainReltn();
policyGroupDomainAssoc.setDomain(domain);
policyGroupDomainAssoc.setCertPolicyGroup(policyGroup);
entityManager.persist(policyGroupDomainAssoc);
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to associate policy group to domain.", e);
}
}
use of org.nhindirect.config.store.CertPolicyGroup in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method disassociatePolicyGroupFromDomains.
@Override
@Transactional(readOnly = false)
public void disassociatePolicyGroupFromDomains(long policyGroupId) throws ConfigurationStoreException {
validateState();
// make sure the policy group exists
final CertPolicyGroup policyGroup = this.getPolicyGroupById(policyGroupId);
if (policyGroup == null)
throw new ConfigurationStoreException("Policy group with id " + policyGroupId + " does not exist");
try {
final Query delete = entityManager.createQuery("DELETE from CertPolicyGroupDomainReltn cpr where cpr.certPolicyGroup = ?1");
delete.setParameter(1, policyGroup);
delete.executeUpdate();
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to dissaccociate domains from policy group id ." + policyGroupId, e);
}
}
use of org.nhindirect.config.store.CertPolicyGroup in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyGroupByName.
@Override
@Transactional(readOnly = true)
public CertPolicyGroup getPolicyGroupByName(String policyGroupName) throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cpg from CertPolicyGroup cpg WHERE UPPER(cpg.policyGroupName) = ?1");
select.setParameter(1, policyGroupName.toUpperCase(Locale.getDefault()));
final CertPolicyGroup rs = (CertPolicyGroup) select.getSingleResult();
// load relationships now as they were deferred by lazy loading
rs.getCertPolicyGroupReltn().size();
return rs;
} catch (NoResultException e) {
return null;
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute certificate policy group DAO query.", e);
}
}
Aggregations