Search in sources :

Example 31 with ApplicationSettingsException

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

the class NodeResource method isExists.

public boolean isExists(Object identifier) throws WorkflowCatalogException {
    HashMap<String, String> ids;
    if (identifier instanceof Map) {
        ids = (HashMap<String, String>) identifier;
    } else {
        logger.error("Identifier should be a map with the field name and it's value");
        throw new WorkflowCatalogException("Identifier should be a map with the field name and it's value");
    }
    EntityManager em = null;
    try {
        em = WorkflowCatalogJPAUtils.getEntityManager();
        Node port = em.find(Node.class, new Node_PK(ids.get(NodeConstants.TEMPLATE_ID), ids.get(NodeConstants.NODE_ID)));
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return port != null;
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new WorkflowCatalogException(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) WorkflowCatalogException(org.apache.airavata.registry.cpi.WorkflowCatalogException) EntityManager(javax.persistence.EntityManager) Node(org.apache.airavata.registry.core.workflow.catalog.model.Node) Node_PK(org.apache.airavata.registry.core.workflow.catalog.model.Node_PK) HashMap(java.util.HashMap) Map(java.util.Map)

Example 32 with ApplicationSettingsException

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

the class PortResource method isExists.

public boolean isExists(Object identifier) throws WorkflowCatalogException {
    HashMap<String, String> ids;
    if (identifier instanceof Map) {
        ids = (HashMap<String, String>) identifier;
    } else {
        logger.error("Identifier should be a map with the field name and it's value");
        throw new WorkflowCatalogException("Identifier should be a map with the field name and it's value");
    }
    EntityManager em = null;
    try {
        em = WorkflowCatalogJPAUtils.getEntityManager();
        Port port = em.find(Port.class, new Port_PK(ids.get(PortConstants.TEMPLATE_ID), ids.get(PortConstants.PORT_ID)));
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        return port != null;
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
        throw new WorkflowCatalogException(e);
    } finally {
        if (em != null && em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
    }
}
Also used : Port_PK(org.apache.airavata.registry.core.workflow.catalog.model.Port_PK) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) WorkflowCatalogException(org.apache.airavata.registry.cpi.WorkflowCatalogException) EntityManager(javax.persistence.EntityManager) Port(org.apache.airavata.registry.core.workflow.catalog.model.Port) HashMap(java.util.HashMap) Map(java.util.Map)

Example 33 with ApplicationSettingsException

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

the class ApplicationSettings method getExternalSettingsFileURLs.

protected URL[] getExternalSettingsFileURLs() {
    try {
        List<URL> externalSettingsFileURLs = new ArrayList<URL>();
        String externalSettingsFileNames = getSettingImpl(ADDITIONAL_SETTINGS_FILES);
        String[] externalSettingFiles = externalSettingsFileNames.split(",");
        for (String externalSettingFile : externalSettingFiles) {
            URL externalSettingFileURL = ApplicationSettings.loadFile(externalSettingFile);
            if (externalSettingFileURL == null) {
                logger.warn("Could not file external settings file " + externalSettingFile);
            } else {
                externalSettingsFileURLs.add(externalSettingFileURL);
            }
        }
        return externalSettingsFileURLs.toArray(new URL[] {});
    } catch (ApplicationSettingsException e) {
        return new URL[] {};
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) URL(java.net.URL)

Example 34 with ApplicationSettingsException

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

the class UNICORESecurityContext method getDefaultConfiguration.

public DefaultClientConfiguration getDefaultConfiguration(Boolean enableMessageLogging) throws GFacException, ApplicationSettingsException {
    try {
        X509Credential cred = getX509Credentials();
        secProperties = new DefaultClientConfiguration(dcValidator, cred);
        setExtraSettings();
    } catch (Exception e) {
        throw new GFacException(e.getMessage(), e);
    }
    if (enableMessageLogging)
        secProperties.setMessageLogging(true);
    return secProperties;
}
Also used : X509Credential(eu.emi.security.authn.x509.X509Credential) GFacException(org.apache.airavata.gfac.core.GFacException) DefaultClientConfiguration(eu.unicore.util.httpclient.DefaultClientConfiguration) GFacException(org.apache.airavata.gfac.core.GFacException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 35 with ApplicationSettingsException

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

the class X509SecurityContext method getDefaultCredentials.

/**
 * Gets the default proxy certificate.
 * @return Default my proxy credentials.
 * @throws org.apache.airavata.common.exception.ApplicationSettingsException
 */
public X509Credential getDefaultCredentials() throws GFacException, ApplicationSettingsException {
    MyProxyLogon logon = new MyProxyLogon();
    logon.setValidator(dcValidator);
    logon.setHost(getRequestData().getMyProxyServerUrl());
    logon.setPort(getRequestData().getMyProxyPort());
    logon.setUsername(getRequestData().getMyProxyUserName());
    logon.setPassphrase(getRequestData().getMyProxyPassword().toCharArray());
    logon.setLifetime(getRequestData().getMyProxyLifeTime());
    try {
        logon.connect();
        logon.logon();
        logon.getCredentials();
        logon.disconnect();
        PrivateKey pk = logon.getPrivateKey();
        return new KeyAndCertCredential(pk, new X509Certificate[] { logon.getCertificate() });
    } catch (Exception e) {
        throw new GFacException("An error occurred while retrieving default security credentials.", e);
    }
}
Also used : PrivateKey(java.security.PrivateKey) GFacException(org.apache.airavata.gfac.core.GFacException) KeyAndCertCredential(eu.emi.security.authn.x509.impl.KeyAndCertCredential) GFacException(org.apache.airavata.gfac.core.GFacException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

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