Search in sources :

Example 11 with ConfigurationStoreException

use of org.nhindirect.config.store.ConfigurationStoreException 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
}
Also used : TrustBundle(org.nhindirect.config.store.TrustBundle) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) NoResultException(javax.persistence.NoResultException) ConfigurationStoreException(org.nhindirect.config.store.ConfigurationStoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method removePolicyUseFromGroups.

/**
	 * {@inheritDoc}
	 */
@Transactional(readOnly = false)
public void removePolicyUseFromGroups(long policyId) throws ConfigurationStoreException {
    validateState();
    // make sure the trust bundle exists
    final CertPolicy policy = this.getPolicyById(policyId);
    if (policy == null)
        throw new ConfigurationStoreException("Certificate policy with id " + policyId + " does not exist");
    try {
        final Query delete = entityManager.createQuery("DELETE from CertPolicyGroupReltn cpr where cpr.certPolicy  = ?1");
        delete.setParameter(1, policy);
        delete.executeUpdate();
        entityManager.flush();
    } catch (Exception e) {
        throw new ConfigurationStoreException("Failed to remove policy id " + policyId + " from all groups", 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 13 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method getPolicyGroupById.

@Override
@Transactional(readOnly = true)
public CertPolicyGroup getPolicyGroupById(long id) throws ConfigurationStoreException {
    validateState();
    try {
        final Query select = entityManager.createQuery("SELECT cpg from CertPolicyGroup cpg WHERE cpg.id = ?1");
        select.setParameter(1, id);
        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 14 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method updateGroupAttributes.

@Override
@Transactional(readOnly = false)
public void updateGroupAttributes(long id, String groupName) throws ConfigurationStoreException {
    validateState();
    try {
        final CertPolicyGroup existingPolicyGroup = this.getPolicyGroupById(id);
        if (existingPolicyGroup == null)
            throw new ConfigurationStoreException("Policy group does not exist");
        if (groupName != null && !groupName.isEmpty())
            existingPolicyGroup.setPolicyGroupName(groupName);
        entityManager.persist(existingPolicyGroup);
        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 : 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 15 with ConfigurationStoreException

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

the class CertPolicyDaoImpl method deletePolicyGroups.

@Override
@Transactional(readOnly = false)
public void deletePolicyGroups(long[] groupIds) throws ConfigurationStoreException {
    validateState();
    if (groupIds == null || groupIds.length == 0)
        return;
    for (long id : groupIds) {
        try {
            final CertPolicyGroup bundle = this.getPolicyGroupById(id);
            entityManager.remove(bundle);
            entityManager.flush();
        } catch (ConfigurationStoreException e) {
            log.warn(e.getMessage(), e);
        }
    }
}
Also used : CertPolicyGroup(org.nhindirect.config.store.CertPolicyGroup) 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