Search in sources :

Example 51 with ApplicationSettingsException

use of org.apache.airavata.common.exception.ApplicationSettingsException in project airavata by apache.

the class StorageResourceResource method remove.

@Override
public void remove(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_RESOURCE);
        generator.setParameter(StorageResourceConstants.RESOURCE_ID, identifier);
        Query q = generator.deleteQuery(em);
        q.executeUpdate();
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new AppCatalogException(e);
    } finally {
        if (em != null && em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) Query(javax.persistence.Query) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Example 52 with ApplicationSettingsException

use of org.apache.airavata.common.exception.ApplicationSettingsException in project airavata by apache.

the class StorageResourceResource method get.

@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_RESOURCE);
        generator.setParameter(StorageResourceConstants.RESOURCE_ID, identifier);
        Query q = generator.selectQuery(em);
        StorageResource storageResource = (StorageResource) q.getSingleResult();
        StorageResourceResource storageResourceResource = (StorageResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_RESOURCE, storageResource);
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return storageResourceResource;
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new AppCatalogException(e);
    } finally {
        if (em != null && em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    }
}
Also used : StorageResource(org.apache.airavata.registry.core.app.catalog.model.StorageResource) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) Query(javax.persistence.Query) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Example 53 with ApplicationSettingsException

use of org.apache.airavata.common.exception.ApplicationSettingsException in project airavata by apache.

the class StorageResourceResource method getAll.

@Override
public List<AppCatalogResource> getAll() throws AppCatalogException {
    List<AppCatalogResource> storageResourceResources = new ArrayList<AppCatalogResource>();
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_RESOURCE);
        Query q = generator.selectQuery(em);
        List<?> results = q.getResultList();
        for (Object result : results) {
            StorageResource storageResource = (StorageResource) result;
            StorageResourceResource storageResourceResource = (StorageResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_RESOURCE, storageResource);
            storageResourceResources.add(storageResourceResource);
        }
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new AppCatalogException(e);
    } finally {
        if (em != null && em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    }
    return storageResourceResources;
}
Also used : StorageResource(org.apache.airavata.registry.core.app.catalog.model.StorageResource) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Example 54 with ApplicationSettingsException

use of org.apache.airavata.common.exception.ApplicationSettingsException in project airavata by apache.

the class StorageResourceResource method get.

@Override
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
    List<AppCatalogResource> storageResourceResources = new ArrayList<AppCatalogResource>();
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(STORAGE_RESOURCE);
        Query q;
        if ((fieldName.equals(StorageResourceConstants.RESOURCE_DESCRIPTION)) || (fieldName.equals(StorageResourceConstants.RESOURCE_ID)) || (fieldName.equals(StorageResourceConstants.HOST_NAME))) {
            generator.setParameter(fieldName, value);
            q = generator.selectQuery(em);
            List<?> results = q.getResultList();
            for (Object result : results) {
                StorageResource storageResource = (StorageResource) result;
                StorageResourceResource storageResourceResource = (StorageResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_RESOURCE, storageResource);
                storageResourceResources.add(storageResourceResource);
            }
        } else {
            em.getTransaction().commit();
            if (em.isOpen()) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                em.close();
            }
            logger.error("Unsupported field name for Storage Resource Resource.", new IllegalArgumentException());
            throw new IllegalArgumentException("Unsupported field name for Storage Resource Resource.");
        }
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new AppCatalogException(e);
    } finally {
        if (em != null && em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    }
    return storageResourceResources;
}
Also used : StorageResource(org.apache.airavata.registry.core.app.catalog.model.StorageResource) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) Query(javax.persistence.Query) ArrayList(java.util.ArrayList) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Example 55 with ApplicationSettingsException

use of org.apache.airavata.common.exception.ApplicationSettingsException in project airavata by apache.

the class UnicoreDataMovementResource method get.

public AppCatalogResource get(Object identifier) throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
        generator.setParameter(UnicoreDataMovementConstants.DATAMOVEMENT_ID, identifier);
        Query q = generator.selectQuery(em);
        UnicoreDataMovement unicoreDataMovement = (UnicoreDataMovement) q.getSingleResult();
        UnicoreDataMovementResource dataMovementResource = (UnicoreDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_DATA_MOVEMENT, unicoreDataMovement);
        em.getTransaction().commit();
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return dataMovementResource;
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new AppCatalogException(e);
    } finally {
        if (em != null && em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    }
}
Also used : UnicoreDataMovement(org.apache.airavata.registry.core.app.catalog.model.UnicoreDataMovement) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) Query(javax.persistence.Query) AppCatalogQueryGenerator(org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)

Aggregations

ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)263 EntityManager (javax.persistence.EntityManager)193 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)172 Query (javax.persistence.Query)147 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)129 HashMap (java.util.HashMap)71 Map (java.util.Map)69 ArrayList (java.util.ArrayList)47 WorkflowCatalogException (org.apache.airavata.registry.cpi.WorkflowCatalogException)26 IOException (java.io.IOException)23 IamAdminServicesException (org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException)20 TException (org.apache.thrift.TException)19 WorkflowCatalogQueryGenerator (org.apache.airavata.registry.core.workflow.catalog.utils.WorkflowCatalogQueryGenerator)18 GFacException (org.apache.airavata.gfac.core.GFacException)11 PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)11 Keycloak (org.keycloak.admin.client.Keycloak)11 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)7 CompositeIdentifier (org.apache.airavata.registry.cpi.CompositeIdentifier)7 File (java.io.File)6 Connection (java.sql.Connection)6