use of org.nhindirect.config.store.TrustBundle 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.TrustBundle in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method deleteTrustBundles.
/**
* {@inheritDoc}
*/
@Transactional(readOnly = false)
@Override
public void deleteTrustBundles(long[] trustBundleIds) throws ConfigurationStoreException {
validateState();
if (trustBundleIds == null || trustBundleIds.length == 0)
return;
for (long id : trustBundleIds) {
try {
final TrustBundle bundle = this.getTrustBundleById(id);
this.disassociateTrustBundleFromDomains(id);
entityManager.remove(bundle);
entityManager.flush();
} catch (ConfigurationStoreException e) {
log.warn(e.getMessage(), e);
}
}
}
use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method disassociateTrustBundleFromDomain.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = false)
public void disassociateTrustBundleFromDomain(long domainId, long trustBundleId) 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 trust bundle exists
final TrustBundle trustBundle = this.getTrustBundleById(trustBundleId);
if (trustBundle == null)
throw new ConfigurationStoreException("Trust budnel with id " + trustBundle + " does not exist");
try {
final Query select = entityManager.createQuery("SELECT tbd from TrustBundleDomainReltn tbd where tbd.domain = ?1 " + " and tbd.trustBundle = ?2 ");
select.setParameter(1, domain);
select.setParameter(2, trustBundle);
final TrustBundleDomainReltn reltn = (TrustBundleDomainReltn) select.getSingleResult();
entityManager.remove(reltn);
entityManager.flush();
} catch (NoResultException e) {
throw new ConfigurationStoreException("Association between domain id " + domainId + " and trust bundle id" + trustBundleId + " does not exist", e);
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to delete trust bundle to domain relation.", e);
}
}
use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method associateTrustBundleToDomain.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = false)
public void associateTrustBundleToDomain(long domainId, long trustBundleId, boolean incoming, boolean outgoing) 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 trust bundle exists
final TrustBundle trustBundle = this.getTrustBundleById(trustBundleId);
if (trustBundle == null)
throw new ConfigurationStoreException("Trust budnel with id " + trustBundle + " does not exist");
try {
final TrustBundleDomainReltn domainTrustBundleAssoc = new TrustBundleDomainReltn();
domainTrustBundleAssoc.setDomain(domain);
domainTrustBundleAssoc.setTrustBundle(trustBundle);
domainTrustBundleAssoc.setIncoming(incoming);
domainTrustBundleAssoc.setOutgoing(outgoing);
entityManager.persist(domainTrustBundleAssoc);
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to associate trust bundle to domain.", e);
}
}
Aggregations