Search in sources :

Example 11 with TrustBundleAnchor

use of org.nhindirect.config.store.TrustBundleAnchor in project nhin-d by DirectProject.

the class TrustBundleDaoImpl method getTrustBundleById.

/**
	 * {@inheritDoc}
	 */
@Override
@Transactional(readOnly = true)
public TrustBundle getTrustBundleById(long id) throws ConfigurationStoreException {
    validateState();
    try {
        Query select = entityManager.createQuery("SELECT tb from TrustBundle tb WHERE tb.id = ?1");
        select.setParameter(1, id);
        TrustBundle rs = (TrustBundle) select.getSingleResult();
        // make sure the anchors are loaded
        if (!rs.getTrustBundleAnchors().isEmpty())
            for (TrustBundleAnchor anchor : rs.getTrustBundleAnchors()) anchor.getData();
        return rs;
    } catch (NoResultException e) {
        return null;
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to execute trust bundle DAO query.", e);
    }
}
Also used : Query(javax.persistence.Query) TrustBundle(org.nhindirect.config.store.TrustBundle) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) TrustBundleAnchor(org.nhindirect.config.store.TrustBundleAnchor) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with TrustBundleAnchor

use of org.nhindirect.config.store.TrustBundleAnchor in project nhin-d by DirectProject.

the class TrustBundleDaoImpl method getTrustBundleByName.

/**
	 * {@inheritDoc}
	 */
@Override
@Transactional(readOnly = true)
public TrustBundle getTrustBundleByName(String bundleName) throws ConfigurationStoreException {
    validateState();
    try {
        Query select = entityManager.createQuery("SELECT tb from TrustBundle tb WHERE UPPER(tb.bundleName) = ?1");
        select.setParameter(1, bundleName.toUpperCase(Locale.getDefault()));
        TrustBundle rs = (TrustBundle) select.getSingleResult();
        // make sure the anchors are loaded
        if (!rs.getTrustBundleAnchors().isEmpty())
            for (TrustBundleAnchor anchor : rs.getTrustBundleAnchors()) anchor.getData();
        return rs;
    } catch (NoResultException e) {
        return null;
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to execute trust bundle DAO query.", e);
    }
}
Also used : Query(javax.persistence.Query) TrustBundle(org.nhindirect.config.store.TrustBundle) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) TrustBundleAnchor(org.nhindirect.config.store.TrustBundleAnchor) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TrustBundleAnchor (org.nhindirect.config.store.TrustBundleAnchor)12 TrustBundle (org.nhindirect.config.store.TrustBundle)10 File (java.io.File)7 ConfigurationStoreException (org.nhindirect.config.store.ConfigurationStoreException)6 NoResultException (javax.persistence.NoResultException)4 Query (javax.persistence.Query)4 Transactional (org.springframework.transaction.annotation.Transactional)4 SocketTimeoutException (java.net.SocketTimeoutException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 Handler (org.apache.camel.Handler)1 TrustBundleService (org.nhindirect.config.service.TrustBundleService)1 Domain (org.nhindirect.config.store.Domain)1 TrustBundleDomainReltn (org.nhindirect.config.store.TrustBundleDomainReltn)1 ApplicationContext (org.springframework.context.ApplicationContext)1