use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class DefaultBundleRefreshProcessorImpl_refreshBundleTest method testRefreshBundle_errorOnUpdate.
@SuppressWarnings("unchecked")
public void testRefreshBundle_errorOnUpdate() throws Exception {
DefaultBundleRefreshProcessorImpl processor = new DefaultBundleRefreshProcessorImpl();
processor.setDao(dao);
final TrustBundle bundle = new TrustBundle();
bundle.setBundleName("Junit Bundle");
File fl = new File("src/test/resources/bundles/signedbundle.p7b");
bundle.setBundleURL(filePrefix + fl.getAbsolutePath());
doThrow(new ConfigurationStoreException("Just Passing Through")).when(dao).updateTrustBundleAnchors(eq(bundle.getId()), (Calendar) any(), (Collection<TrustBundleAnchor>) any(), (String) any());
processor.refreshBundle(bundle);
verify(dao, times(1)).updateTrustBundleAnchors(eq(bundle.getId()), (Calendar) any(), (Collection<TrustBundleAnchor>) any(), (String) any());
}
use of org.nhindirect.config.store.TrustBundle 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.TrustBundle in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method disassociateTrustBundleFromDomains.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = false)
public void disassociateTrustBundleFromDomains(long trustBundleId) throws ConfigurationStoreException {
validateState();
// 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 delete = entityManager.createQuery("DELETE from TrustBundleDomainReltn tbd where tbd.trustBundle = ?1");
delete.setParameter(1, trustBundle);
delete.executeUpdate();
entityManager.flush();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to dissaccociate domains from trust bundle id ." + trustBundleId, e);
}
}
use of org.nhindirect.config.store.TrustBundle in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method updateTrustBundleAttributes.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = false)
public void updateTrustBundleAttributes(long trustBundleId, String bundleName, String bundleUrl, X509Certificate signingCert, int refreshInterval) throws ConfigurationStoreException {
validateState();
try {
final TrustBundle existingBundle = this.getTrustBundleById(trustBundleId);
if (existingBundle == null)
throw new ConfigurationStoreException("Trust bundle does not exist");
if (signingCert == null)
existingBundle.setSigningCertificateData(null);
else
existingBundle.setSigningCertificateData(signingCert.getEncoded());
existingBundle.setRefreshInterval(refreshInterval);
if (bundleName != null && !bundleName.isEmpty())
existingBundle.setBundleName(bundleName);
if (bundleUrl != null && !bundleUrl.isEmpty())
existingBundle.setBundleURL(bundleUrl);
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.TrustBundle in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method getTrustBundles.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<TrustBundle> getTrustBundles() throws ConfigurationStoreException {
validateState();
Collection<TrustBundle> rs;
try {
Query select = entityManager.createQuery("SELECT tb from TrustBundle tb");
rs = select.getResultList();
if (rs.size() == 0)
return Collections.emptyList();
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute trust bundle DAO query.", e);
}
// make sure the anchors are loaded
for (TrustBundle bundle : rs) {
if (!bundle.getTrustBundleAnchors().isEmpty())
for (TrustBundleAnchor anchor : bundle.getTrustBundleAnchors()) anchor.getData();
}
return rs;
}
Aggregations