Search in sources :

Example 6 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method addPolicyGroup.

@Override
@Transactional(readOnly = false)
public void addPolicyGroup(CertPolicyGroup group) throws ConfigurationStoreException {
    validateState();
    try {
        final CertPolicyGroup existingPolicyGroup = this.getPolicyGroupByName(group.getPolicyGroupName());
        if (existingPolicyGroup != null)
            throw new ConfigurationStoreException("Certificate policy group " + group.getPolicyGroupName() + " already exists");
        group.setCreateTime(Calendar.getInstance(Locale.getDefault()));
        entityManager.persist(group);
        entityManager.flush();
    } catch (ConfigurationStoreException cse) {
        throw cse;
    }///CLOVER:OFF
     catch (Exception e) {
        throw new ConfigurationStoreException("Failed to add certificate policy group " + group.getPolicyGroupName(), e);
    }
///CLOVER:ON
}
Also used : CertPolicyGroup(org.nhindirect.config.store.CertPolicyGroup) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method getPolicies.

@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<CertPolicy> getPolicies() throws ConfigurationStoreException {
    validateState();
    try {
        final Query select = entityManager.createQuery("SELECT cp from CertPolicy cp");
        final Collection<CertPolicy> rs = select.getResultList();
        if (rs.size() == 0)
            return Collections.emptyList();
        return rs;
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to execute certificate policy DAO query.", e);
    }
}
Also used : Query(javax.persistence.Query) CertPolicy(org.nhindirect.config.store.CertPolicy) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method deletePolicies.

@Override
@Transactional(readOnly = false)
public void deletePolicies(long[] policyIds) throws ConfigurationStoreException {
    validateState();
    if (policyIds == null || policyIds.length == 0)
        return;
    for (long id : policyIds) {
        try {
            final CertPolicy bundle = this.getPolicyById(id);
            this.removePolicyUseFromGroups(id);
            entityManager.remove(bundle);
            entityManager.flush();
        } catch (ConfigurationStoreException e) {
            log.warn(e.getMessage(), e);
        }
    }
}
Also used : CertPolicy(org.nhindirect.config.store.CertPolicy) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method getPolicyGroups.

@Override
@Transactional(readOnly = true)
public Collection<CertPolicyGroup> getPolicyGroups() throws ConfigurationStoreException {
    validateState();
    try {
        final Query select = entityManager.createQuery("SELECT cpg from CertPolicyGroup cpg");
        @SuppressWarnings("unchecked") final Collection<CertPolicyGroup> rs = select.getResultList();
        if (rs.size() == 0)
            return Collections.emptyList();
        // load relationships now as they were deferred by lazy loading 
        for (CertPolicyGroup group : rs) group.getCertPolicyGroupReltn().size();
        return rs;
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to execute certificate policy group DAO query.", e);
    }
}
Also used : Query(javax.persistence.Query) CertPolicyGroup(org.nhindirect.config.store.CertPolicyGroup) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with ConfigurationStoreException

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

the class TrustBundleDaoImpl method getTrustBundlesByDomain.

/**
	 * {@inheritDoc}
	 */
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<TrustBundleDomainReltn> getTrustBundlesByDomain(long domainId) 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");
    Collection<TrustBundleDomainReltn> retVal = null;
    try {
        final Query select = entityManager.createQuery("SELECT tbd from TrustBundleDomainReltn tbd where tbd.domain = ?1");
        select.setParameter(1, domain);
        retVal = (Collection<TrustBundleDomainReltn>) select.getResultList();
        if (retVal.size() == 0)
            return Collections.emptyList();
        for (TrustBundleDomainReltn reltn : retVal) {
            if (!reltn.getTrustBundle().getTrustBundleAnchors().isEmpty())
                for (TrustBundleAnchor anchor : reltn.getTrustBundle().getTrustBundleAnchors()) anchor.getData();
        }
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to execute trust bundle relation DAO query.", e);
    }
    return retVal;
}
Also used : Query(javax.persistence.Query) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Domain(org.nhindirect.config.store.Domain) TrustBundleAnchor(org.nhindirect.config.store.TrustBundleAnchor) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) TrustBundleDomainReltn(org.nhindirect.config.store.TrustBundleDomainReltn) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ConfigurationStoreException (org.nhindirect.config.store.ConfigurationStoreException)45 Transactional (org.springframework.transaction.annotation.Transactional)39 NoResultException (javax.persistence.NoResultException)32 Query (javax.persistence.Query)21 TrustBundle (org.nhindirect.config.store.TrustBundle)15 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)10 Domain (org.nhindirect.config.store.Domain)10 CertPolicy (org.nhindirect.config.store.CertPolicy)8 TrustBundleAnchor (org.nhindirect.config.store.TrustBundleAnchor)6 TrustBundleDomainReltn (org.nhindirect.config.store.TrustBundleDomainReltn)5 CertPolicyGroupDomainReltn (org.nhindirect.config.store.CertPolicyGroupDomainReltn)4 File (java.io.File)3 CertPolicyGroupReltn (org.nhindirect.config.store.CertPolicyGroupReltn)3 DNSRecord (org.nhindirect.config.store.DNSRecord)2 ApplicationContext (org.springframework.context.ApplicationContext)2 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 X509Certificate (java.security.cert.X509Certificate)1 RSAKey (java.security.interfaces.RSAKey)1