Search in sources :

Example 41 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method disassociatePolicyGroupsFromDomain.

@Override
@Transactional(readOnly = false)
public void disassociatePolicyGroupsFromDomain(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");
    try {
        final Query delete = entityManager.createQuery("DELETE from CertPolicyGroupDomainReltn cpr where cpr.domain  = ?1");
        delete.setParameter(1, domain);
        delete.executeUpdate();
        entityManager.flush();
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to dissaccociate group policies from domain id ." + domainId, e);
    }
}
Also used : Query(javax.persistence.Query) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Domain(org.nhindirect.config.store.Domain) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 42 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method getPolicyGroupsByDomain.

@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<CertPolicyGroupDomainReltn> getPolicyGroupsByDomain(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<CertPolicyGroupDomainReltn> retVal = null;
    try {
        final Query select = entityManager.createQuery("SELECT cpr from CertPolicyGroupDomainReltn cpr where cpr.domain = ?1");
        select.setParameter(1, domain);
        retVal = (Collection<CertPolicyGroupDomainReltn>) select.getResultList();
        if (retVal.size() == 0)
            return Collections.emptyList();
        for (CertPolicyGroupDomainReltn reltn : retVal) {
            if (!reltn.getCertPolicyGroup().getCertPolicyGroupReltn().isEmpty())
                for (CertPolicyGroupReltn groupReltn : reltn.getCertPolicyGroup().getCertPolicyGroupReltn()) groupReltn.getCertPolicy().getPolicyData();
        }
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to execute policy group to domain relation DAO query.", e);
    }
    return retVal;
}
Also used : CertPolicyGroupReltn(org.nhindirect.config.store.CertPolicyGroupReltn) CertPolicyGroupDomainReltn(org.nhindirect.config.store.CertPolicyGroupDomainReltn) Query(javax.persistence.Query) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Domain(org.nhindirect.config.store.Domain) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 43 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method updatePolicyAttributes.

@Override
@Transactional(readOnly = false)
public void updatePolicyAttributes(long id, String policyName, PolicyLexicon lexicon, byte[] policyData) throws ConfigurationStoreException {
    validateState();
    try {
        final CertPolicy existingPolicy = this.getPolicyById(id);
        if (existingPolicy == null)
            throw new ConfigurationStoreException("Policy does not exist");
        if (policyData != null && policyData.length > 0)
            existingPolicy.setPolicyData(policyData);
        if (policyName != null && !policyName.isEmpty())
            existingPolicy.setPolicyName(policyName);
        if (lexicon != null)
            existingPolicy.setLexicon(lexicon);
        entityManager.persist(existingPolicy);
        entityManager.flush();
    } catch (ConfigurationStoreException cse) {
        throw cse;
    }///CLOVER:OFF
     catch (Exception e) {
        throw new ConfigurationStoreException("Failed to update certificate policy attributes.", e);
    }
///CLOVER:ON
}
Also used : 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 44 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method getPolicyGroupByName.

@Override
@Transactional(readOnly = true)
public CertPolicyGroup getPolicyGroupByName(String policyGroupName) throws ConfigurationStoreException {
    validateState();
    try {
        final Query select = entityManager.createQuery("SELECT cpg from CertPolicyGroup cpg WHERE UPPER(cpg.policyGroupName) = ?1");
        select.setParameter(1, policyGroupName.toUpperCase(Locale.getDefault()));
        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);
    }
}
Also used : Query(javax.persistence.Query) CertPolicyGroup(org.nhindirect.config.store.CertPolicyGroup) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 45 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method removePolicyUseFromGroup.

@Override
@Transactional(readOnly = false)
public void removePolicyUseFromGroup(long policyGroupReltnId) throws ConfigurationStoreException {
    validateState();
    try {
        final Query select = entityManager.createQuery("DELETE from CertPolicyGroupReltn cpr WHERE cpr.id = ?1");
        select.setParameter(1, policyGroupReltnId);
        select.executeUpdate();
        entityManager.flush();
    } catch (NoResultException e) {
        throw new ConfigurationStoreException("Policy group reltn with id " + policyGroupReltnId + " does not exist");
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to remove policy use from policy group.", e);
    }
}
Also used : Query(javax.persistence.Query) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) 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