use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class GwyResourceProfileImpl method getAllComputeResourcePreferences.
/**
* @param gatewayId
* @return
*/
@Override
public List<ComputeResourcePreference> getAllComputeResourcePreferences(String gatewayId) throws AppCatalogException {
try {
ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
return AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
} catch (Exception e) {
logger.error("Error while retrieving compute resource preference...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class GwyResourceProfileImpl method getComputeResourcePreference.
/**
* @param gatewayId
* @param hostId
* @return ComputeResourcePreference
*/
@Override
public ComputeResourcePreference getComputeResourcePreference(String gatewayId, String hostId) throws AppCatalogException {
try {
ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
for (AppCatalogResource resource : computePrefList) {
ComputeHostPreferenceResource cmP = (ComputeHostPreferenceResource) resource;
if (cmP.getResourceId() != null && !cmP.getResourceId().equals("")) {
if (cmP.getResourceId().equals(hostId)) {
return AppCatalogThriftConversion.getComputeResourcePreference(cmP);
}
}
}
} catch (Exception e) {
logger.error("Error while retrieving compute resource preference...", e);
throw new AppCatalogException(e);
}
return null;
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class GwyResourceProfileImpl method getAllStoragePreferences.
@Override
public List<StoragePreference> getAllStoragePreferences(String gatewayId) throws AppCatalogException {
try {
StoragePreferenceResource prefResource = new StoragePreferenceResource();
List<AppCatalogResource> dataStoragePrefList = prefResource.get(AppCatAbstractResource.StoragePreferenceConstants.GATEWAY_ID, gatewayId);
return AppCatalogThriftConversion.getDataStoragePreferences(dataStoragePrefList);
} catch (Exception e) {
logger.error("Error while retrieving data storage preference...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class AppEnvironmentResource method isExists.
@Override
public boolean isExists(Object identifier) throws AppCatalogException {
HashMap<String, String> ids;
if (identifier instanceof Map) {
ids = (HashMap) identifier;
} else {
logger.error("Identifier should be a map with the field name and it's value");
throw new AppCatalogException("Identifier should be a map with the field name and it's value");
}
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
AppEnvironment appEnvironment = em.find(AppEnvironment.class, new AppEnvironment_PK(ids.get(AppEnvironmentConstants.DEPLOYMENT_ID), ids.get(AppEnvironmentConstants.NAME)));
em.close();
return appEnvironment != null;
} 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();
}
}
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class AppEnvironmentResource method remove.
@Override
public void remove(Object identifier) throws AppCatalogException {
HashMap<String, String> ids;
if (identifier instanceof Map) {
ids = (HashMap) identifier;
} else {
logger.error("Identifier should be a map with the field name and it's value");
throw new AppCatalogException("Identifier should be a map with the field name and it's value");
}
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_ENVIRONMENT);
generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, ids.get(AppEnvironmentConstants.DEPLOYMENT_ID));
if (ids.get(AppEnvironmentConstants.NAME) != null) {
generator.setParameter(AppEnvironmentConstants.NAME, ids.get(AppEnvironmentConstants.NAME));
}
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();
}
}
}
Aggregations