use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class StorageResourceResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
StorageResource existingStorageResource = em.find(StorageResource.class, storageResourceId);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
StorageResource storageResource;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingStorageResource == null) {
storageResource = new StorageResource();
storageResource.setCreationTime(AiravataUtils.getCurrentTimestamp());
} else {
storageResource = existingStorageResource;
storageResource.setUpdateTime(AiravataUtils.getCurrentTimestamp());
}
storageResource.setDescription(getResourceDescription());
storageResource.setStorageResourceId(getStorageResourceId());
storageResource.setHostName(getHostName());
storageResource.setEnabled(isEnabled());
if (existingStorageResource == null) {
em.persist(storageResource);
} else {
em.merge(storageResource);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception 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 UnicoreDataMovementResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> unicoreDMResourceList = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
List results;
if (fieldName.equals(UnicoreDataMovementConstants.UNICORE_ENDPOINT_URL)) {
generator.setParameter(UnicoreDataMovementConstants.UNICORE_ENDPOINT_URL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
UnicoreDataMovement dataMovement = (UnicoreDataMovement) result;
UnicoreDataMovementResource unicoreJobSubmissionResource = (UnicoreDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_DATA_MOVEMENT, dataMovement);
unicoreDMResourceList.add(unicoreJobSubmissionResource);
}
}
} else if (fieldName.equals(UnicoreDataMovementConstants.SECURITY_PROTOCAL)) {
generator.setParameter(UnicoreDataMovementConstants.SECURITY_PROTOCAL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
UnicoreDataMovement dataMovement = (UnicoreDataMovement) result;
UnicoreDataMovementResource dataMovementResource = (UnicoreDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_DATA_MOVEMENT, dataMovement);
unicoreDMResourceList.add(dataMovementResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for Unicore data movement resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Unicore data movement resource.");
}
em.getTransaction().commit();
em.close();
} catch (Exception 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 unicoreDMResourceList;
}
use of org.apache.airavata.registry.cpi.AppCatalogException 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();
}
}
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class UnicoreJobSubmissionResource method getIds.
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> globusSubmissionResourceIDs = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
List results;
if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP)) {
generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for Globus Submission resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception 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 globusSubmissionResourceIDs;
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class UnicoreJobSubmissionResource method get.
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> unicoreSubmissionResourceList = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
List results;
if (fieldName.equals(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL)) {
generator.setParameter(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
UnicoreJobSubmissionResource unicoreJobSubmissionResource = (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
}
}
} else if (fieldName.equals(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL)) {
generator.setParameter(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
UnicoreJobSubmissionResource unicoreJobSubmissionResource = (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for Unicore submission resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Unicore Submission resource.");
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception 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 unicoreSubmissionResourceList;
}
Aggregations