use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method updateTrustBundleAnchors.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = false)
public void updateTrustBundleAnchors(long trustBundleId, Calendar attemptTime, Collection<TrustBundleAnchor> newAnchorSet, String bundleCheckSum) throws ConfigurationStoreException {
validateState();
try {
final TrustBundle existingBundle = this.getTrustBundleById(trustBundleId);
if (existingBundle == null)
throw new ConfigurationStoreException("Trust bundle does not exist");
// blow away all the existing bundles
final Query delete = entityManager.createQuery("DELETE from TrustBundleAnchor tba where tba.trustBundle = ?1");
delete.setParameter(1, existingBundle);
delete.executeUpdate();
// now update the bundle
existingBundle.setCheckSum(bundleCheckSum);
existingBundle.setTrustBundleAnchors(newAnchorSet);
existingBundle.setLastRefreshAttempt(attemptTime);
existingBundle.setLastSuccessfulRefresh(Calendar.getInstance(Locale.getDefault()));
entityManager.persist(existingBundle);
entityManager.flush();
} catch (ConfigurationStoreException cse) {
throw cse;
}///CLOVER:OFF
catch (Exception e) {
throw new ConfigurationStoreException("Failed to update anchors in trust bundle.", e);
}
///CLOVER:ON
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyByName.
@Override
@Transactional(readOnly = true)
public CertPolicy getPolicyByName(String policyName) throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cp from CertPolicy cp WHERE UPPER(cp.policyName) = ?1");
select.setParameter(1, policyName.toUpperCase(Locale.getDefault()));
final CertPolicy rs = (CertPolicy) select.getSingleResult();
return rs;
} catch (NoResultException e) {
return null;
} 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 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.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyById.
@Override
@Transactional(readOnly = true)
public CertPolicy getPolicyById(long id) throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cp from CertPolicy cp WHERE cp.id = ?1");
select.setParameter(1, id);
final CertPolicy rs = (CertPolicy) select.getSingleResult();
return rs;
} catch (NoResultException e) {
return null;
} 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 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);
}
}
Aggregations