use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method addPolicyGroup.
@Override
@Transactional(readOnly = false)
public void addPolicyGroup(CertPolicyGroup group) throws ConfigurationStoreException {
validateState();
try {
final CertPolicyGroup existingPolicyGroup = this.getPolicyGroupByName(group.getPolicyGroupName());
if (existingPolicyGroup != null)
throw new ConfigurationStoreException("Certificate policy group " + group.getPolicyGroupName() + " already exists");
group.setCreateTime(Calendar.getInstance(Locale.getDefault()));
entityManager.persist(group);
entityManager.flush();
} catch (ConfigurationStoreException cse) {
throw cse;
}///CLOVER:OFF
catch (Exception e) {
throw new ConfigurationStoreException("Failed to add certificate policy group " + group.getPolicyGroupName(), e);
}
///CLOVER:ON
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicies.
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<CertPolicy> getPolicies() throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cp from CertPolicy cp");
final Collection<CertPolicy> rs = select.getResultList();
if (rs.size() == 0)
return Collections.emptyList();
return rs;
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute certificate policy DAO query.", e);
}
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method deletePolicies.
@Override
@Transactional(readOnly = false)
public void deletePolicies(long[] policyIds) throws ConfigurationStoreException {
validateState();
if (policyIds == null || policyIds.length == 0)
return;
for (long id : policyIds) {
try {
final CertPolicy bundle = this.getPolicyById(id);
this.removePolicyUseFromGroups(id);
entityManager.remove(bundle);
entityManager.flush();
} catch (ConfigurationStoreException e) {
log.warn(e.getMessage(), e);
}
}
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyGroups.
@Override
@Transactional(readOnly = true)
public Collection<CertPolicyGroup> getPolicyGroups() throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cpg from CertPolicyGroup cpg");
@SuppressWarnings("unchecked") final Collection<CertPolicyGroup> rs = select.getResultList();
if (rs.size() == 0)
return Collections.emptyList();
// load relationships now as they were deferred by lazy loading
for (CertPolicyGroup group : rs) group.getCertPolicyGroupReltn().size();
return rs;
} 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 TrustBundleDaoImpl method getTrustBundlesByDomain.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<TrustBundleDomainReltn> getTrustBundlesByDomain(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<TrustBundleDomainReltn> retVal = null;
try {
final Query select = entityManager.createQuery("SELECT tbd from TrustBundleDomainReltn tbd where tbd.domain = ?1");
select.setParameter(1, domain);
retVal = (Collection<TrustBundleDomainReltn>) select.getResultList();
if (retVal.size() == 0)
return Collections.emptyList();
for (TrustBundleDomainReltn reltn : retVal) {
if (!reltn.getTrustBundle().getTrustBundleAnchors().isEmpty())
for (TrustBundleAnchor anchor : reltn.getTrustBundle().getTrustBundleAnchors()) anchor.getData();
}
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute trust bundle relation DAO query.", e);
}
return retVal;
}
Aggregations