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();
}
}
}
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();
}
}
}
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[] {};
}
}
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;
}
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);
}
}
Aggregations