use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method updateLastUpdateError.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = false)
public void updateLastUpdateError(long trustBundleId, Calendar attemptTime, BundleRefreshError error) throws ConfigurationStoreException {
validateState();
try {
final TrustBundle existingBundle = this.getTrustBundleById(trustBundleId);
if (existingBundle == null)
throw new ConfigurationStoreException("Trust bundle does not exist");
existingBundle.setLastRefreshAttempt(attemptTime);
existingBundle.setLastRefreshError(error);
entityManager.persist(existingBundle);
entityManager.flush();
} catch (ConfigurationStoreException cse) {
throw cse;
}///CLOVER:OFF
catch (Exception e) {
throw new ConfigurationStoreException("Failed to update bundle last refresh error.", e);
}
///CLOVER:ON
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method removePolicyUseFromGroups.
/**
* {@inheritDoc}
*/
@Transactional(readOnly = false)
public void removePolicyUseFromGroups(long policyId) throws ConfigurationStoreException {
validateState();
// make sure the trust bundle exists
final CertPolicy policy = this.getPolicyById(policyId);
if (policy == null)
throw new ConfigurationStoreException("Certificate policy with id " + policyId + " does not exist");
try {
final Query delete = entityManager.createQuery("DELETE from CertPolicyGroupReltn cpr where cpr.certPolicy = ?1");
delete.setParameter(1, policy);
delete.executeUpdate();
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to remove policy id " + policyId + " from all groups", e);
}
}
use of org.nhindirect.config.store.ConfigurationStoreException in project nhin-d by DirectProject.
the class CertPolicyDaoImpl method getPolicyGroupById.
@Override
@Transactional(readOnly = true)
public CertPolicyGroup getPolicyGroupById(long id) throws ConfigurationStoreException {
validateState();
try {
final Query select = entityManager.createQuery("SELECT cpg from CertPolicyGroup cpg WHERE cpg.id = ?1");
select.setParameter(1, id);
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 updateGroupAttributes.
@Override
@Transactional(readOnly = false)
public void updateGroupAttributes(long id, String groupName) throws ConfigurationStoreException {
validateState();
try {
final CertPolicyGroup existingPolicyGroup = this.getPolicyGroupById(id);
if (existingPolicyGroup == null)
throw new ConfigurationStoreException("Policy group does not exist");
if (groupName != null && !groupName.isEmpty())
existingPolicyGroup.setPolicyGroupName(groupName);
entityManager.persist(existingPolicyGroup);
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 deletePolicyGroups.
@Override
@Transactional(readOnly = false)
public void deletePolicyGroups(long[] groupIds) throws ConfigurationStoreException {
validateState();
if (groupIds == null || groupIds.length == 0)
return;
for (long id : groupIds) {
try {
final CertPolicyGroup bundle = this.getPolicyGroupById(id);
entityManager.remove(bundle);
entityManager.flush();
} catch (ConfigurationStoreException e) {
log.warn(e.getMessage(), e);
}
}
}
Aggregations