use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method disassociatePolicyGroupsFromDomain.
@Override
@Transactional(readOnly = false)
public void disassociatePolicyGroupsFromDomain(long domainId) 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");
try {
final Query delete = entityManager.createQuery("DELETE from CertPolicyGroupDomainReltn cpr where cpr.domain = ?1");
delete.setParameter(1, domain);
delete.executeUpdate();
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to dissaccociate group policies from domain id ." + domainId, e);
}
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyGroupsByDomain.
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<CertPolicyGroupDomainReltn> getPolicyGroupsByDomain(long domainId) 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");
Collection<CertPolicyGroupDomainReltn> retVal = null;
try {
final Query select = entityManager.createQuery("SELECT cpr from CertPolicyGroupDomainReltn cpr where cpr.domain = ?1");
select.setParameter(1, domain);
retVal = (Collection<CertPolicyGroupDomainReltn>) select.getResultList();
if (retVal.size() == 0)
return Collections.emptyList();
for (CertPolicyGroupDomainReltn reltn : retVal) {
if (!reltn.getCertPolicyGroup().getCertPolicyGroupReltn().isEmpty())
for (CertPolicyGroupReltn groupReltn : reltn.getCertPolicyGroup().getCertPolicyGroupReltn()) groupReltn.getCertPolicy().getPolicyData();
}
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute policy group to domain relation DAO query.", e);
}
return retVal;
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method updatePolicyAttributes.
@Override
@Transactional(readOnly = false)
public void updatePolicyAttributes(long id, String policyName, PolicyLexicon lexicon, byte[] policyData) throws ConfigurationStoreException {
validateState();
try {
final CertPolicy existingPolicy = this.getPolicyById(id);
if (existingPolicy == null)
throw new ConfigurationStoreException("Policy does not exist");
if (policyData != null && policyData.length > 0)
existingPolicy.setPolicyData(policyData);
if (policyName != null && !policyName.isEmpty())
existingPolicy.setPolicyName(policyName);
if (lexicon != null)
existingPolicy.setLexicon(lexicon);
entityManager.persist(existingPolicy);
entityManager.flush();
} catch (ConfigurationStoreException cse) {
throw cse;
}///CLOVER:OFF
catch (Exception e) {
throw new ConfigurationStoreException("Failed to update certificate policy attributes.", e);
}
///CLOVER:ON
}
use of org.nhindirect.config.store.ConfigurationStoreException 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);
}
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method removePolicyUseFromGroup.
@Override
@Transactional(readOnly = false)
public void removePolicyUseFromGroup(long policyGroupReltnId) throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("DELETE from CertPolicyGroupReltn cpr WHERE cpr.id = ?1");
select.setParameter(1, policyGroupReltnId);
select.executeUpdate();
entityManager.flush();
} catch (NoResultException e) {
throw new ConfigurationStoreException("Policy group reltn with id " + policyGroupReltnId + " does not exist");
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to remove policy use from policy group.", e);
}
}
Aggregations