You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2016/01/19 18:32:24 UTC
[1/3] airavata git commit: fixing concurrent access issue at registry
level
Repository: airavata
Updated Branches:
refs/heads/develop 0c51c7aa1 -> f1e16793b
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
index 5e42bba..1234c17 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
@@ -64,7 +64,12 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -98,7 +103,12 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
ModuleLoadCmd moduleLoadCmd = (ModuleLoadCmd) q.getSingleResult();
ModuleLoadCmdResource moduleLoadCmdResource = (ModuleLoadCmdResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return moduleLoadCmdResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -135,12 +145,22 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
(o1, o2) -> ((ModuleLoadCmdResource)o1).getOrder()- ((ModuleLoadCmdResource)o2).getOrder());
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Module Load Cmd Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Module Load Cmd Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -185,12 +205,22 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Module Load Cmd Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Module Load Cmd Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,7 +241,13 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ModuleLoadCmd existingModuleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(cmd, appDeploymentId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
ModuleLoadCmd moduleLoadCmd;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -231,7 +267,12 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
em.merge(moduleLoadCmd);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -258,7 +299,12 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ModuleLoadCmd moduleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(ids.get(ModuleLoadCmdConstants.CMD), ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return moduleLoadCmd != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
index 24c3bbc..b62b24d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
@@ -66,7 +66,12 @@ public class PostJobCommandResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -103,7 +108,12 @@ public class PostJobCommandResource extends AppCatAbstractResource {
(PostJobCommandResource) AppCatalogJPAUtils.getResource(
AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return postJobCommandResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -144,12 +154,22 @@ public class PostJobCommandResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Post Job Command Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Post Job Command Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -205,12 +225,22 @@ public class PostJobCommandResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for GSISSH Post Job resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Post JOb Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -231,7 +261,12 @@ public class PostJobCommandResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
PostJobCommand existingPostJobCommand = em.find(PostJobCommand.class,
new PostJobCommandPK(appDeploymentId, command));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -251,7 +286,12 @@ public class PostJobCommandResource extends AppCatAbstractResource {
em.persist(postJobCommand);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -281,7 +321,12 @@ public class PostJobCommandResource extends AppCatAbstractResource {
ids.get(PostJobCommandConstants.DEPLOYMENT_ID),
ids.get(PostJobCommandConstants.COMMAND)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return postJobCommand != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
index 2f7facd..f16900d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
@@ -66,7 +66,12 @@ public class PreJobCommandResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -103,7 +108,12 @@ public class PreJobCommandResource extends AppCatAbstractResource {
(PreJobCommandResource) AppCatalogJPAUtils.getResource(
AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return preJobCommandResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -144,12 +154,22 @@ public class PreJobCommandResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Pre Job Command Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Pre Job Command Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -205,12 +225,22 @@ public class PreJobCommandResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for GSISSH Pre Job resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Pre JOb Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -231,7 +261,12 @@ public class PreJobCommandResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
PreJobCommand existingPreJobCommand = em.find(PreJobCommand.class,
new PreJobCommandPK(appDeploymentId, command));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -251,7 +286,12 @@ public class PreJobCommandResource extends AppCatAbstractResource {
em.persist(preJobCommand);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -281,7 +321,12 @@ public class PreJobCommandResource extends AppCatAbstractResource {
ids.get(PreJobCommandConstants.DEPLOYMENT_ID),
ids.get(PreJobCommandConstants.COMMAND)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return preJobCommand != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java
index e84506c..3406b83 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java
@@ -74,7 +74,12 @@ public class ResourceJobManagerResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -100,7 +105,12 @@ public class ResourceJobManagerResource extends AppCatAbstractResource {
ResourceJobManager resourceJobManager = (ResourceJobManager) q.getSingleResult();
ResourceJobManagerResource resourceJobManagerResource = (ResourceJobManagerResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return resourceJobManagerResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -135,12 +145,22 @@ public class ResourceJobManagerResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Resource Job Manager Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Resource Job Manager Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -185,12 +205,22 @@ public class ResourceJobManagerResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Resource Job Manager Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Resource Job Manager Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,7 +241,13 @@ public class ResourceJobManagerResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ResourceJobManager existingResourceJobManager = em.find(ResourceJobManager.class, resourceJobManagerId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
ResourceJobManager resourceJobManager;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -232,7 +268,12 @@ public class ResourceJobManagerResource extends AppCatAbstractResource {
em.merge(resourceJobManager);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -252,7 +293,12 @@ public class ResourceJobManagerResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return resourceJobManager != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java
index 3b4c63d..2d6b8f7 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java
@@ -72,7 +72,12 @@ public class ScpDataMovementResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -98,7 +103,12 @@ public class ScpDataMovementResource extends AppCatAbstractResource {
ScpDataMovement scpDataMovement = (ScpDataMovement) q.getSingleResult();
ScpDataMovementResource scpDataMovementResource = (ScpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return scpDataMovementResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -133,12 +143,22 @@ public class ScpDataMovementResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Scp Data Movement Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Scp Data Movement Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -183,12 +203,22 @@ public class ScpDataMovementResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Scp Data Movement Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Scp Data Movement Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -209,7 +239,12 @@ public class ScpDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ScpDataMovement existingScpDataMovement = em.find(ScpDataMovement.class, dataMovementInterfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
ScpDataMovement scpDataMovement;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -231,7 +266,12 @@ public class ScpDataMovementResource extends AppCatAbstractResource {
em.merge(scpDataMovement);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -251,7 +291,12 @@ public class ScpDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ScpDataMovement scpDataMovement = em.find(ScpDataMovement.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return scpDataMovement != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java
index 2390f68..4a06dee 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java
@@ -76,7 +76,12 @@ public class SshJobSubmissionResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -102,7 +107,12 @@ public class SshJobSubmissionResource extends AppCatAbstractResource {
SshJobSubmission sshJobSubmission = (SshJobSubmission) q.getSingleResult();
SshJobSubmissionResource sshJobSubmissionResource = (SshJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_JOB_SUBMISSION, sshJobSubmission);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return sshJobSubmissionResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -137,12 +147,22 @@ public class SshJobSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Ssh Job Submission Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Ssh Job Submission Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -187,12 +207,22 @@ public class SshJobSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Ssh Job Submission Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Ssh Job Submission Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -213,7 +243,12 @@ public class SshJobSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
SshJobSubmission existingSshJobSubmission = em.find(SshJobSubmission.class, jobSubmissionInterfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
SshJobSubmission sshJobSubmission;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -238,7 +273,12 @@ public class SshJobSubmissionResource extends AppCatAbstractResource {
em.merge(sshJobSubmission);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -258,7 +298,12 @@ public class SshJobSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
SshJobSubmission sshJobSubmission = em.find(SshJobSubmission.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return sshJobSubmission != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java
index 7e99c46..ef150ad 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageInterfaceResource.java
@@ -92,7 +92,12 @@ public class StorageInterfaceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -126,7 +131,12 @@ public class StorageInterfaceResource extends AppCatAbstractResource {
StorageInterface storageInterface = (StorageInterface) q.getSingleResult();
StorageInterfaceResource storageInterfaceResource = (StorageInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_INTERFACE, storageInterface);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return storageInterfaceResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -161,12 +171,22 @@ public class StorageInterfaceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Data Movement Interface Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,12 +231,22 @@ public class StorageInterfaceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Storage Interface Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Storage Interface Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -237,7 +267,12 @@ public class StorageInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
StorageInterface existingStorageInterface = em.find(StorageInterface.class, new StorageInterface_PK(storageResourceId, dataMovementInterfaceId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
StorageInterface storageInterface;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -260,7 +295,12 @@ public class StorageInterfaceResource extends AppCatAbstractResource {
em.merge(storageInterface);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -287,7 +327,12 @@ public class StorageInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
StorageInterface storageInterface = em.find(StorageInterface.class, new StorageInterface_PK(ids.get(StorageInterfaceConstants.STORAGE_RESOURCE_ID), ids.get(StorageInterfaceConstants.DATA_MOVEMENT_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return storageInterface != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java
index ae32eca..a2c3f51 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StoragePreferenceResource.java
@@ -116,7 +116,12 @@ public class StoragePreferenceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -152,7 +157,12 @@ public class StoragePreferenceResource extends AppCatAbstractResource {
StoragePreferenceResource preferenceResource =
(StoragePreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_PREFERENCE, preference);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return preferenceResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -209,12 +219,22 @@ public class StoragePreferenceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for data storage preference Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for data storage preference Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -251,7 +271,12 @@ public class StoragePreferenceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
StoragePreference existingPreference = em.find(StoragePreference.class, new StoragePreferencePK(gatewayId, storageResourceId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -275,7 +300,12 @@ public class StoragePreferenceResource extends AppCatAbstractResource {
em.persist(resourcePreference);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -305,7 +335,12 @@ public class StoragePreferenceResource extends AppCatAbstractResource {
StoragePreference existingPreference = em.find(StoragePreference.class,
new StoragePreferencePK(ids.get(StoragePreferenceConstants.GATEWAY_ID),
ids.get(StoragePreferenceConstants.STORAGE_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return existingPreference != null;
}catch (Exception e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java
index 1d7039a..e7162ea 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/StorageResourceResource.java
@@ -80,7 +80,12 @@ public class StorageResourceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -106,7 +111,12 @@ public class StorageResourceResource extends AppCatAbstractResource {
StorageResource storageResource = (StorageResource) q.getSingleResult();
StorageResourceResource storageResourceResource = (StorageResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.STORAGE_RESOURCE, storageResource);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return storageResourceResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -141,12 +151,22 @@ public class StorageResourceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ 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();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -177,7 +197,12 @@ public class StorageResourceResource extends AppCatAbstractResource {
storageResourceResources.add(storageResourceResource);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -207,7 +232,12 @@ public class StorageResourceResource extends AppCatAbstractResource {
storageResourceResources.add(storageResource.getStorageResourceId());
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -242,12 +272,22 @@ public class StorageResourceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ 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();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -268,7 +308,12 @@ public class StorageResourceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
StorageResource existingStorageResource = em.find(StorageResource.class, storageResourceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
StorageResource storageResource;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -289,7 +334,12 @@ public class StorageResourceResource extends AppCatAbstractResource {
em.merge(storageResource);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -309,7 +359,12 @@ public class StorageResourceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
StorageResource storageResource = em.find(StorageResource.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return storageResource != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java
index db5ccde..782f9b9 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java
@@ -53,7 +53,12 @@ public class UnicoreDataMovementResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -81,7 +86,12 @@ public class UnicoreDataMovementResource extends AppCatAbstractResource {
.getResource(AppCatalogResourceType.UNICORE_DATA_MOVEMENT,
unicoreDataMovement);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return dataMovementResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -134,7 +144,12 @@ public class UnicoreDataMovementResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ 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.");
}
@@ -175,7 +190,12 @@ public class UnicoreDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
UnicoreDataMovement existingDataMovement = em.find(UnicoreDataMovement.class, dataMovementId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -192,7 +212,12 @@ public class UnicoreDataMovementResource extends AppCatAbstractResource {
em.persist(unicoreJobSubmission);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,7 +236,12 @@ public class UnicoreDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
UnicoreDataMovement dataMovement = em.find(UnicoreDataMovement.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return dataMovement != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java
index f5b9760..995a7a1 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java
@@ -56,7 +56,12 @@ public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -85,7 +90,12 @@ public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
.getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION,
unicoreJobSubmission);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return unicoreSubmissionResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -139,12 +149,22 @@ public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
}
else {
em.getTransaction().commit();
- em.close();
+ 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();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -223,12 +243,22 @@ public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ 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();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -248,7 +278,12 @@ public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
UnicoreJobSubmission existingUnicoreSubmission = em.find(UnicoreJobSubmission.class, jobSubmissionInterfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -266,7 +301,12 @@ public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
em.persist(unicoreJobSubmission);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -285,7 +325,12 @@ public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
UnicoreJobSubmission unicoreJobSubmission = em.find(UnicoreJobSubmission.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return unicoreJobSubmission != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java
index 913d996..94eb02b 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java
@@ -75,7 +75,12 @@ public class WorkflowInputResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -111,7 +116,12 @@ public class WorkflowInputResource extends AppCatAbstractResource {
(WorkflowInputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_INPUT
, workflowInput);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return workflowInputResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -176,12 +186,22 @@ public class WorkflowInputResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for WFInput Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for WFInput Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -245,12 +265,22 @@ public class WorkflowInputResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for WFInput resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for WFInput Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -270,7 +300,12 @@ public class WorkflowInputResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
WorkflowInput existingWFInput = em.find(WorkflowInput.class, new WorkflowInput_PK(wfTemplateId, inputKey));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
WorkflowInput workflowInput;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -300,7 +335,12 @@ public class WorkflowInputResource extends AppCatAbstractResource {
em.merge(workflowInput);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -330,7 +370,12 @@ public class WorkflowInputResource extends AppCatAbstractResource {
ids.get(WFInputConstants.WF_TEMPLATE_ID),
ids.get(WFInputConstants.INPUT_KEY)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return workflowInput != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java
index e4d7b5c..f216731 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java
@@ -69,7 +69,12 @@ public class WorkflowOutputResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -105,7 +110,12 @@ public class WorkflowOutputResource extends AppCatAbstractResource {
(WorkflowOutputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_OUTPUT
, wfOutput);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return workflowOutputResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -170,12 +180,22 @@ public class WorkflowOutputResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for WF Output Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for WF Output Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -240,12 +260,22 @@ public class WorkflowOutputResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for WF Output resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for WF Output Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -266,7 +296,12 @@ public class WorkflowOutputResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
WorkflowOutput existingWorkflowOutput = em.find(WorkflowOutput.class,
new WorkflowOutput_PK(wfTemplateId, outputKey));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -299,7 +334,12 @@ public class WorkflowOutputResource extends AppCatAbstractResource {
em.persist(workflowOutput);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -329,7 +369,12 @@ public class WorkflowOutputResource extends AppCatAbstractResource {
ids.get(WFOutputConstants.WF_TEMPLATE_ID),
ids.get(WFOutputConstants.OUTPUT_KEY)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return workflowOutput != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
index 4c79ed1..8c03213 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
@@ -91,7 +91,12 @@ public class WorkflowResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -117,7 +122,12 @@ public class WorkflowResource extends AppCatAbstractResource {
Workflow workflow = (Workflow) q.getSingleResult();
WorkflowResource workflowResource = (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return workflowResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -152,12 +162,22 @@ public class WorkflowResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -192,7 +212,12 @@ public class WorkflowResource extends AppCatAbstractResource {
}
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -225,7 +250,12 @@ public class WorkflowResource extends AppCatAbstractResource {
}
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -260,12 +290,22 @@ public class WorkflowResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -286,7 +326,12 @@ public class WorkflowResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
Workflow existingWorkflow = em.find(Workflow.class, wfTemplateId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
Workflow workflow;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -313,7 +358,12 @@ public class WorkflowResource extends AppCatAbstractResource {
em.merge(workflow);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -333,7 +383,12 @@ public class WorkflowResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
Workflow workflow = em.find(Workflow.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return workflow != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
[3/3] airavata git commit: fixing concurrent access issue at registry
level
Posted by ch...@apache.org.
fixing concurrent access issue at registry level
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/f1e16793
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/f1e16793
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/f1e16793
Branch: refs/heads/develop
Commit: f1e16793be29e68f4fca64c8ada84e0a0fe6a9b6
Parents: 0c51c7a
Author: Chathuri Wimalasena <ch...@apache.org>
Authored: Tue Jan 19 12:33:25 2016 -0500
Committer: Chathuri Wimalasena <ch...@apache.org>
Committed: Tue Jan 19 12:33:25 2016 -0500
----------------------------------------------------------------------
.../resources/AppDeploymentResource.java | 70 +++++++++++++++---
.../resources/AppEnvironmentResource.java | 35 +++++++--
.../catalog/resources/AppInterfaceResource.java | 77 ++++++++++++++++---
...ppModuleMappingAppCatalogResourceAppCat.java | 56 ++++++++++++--
.../catalog/resources/AppModuleResource.java | 70 +++++++++++++++---
.../resources/ApplicationInputResource.java | 63 +++++++++++++---
.../resources/ApplicationOutputResource.java | 56 ++++++++++++--
.../catalog/resources/BatchQueueResource.java | 63 +++++++++++++---
.../resources/CloudSubmissionResource.java | 64 +++++++++++++---
.../ComputeHostPreferenceResource.java | 49 ++++++++++--
.../ComputeResourceFileSystemResource.java | 63 +++++++++++++---
.../resources/ComputeResourceResource.java | 77 ++++++++++++++++---
.../DataMovementInterfaceResource.java | 56 ++++++++++++--
.../catalog/resources/GSISSHExportResource.java | 63 +++++++++++++---
.../resources/GSISSHSubmissionResource.java | 63 +++++++++++++---
.../GatewayClientCredentialResource.java | 78 +++++++++++++++++---
.../resources/GatewayProfileResource.java | 70 +++++++++++++++---
.../resources/GlobusGKEndpointResource.java | 63 +++++++++++++---
.../resources/GlobusJobSubmissionResource.java | 56 ++++++++++++--
.../resources/GridftpDataMovementResource.java | 65 +++++++++++++---
.../resources/GridftpEndpointResource.java | 64 +++++++++++++---
.../catalog/resources/HostAliasAppResource.java | 63 +++++++++++++---
.../resources/HostIPAddressResource.java | 63 +++++++++++++---
.../resources/JobManagerCommandResource.java | 64 +++++++++++++---
.../JobSubmissionInterfaceResource.java | 63 +++++++++++++---
.../resources/LibraryApendPathResource.java | 49 ++++++++++--
.../resources/LibraryPrepandPathResource.java | 49 ++++++++++--
.../resources/LocalDataMovementResource.java | 64 +++++++++++++---
.../resources/LocalSubmissionResource.java | 63 +++++++++++++---
.../resources/ModuleLoadCmdResource.java | 64 +++++++++++++---
.../resources/PostJobCommandResource.java | 63 +++++++++++++---
.../resources/PreJobCommandResource.java | 63 +++++++++++++---
.../resources/ResourceJobManagerResource.java | 64 +++++++++++++---
.../resources/ScpDataMovementResource.java | 63 +++++++++++++---
.../resources/SshJobSubmissionResource.java | 63 +++++++++++++---
.../resources/StorageInterfaceResource.java | 63 +++++++++++++---
.../resources/StoragePreferenceResource.java | 49 ++++++++++--
.../resources/StorageResourceResource.java | 77 ++++++++++++++++---
.../resources/UnicoreDataMovementResource.java | 42 +++++++++--
.../resources/UnicoreJobSubmissionResource.java | 63 +++++++++++++---
.../resources/WorkflowInputResource.java | 63 +++++++++++++---
.../resources/WorkflowOutputResource.java | 63 +++++++++++++---
.../app/catalog/resources/WorkflowResource.java | 77 ++++++++++++++++---
43 files changed, 2295 insertions(+), 381 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java
index e1ab857..2d563e3 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java
@@ -144,7 +144,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -171,7 +176,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
AppDeploymentResource deploymentResource =
(AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return deploymentResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -222,12 +232,22 @@ public class AppDeploymentResource extends AppCatAbstractResource {
}
}else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for app deployment resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app deployment resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -262,7 +282,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
}
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -294,7 +319,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
}
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -341,7 +371,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
}
}else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for app deployment resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app deployment resource.");
}
@@ -367,7 +402,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationDeployment existingDeployment = em.find(ApplicationDeployment.class, deploymentId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -400,7 +440,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
em.persist(deployment);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -421,7 +466,12 @@ public class AppDeploymentResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationDeployment deployment = em.find(ApplicationDeployment.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return deployment != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
index 46d16dc..263f9f0 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
@@ -106,7 +106,12 @@ public class AppEnvironmentResource extends AppCatAbstractResource{
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -141,7 +146,12 @@ public class AppEnvironmentResource extends AppCatAbstractResource{
AppEnvironmentResource resource =
(AppEnvironmentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT, appEnvironment);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return resource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -197,7 +207,12 @@ public class AppEnvironmentResource extends AppCatAbstractResource{
throw new IllegalArgumentException("Unsupported field name for App Environment resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -234,7 +249,12 @@ public class AppEnvironmentResource extends AppCatAbstractResource{
try {
em = AppCatalogJPAUtils.getEntityManager();
AppEnvironment existigAppEnv = em.find(AppEnvironment.class, new AppEnvironment_PK(deploymentId, name));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -255,7 +275,12 @@ public class AppEnvironmentResource extends AppCatAbstractResource{
em.persist(appEnvironment);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java
index ec15ed1..967ebf4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java
@@ -105,7 +105,12 @@ public class AppInterfaceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -132,7 +137,12 @@ public class AppInterfaceResource extends AppCatAbstractResource {
AppInterfaceResource resource =
(AppInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INTERFACE, applicationInterface);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return resource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -171,12 +181,22 @@ public class AppInterfaceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for application interface.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for application interface.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,7 +231,12 @@ public class AppInterfaceResource extends AppCatAbstractResource {
}
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -243,7 +268,12 @@ public class AppInterfaceResource extends AppCatAbstractResource {
}
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -280,12 +310,22 @@ public class AppInterfaceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for application interface.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for application interface.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -306,7 +346,12 @@ public class AppInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationInterface existigAppInterface = em.find(ApplicationInterface.class, interfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -326,7 +371,12 @@ public class AppInterfaceResource extends AppCatAbstractResource {
em.persist(applicationInterface);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -346,7 +396,12 @@ public class AppInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationInterface existigAppInterface = em.find(ApplicationInterface.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return existigAppInterface != null;
}catch (Exception e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
index 49cdd8b..845e5b7 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
@@ -101,7 +101,12 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -124,7 +129,12 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -159,7 +169,12 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
AppModuleMappingAppCatalogResourceAppCat resource =
(AppModuleMappingAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_MODULE_MAPPING, result);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return resource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -210,12 +225,22 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
}
}else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for app module mapping resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app module mapping resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -252,7 +277,12 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
try {
em = AppCatalogJPAUtils.getEntityManager();
AppModuleMapping existngModuleMap = em.find(AppModuleMapping.class, new AppModuleMapping_PK(interfaceId, moduleId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -271,7 +301,12 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
em.persist(appModuleMapping);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -300,7 +335,12 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
AppModuleMapping moduleMapping = em.find(AppModuleMapping.class,
new AppModuleMapping_PK(ids.get(AppModuleMappingConstants.INTERFACE_ID),
ids.get(AppModuleMappingConstants.MODULE_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return moduleMapping != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
index ea1400e..2e8d839 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
@@ -114,7 +114,12 @@ public class AppModuleResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -141,7 +146,12 @@ public class AppModuleResource extends AppCatAbstractResource {
AppModuleResource appModuleResource =
(AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return appModuleResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -180,12 +190,22 @@ public class AppModuleResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app module resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -217,7 +237,12 @@ public class AppModuleResource extends AppCatAbstractResource {
appModuleResources.add(appModuleResource);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -259,12 +284,22 @@ public class AppModuleResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app module resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -285,7 +320,12 @@ public class AppModuleResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationModule existingModule = em.find(ApplicationModule.class, moduleId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -307,7 +347,12 @@ public class AppModuleResource extends AppCatAbstractResource {
em.persist(applicationModule);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -327,7 +372,12 @@ public class AppModuleResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationModule applicationModule = em.find(ApplicationModule.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return applicationModule != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java
index 0244066..b04e55a 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java
@@ -77,7 +77,12 @@ public class ApplicationInputResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -113,7 +118,12 @@ public class ApplicationInputResource extends AppCatAbstractResource {
(ApplicationInputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INPUT
, applicationInput);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return applicationInputResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -178,12 +188,22 @@ public class ApplicationInputResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for AppInput Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -249,12 +269,22 @@ public class ApplicationInputResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for AppInput resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -274,7 +304,12 @@ public class ApplicationInputResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationIntInput existingApplicationInput = em.find(ApplicationIntInput.class, new AppInput_PK(interfaceID, inputKey));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
ApplicationIntInput applicationInput;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -303,7 +338,12 @@ public class ApplicationInputResource extends AppCatAbstractResource {
em.merge(applicationInput);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -333,7 +373,12 @@ public class ApplicationInputResource extends AppCatAbstractResource {
ids.get(AppInputConstants.INTERFACE_ID),
ids.get(AppInputConstants.INPUT_KEY)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return applicationInput != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java
index 2ddabcd..b9a32e1 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java
@@ -75,7 +75,12 @@ public class ApplicationOutputResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -112,7 +117,12 @@ public class ApplicationOutputResource extends AppCatAbstractResource {
(ApplicationOutputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_OUTPUT
, applicationOutput);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return applicationOutputResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -177,12 +187,22 @@ public class ApplicationOutputResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for App Output Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for App Output Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -254,7 +274,12 @@ public class ApplicationOutputResource extends AppCatAbstractResource {
throw new IllegalArgumentException("Unsupported field name for App Output Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -275,7 +300,12 @@ public class ApplicationOutputResource extends AppCatAbstractResource {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationIntOutput existingApplicationOutput = em.find(ApplicationIntOutput.class,
new AppOutput_PK(interfaceID, outputKey));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
ApplicationIntOutput applicationOutput;
em = AppCatalogJPAUtils.getEntityManager();
@@ -300,7 +330,12 @@ public class ApplicationOutputResource extends AppCatAbstractResource {
applicationOutput.setOutputStreaming(outputStreaming);
em.merge(applicationOutput);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -330,7 +365,12 @@ public class ApplicationOutputResource extends AppCatAbstractResource {
ids.get(AppOutputConstants.INTERFACE_ID),
ids.get(AppOutputConstants.OUTPUT_KEY)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return applicationOutput != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java
index 56e088c..4fc8a49 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java
@@ -71,7 +71,12 @@ public class BatchQueueResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -105,7 +110,12 @@ public class BatchQueueResource extends AppCatAbstractResource {
BatchQueue batchQueue = (BatchQueue) q.getSingleResult();
BatchQueueResource batchQueueResource = (BatchQueueResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.BATCH_QUEUE, batchQueue);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return batchQueueResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -140,12 +150,22 @@ public class BatchQueueResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Batch Queue Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Batch Queue Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -190,12 +210,22 @@ public class BatchQueueResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Batch Queue Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Batch Queue Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -216,7 +246,12 @@ public class BatchQueueResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
BatchQueue existingBatchQueue = em.find(BatchQueue.class, new BatchQueue_PK(computeResourceId, queueName));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
BatchQueue batchQueue;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -241,7 +276,12 @@ public class BatchQueueResource extends AppCatAbstractResource {
em.merge(batchQueue);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -268,7 +308,12 @@ public class BatchQueueResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
BatchQueue batchQueue = em.find(BatchQueue.class, new BatchQueue_PK(ids.get(BatchQueueConstants.COMPUTE_RESOURCE_ID), ids.get(BatchQueueConstants.QUEUE_NAME)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return batchQueue != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java
index d899a66..870e244 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java
@@ -54,7 +54,12 @@ public class CloudSubmissionResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -80,7 +85,12 @@ public class CloudSubmissionResource extends AppCatAbstractResource {
CloudJobSubmission cloudJobSubmission = (CloudJobSubmission) q.getSingleResult();
CloudSubmissionResource localSubmissionResource = (CloudSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.ClOUD_SUBMISSION, cloudJobSubmission);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return localSubmissionResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -115,12 +125,22 @@ public class CloudSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -165,12 +185,22 @@ public class CloudSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -191,7 +221,13 @@ public class CloudSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
CloudJobSubmission existingLocalSubmission = em.find(CloudJobSubmission.class, jobSubmissionInterfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
CloudJobSubmission cloudJobSubmission;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -213,7 +249,12 @@ public class CloudSubmissionResource extends AppCatAbstractResource {
em.merge(cloudJobSubmission);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -233,7 +274,12 @@ public class CloudSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
CloudJobSubmission localSubmission = em.find(CloudJobSubmission.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return localSubmission != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
index 0528843..6fb9555 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
@@ -173,7 +173,12 @@ public class ComputeHostPreferenceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -209,7 +214,12 @@ public class ComputeHostPreferenceResource extends AppCatAbstractResource {
ComputeHostPreferenceResource preferenceResource =
(ComputeHostPreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE, preference);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return preferenceResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -298,12 +308,22 @@ public class ComputeHostPreferenceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Compute host preference Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Compute host preference Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -340,7 +360,12 @@ public class ComputeHostPreferenceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class, new ComputeResourcePreferencePK(gatewayId, resourceId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -377,7 +402,12 @@ public class ComputeHostPreferenceResource extends AppCatAbstractResource {
em.persist(resourcePreference);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -407,7 +437,12 @@ public class ComputeHostPreferenceResource extends AppCatAbstractResource {
ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class,
new ComputeResourcePreferencePK(ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID),
ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return existingPreference != null;
}catch (Exception e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java
index 7eb3232..dac48b1 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java
@@ -66,7 +66,12 @@ public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -100,7 +105,12 @@ public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
ComputeResourceFileSystem computeResourceFileSystem = (ComputeResourceFileSystem) q.getSingleResult();
ComputeResourceFileSystemResource computeResourceFileSystemResource = (ComputeResourceFileSystemResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_FILE_SYSTEM, computeResourceFileSystem);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return computeResourceFileSystemResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -135,12 +145,22 @@ public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Compute Resource File System Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Compute Resource File System Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -185,12 +205,22 @@ public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Compute Resource File System Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Compute Resource File System Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,7 +241,12 @@ public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ComputeResourceFileSystem existingComputeResourceFileSystem = em.find(ComputeResourceFileSystem.class, new ComputeResourceFileSystem_PK(computeResourceId, fileSystem));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
ComputeResourceFileSystem computeResourceFileSystem;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -231,7 +266,12 @@ public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
em.merge(computeResourceFileSystem);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -258,7 +298,12 @@ public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ComputeResourceFileSystem computeResourceFileSystem = em.find(ComputeResourceFileSystem.class, new ComputeResourceFileSystem_PK(ids.get(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID), ids.get(ComputeResourceFileSystemConstants.FILE_SYSTEM)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return computeResourceFileSystem != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java
index e10baba..09fcdec 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java
@@ -89,7 +89,12 @@ public class ComputeResourceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -115,7 +120,12 @@ public class ComputeResourceResource extends AppCatAbstractResource {
ComputeResource computeResource = (ComputeResource) q.getSingleResult();
ComputeResourceResource computeResourceResource = (ComputeResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return computeResourceResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -150,12 +160,22 @@ public class ComputeResourceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Compute Resource Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Compute Resource Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -186,7 +206,12 @@ public class ComputeResourceResource extends AppCatAbstractResource {
computeResourceResources.add(computeResourceResource);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -216,7 +241,12 @@ public class ComputeResourceResource extends AppCatAbstractResource {
computeResourceResources.add(computeResource.getResourceId());
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -251,12 +281,22 @@ public class ComputeResourceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Compute Resource Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Compute Resource Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -277,7 +317,12 @@ public class ComputeResourceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ComputeResource existingComputeResource = em.find(ComputeResource.class, resourceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
ComputeResource computeResource;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -299,7 +344,12 @@ public class ComputeResourceResource extends AppCatAbstractResource {
em.merge(computeResource);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -319,7 +369,12 @@ public class ComputeResourceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
ComputeResource computeResource = em.find(ComputeResource.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return computeResource != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java
index 9ebac56..618ad03 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java
@@ -87,7 +87,12 @@ public class DataMovementInterfaceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -121,7 +126,12 @@ public class DataMovementInterfaceResource extends AppCatAbstractResource {
DataMovementInterface dataMovementInterface = (DataMovementInterface) q.getSingleResult();
DataMovementInterfaceResource dataMovementInterfaceResource = (DataMovementInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_INTERFACE, dataMovementInterface);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return dataMovementInterfaceResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -161,7 +171,12 @@ public class DataMovementInterfaceResource extends AppCatAbstractResource {
throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -206,12 +221,22 @@ public class DataMovementInterfaceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Data Movement Interface Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -232,7 +257,12 @@ public class DataMovementInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
DataMovementInterface existingDataMovementInterface = em.find(DataMovementInterface.class, new DataMovementInterface_PK(computeResourceId, dataMovementInterfaceId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
DataMovementInterface dataMovementInterface;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -255,7 +285,12 @@ public class DataMovementInterfaceResource extends AppCatAbstractResource {
em.merge(dataMovementInterface);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -282,7 +317,12 @@ public class DataMovementInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
DataMovementInterface dataMovementInterface = em.find(DataMovementInterface.class, new DataMovementInterface_PK(ids.get(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID), ids.get(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return dataMovementInterface != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java
index 1261b39..38f00e2 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java
@@ -65,7 +65,12 @@ public class GSISSHExportResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -101,7 +106,12 @@ public class GSISSHExportResource extends AppCatAbstractResource {
(GSISSHExportResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT
, gsisshExport);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gsisshExportResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -151,12 +161,22 @@ public class GSISSHExportResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for GSISSH Export Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -212,12 +232,22 @@ public class GSISSHExportResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for GSISSH Export resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -237,7 +267,12 @@ public class GSISSHExportResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GSISSHExport existingGSIExport = em.find(GSISSHExport.class, new GSISSHExportPK(submissionID, export));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -255,7 +290,12 @@ public class GSISSHExportResource extends AppCatAbstractResource {
em.persist(gsisshExport);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -284,7 +324,12 @@ public class GSISSHExportResource extends AppCatAbstractResource {
GSISSHExport gsisshExport = em.find(GSISSHExport.class, new GSISSHExportPK(ids.get(GSISSHExportConstants.SUBMISSION_ID),
ids.get(GSISSHExportConstants.EXPORT)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gsisshExport != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
[2/3] airavata git commit: fixing concurrent access issue at registry
level
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java
index 29fc5c5..4ecdfdc 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java
@@ -53,7 +53,12 @@ public class GSISSHSubmissionResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -80,7 +85,12 @@ public class GSISSHSubmissionResource extends AppCatAbstractResource {
(GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION
, gsisshSubmission);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gsisshSubmissionResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -158,12 +168,22 @@ public class GSISSHSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for GSISSH submission resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Submission resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -249,12 +269,22 @@ public class GSISSHSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for GSISSH Submission resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Submission resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -274,7 +304,12 @@ public class GSISSHSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GSISSHSubmission existingGSISSHSubmission = em.find(GSISSHSubmission.class, submissionID);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -295,7 +330,12 @@ public class GSISSHSubmissionResource extends AppCatAbstractResource {
em.persist(gsisshSubmission);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -315,7 +355,12 @@ public class GSISSHSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GSISSHSubmission gsisshSubmission = em.find(GSISSHSubmission.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gsisshSubmission != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayClientCredentialResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayClientCredentialResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayClientCredentialResource.java
index 82eec95..7321600 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayClientCredentialResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayClientCredentialResource.java
@@ -89,7 +89,12 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -116,7 +121,12 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
GatewayClientCredentialResource gatewayClientCredentialResource = (GatewayClientCredentialResource)
AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_CLIENT_CREDENTIAL, gatewayClientCredential);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gatewayClientCredentialResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -152,12 +162,22 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gateway Client Credential Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gateway Client Credential Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -188,7 +208,12 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
computeResourceResources.add(computeResourceResource);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -218,7 +243,12 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
gatewayClientCredentials.add(gatewayClientCredential.getClientKey());
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -252,12 +282,22 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gateway Client Credential Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gateway Client Credential Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -278,7 +318,13 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GatewayClientCredential existingGatewayClientCredential = em.find(GatewayClientCredential.class, clientKey);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
GatewayClientCredential gatewayClientCredential;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -296,7 +342,12 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
em.merge(gatewayClientCredential);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -316,7 +367,12 @@ public class GatewayClientCredentialResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GatewayClientCredential gatewayClientCredential = em.find(GatewayClientCredential.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gatewayClientCredential != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
index 725c72f..6a2ac8b 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
@@ -77,7 +77,12 @@ public class GatewayProfileResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -104,7 +109,12 @@ public class GatewayProfileResource extends AppCatAbstractResource {
(GatewayProfileResource) AppCatalogJPAUtils.getResource(
AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gatewayProfileResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -154,12 +164,22 @@ public class GatewayProfileResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gateway Profile resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gateway Profile resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -193,7 +213,12 @@ public class GatewayProfileResource extends AppCatAbstractResource {
}
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -244,12 +269,22 @@ public class GatewayProfileResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gateway Profile resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gateway Profile resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -269,7 +304,12 @@ public class GatewayProfileResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GatewayProfile existingGatewayProfile = em.find(GatewayProfile.class, gatewayID);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -289,7 +329,12 @@ public class GatewayProfileResource extends AppCatAbstractResource {
em.persist(gatewayProfile);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -308,7 +353,12 @@ public class GatewayProfileResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GatewayProfile gatewayProfile = em.find(GatewayProfile.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gatewayProfile != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java
index 1fda19f..f050ee9 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java
@@ -65,7 +65,12 @@ public class GlobusGKEndpointResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -100,7 +105,12 @@ public class GlobusGKEndpointResource extends AppCatAbstractResource {
GlobusGKEndpointResource gkEndpointResource =
(GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, gkEndpoint);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gkEndpointResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -150,12 +160,22 @@ public class GlobusGKEndpointResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Globus Endpoint Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Globus Endpoint Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,12 +231,22 @@ public class GlobusGKEndpointResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Globus EP resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Globus EP Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -236,7 +266,12 @@ public class GlobusGKEndpointResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GlobusGKEndpoint existingGlobusEP = em.find(GlobusGKEndpoint.class, new GlobusGKEndPointPK(submissionID, endpoint));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -254,7 +289,12 @@ public class GlobusGKEndpointResource extends AppCatAbstractResource {
em.persist(globusGKEndpoint);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -283,7 +323,12 @@ public class GlobusGKEndpointResource extends AppCatAbstractResource {
GlobusGKEndpoint gkEndpoint = em.find(GlobusGKEndpoint.class, new GlobusGKEndPointPK(ids.get(GlobusEPConstants.SUBMISSION_ID),
ids.get(GlobusEPConstants.ENDPOINT)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gkEndpoint != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java
index 483c730..5199602 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java
@@ -51,7 +51,12 @@ public class GlobusJobSubmissionResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -78,7 +83,12 @@ public class GlobusJobSubmissionResource extends AppCatAbstractResource {
(GlobusJobSubmissionResource) AppCatalogJPAUtils.getResource(
AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return globusJobSubmissionResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -130,12 +140,22 @@ public class GlobusJobSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ 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();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -212,12 +232,22 @@ public class GlobusJobSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ 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();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -254,7 +284,12 @@ public class GlobusJobSubmissionResource extends AppCatAbstractResource {
em.persist(globusJobSubmission);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -273,7 +308,12 @@ public class GlobusJobSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GlobusJobSubmission globusJobSubmission = em.find(GlobusJobSubmission.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return globusJobSubmission != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java
index ebfc241..6a7f470 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java
@@ -70,7 +70,12 @@ public class GridftpDataMovementResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -96,7 +101,12 @@ public class GridftpDataMovementResource extends AppCatAbstractResource {
GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) q.getSingleResult();
GridftpDataMovementResource gridftpDataMovementResource = (GridftpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gridftpDataMovementResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -131,12 +141,22 @@ public class GridftpDataMovementResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gridftp Data Movement Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gridftp Data Movement Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -181,12 +201,22 @@ public class GridftpDataMovementResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gridftp Data Movement Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gridftp Data Movement Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -207,7 +237,13 @@ public class GridftpDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GridftpDataMovement existingGridftpDataMovement = em.find(GridftpDataMovement.class, dataMovementInterfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
GridftpDataMovement gridftpDataMovement;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -226,7 +262,12 @@ public class GridftpDataMovementResource extends AppCatAbstractResource {
em.merge(gridftpDataMovement);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -246,7 +287,13 @@ public class GridftpDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GridftpDataMovement gridftpDataMovement = em.find(GridftpDataMovement.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
return gridftpDataMovement != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java
index 8f3e806..b56058e 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java
@@ -83,7 +83,12 @@ public class GridftpEndpointResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -117,7 +122,12 @@ public class GridftpEndpointResource extends AppCatAbstractResource {
GridftpEndpoint gridftpEndpoint = (GridftpEndpoint) q.getSingleResult();
GridftpEndpointResource gridftpEndpointResource = (GridftpEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_ENDPOINT, gridftpEndpoint);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gridftpEndpointResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -152,12 +162,22 @@ public class GridftpEndpointResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gridftp Endpoint Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gridftp Endpoint Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -202,12 +222,22 @@ public class GridftpEndpointResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Gridftp Endpoint Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Gridftp Endpoint Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -228,7 +258,13 @@ public class GridftpEndpointResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GridftpEndpoint existingGridftpEndpoint = em.find(GridftpEndpoint.class, new GridftpEndpoint_PK(endpoint, dataMovementInterfaceId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
GridftpEndpoint gridftpEndpoint;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -249,7 +285,12 @@ public class GridftpEndpointResource extends AppCatAbstractResource {
em.merge(gridftpEndpoint);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -276,7 +317,12 @@ public class GridftpEndpointResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
GridftpEndpoint gridftpEndpoint = em.find(GridftpEndpoint.class, new GridftpEndpoint_PK(ids.get(GridftpEndpointConstants.ENDPOINT), ids.get(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return gridftpEndpoint != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java
index 8f9a752..5532b7f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java
@@ -53,7 +53,12 @@ public class HostAliasAppResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -88,7 +93,12 @@ public class HostAliasAppResource extends AppCatAbstractResource {
HostAliasAppResource hostAliasResource =
(HostAliasAppResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_ALIAS, hostAlias);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return hostAliasResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -139,12 +149,22 @@ public class HostAliasAppResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Host Alias Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Host Alias Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -201,12 +221,22 @@ public class HostAliasAppResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Host Alias resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Host Alias Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -226,7 +256,12 @@ public class HostAliasAppResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
HostAlias existingHostAlias = em.find(HostAlias.class, new HostAliasPK(resourceID, alias));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -245,7 +280,12 @@ public class HostAliasAppResource extends AppCatAbstractResource {
em.persist(hostAlias);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -275,7 +315,12 @@ public class HostAliasAppResource extends AppCatAbstractResource {
HostAlias hostAlias = em.find(HostAlias.class, new HostAliasPK(ids.get(HostAliasConstants.RESOURCE_ID),
ids.get(HostAliasConstants.ALIAS)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return hostAlias != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java
index 3bd4c11..5b99959 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java
@@ -55,7 +55,12 @@ public class HostIPAddressResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -91,7 +96,12 @@ public class HostIPAddressResource extends AppCatAbstractResource {
HostIPAddressResource hostIPAddressResource =
(HostIPAddressResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_IPADDRESS, hostIPAddress);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return hostIPAddressResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -142,12 +152,22 @@ public class HostIPAddressResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Host IPAddress Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Host IPAddress Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -204,12 +224,22 @@ public class HostIPAddressResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Host IP Address resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Host IPAddress Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -229,7 +259,12 @@ public class HostIPAddressResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
HostIPAddress existingHostIP = em.find(HostIPAddress.class, new HostIPAddressPK(resourceID,ipaddress));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -247,7 +282,12 @@ public class HostIPAddressResource extends AppCatAbstractResource {
em.persist(hostIPAddress);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -277,7 +317,12 @@ public class HostIPAddressResource extends AppCatAbstractResource {
HostIPAddress hostIPAddress = em.find(HostIPAddress.class, new HostIPAddressPK(ids.get(HostIPAddressConstants.RESOURCE_ID),
ids.get(HostIPAddressConstants.IP_ADDRESS)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return hostIPAddress != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java
index 4cc623b..1f6516e 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java
@@ -66,7 +66,12 @@ public class JobManagerCommandResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -100,7 +105,12 @@ public class JobManagerCommandResource extends AppCatAbstractResource {
JobManagerCommand jobManagerCommand = (JobManagerCommand) q.getSingleResult();
JobManagerCommandResource jobManagerCommandResource = (JobManagerCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return jobManagerCommandResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -135,12 +145,22 @@ public class JobManagerCommandResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -185,12 +205,22 @@ public class JobManagerCommandResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,7 +241,13 @@ public class JobManagerCommandResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
JobManagerCommand existingJobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(resourceJobManagerId, commandType));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
JobManagerCommand jobManagerCommand;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -231,7 +267,12 @@ public class JobManagerCommandResource extends AppCatAbstractResource {
em.merge(jobManagerCommand);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -258,7 +299,12 @@ public class JobManagerCommandResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
JobManagerCommand jobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID), ids.get(JobManagerCommandConstants.COMMAND_TYPE)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return jobManagerCommand != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java
index a8df941..806d625 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java
@@ -87,7 +87,12 @@ public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -121,7 +126,12 @@ public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) q.getSingleResult();
JobSubmissionInterfaceResource jobSubmissionInterfaceResource = (JobSubmissionInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return jobSubmissionInterfaceResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -156,12 +166,22 @@ public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -206,12 +226,22 @@ public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -232,7 +262,12 @@ public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
JobSubmissionInterface existingJobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(jobSubmissionInterfaceId, computeResourceId));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
JobSubmissionInterface jobSubmissionInterface;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -255,7 +290,12 @@ public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
em.merge(jobSubmissionInterface);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -282,7 +322,12 @@ public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
JobSubmissionInterface jobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID), ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return jobSubmissionInterface != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java
index 0949f20..cd854b4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java
@@ -99,7 +99,12 @@ public class LibraryApendPathResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -134,7 +139,12 @@ public class LibraryApendPathResource extends AppCatAbstractResource {
LibraryApendPathResource resource =
(LibraryApendPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, libraryApendPath);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return resource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -185,12 +195,22 @@ public class LibraryApendPathResource extends AppCatAbstractResource {
}
}else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for libraryApendPath resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for libraryApendPath resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -227,7 +247,12 @@ public class LibraryApendPathResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
LibraryApendPath existigApendPath = em.find(LibraryApendPath.class, new LibraryApendPath_PK(deploymentId, name));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -246,7 +271,12 @@ public class LibraryApendPathResource extends AppCatAbstractResource {
em.persist(apendPath);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -275,7 +305,12 @@ public class LibraryApendPathResource extends AppCatAbstractResource {
LibraryApendPath apendPath = em.find(LibraryApendPath.class,
new LibraryApendPath_PK(ids.get(LibraryApendPathConstants.DEPLOYMENT_ID),
ids.get(LibraryApendPathConstants.NAME)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return apendPath != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java
index fa77b2c..38bd565 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java
@@ -99,7 +99,12 @@ public class LibraryPrepandPathResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -134,7 +139,12 @@ public class LibraryPrepandPathResource extends AppCatAbstractResource {
LibraryPrepandPathResource resource =
(LibraryPrepandPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, libraryPrepandPath);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return resource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -185,12 +195,22 @@ public class LibraryPrepandPathResource extends AppCatAbstractResource {
}
}else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for libraryPrepandPath resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for libraryPrepandPath resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -227,7 +247,12 @@ public class LibraryPrepandPathResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
LibraryPrepandPath existigPrepPath = em.find(LibraryPrepandPath.class, new LibraryPrepandPath_PK(deploymentId, name));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -245,7 +270,12 @@ public class LibraryPrepandPathResource extends AppCatAbstractResource {
em.persist(prepandPath);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -274,7 +304,12 @@ public class LibraryPrepandPathResource extends AppCatAbstractResource {
LibraryPrepandPath prepandPath = em.find(LibraryPrepandPath.class,
new LibraryPrepandPath_PK(ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID),
ids.get(LibraryPrepandPathConstants.NAME)));
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return prepandPath != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java
index 11cb089..dd44e49 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java
@@ -51,7 +51,12 @@ public class LocalDataMovementResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -77,7 +82,12 @@ public class LocalDataMovementResource extends AppCatAbstractResource {
LocalDataMovement localDataMovement = (LocalDataMovement) q.getSingleResult();
LocalDataMovementResource localDataMovementResource = (LocalDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_DATA_MOVEMENT, localDataMovement);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return localDataMovementResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -112,12 +122,22 @@ public class LocalDataMovementResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Local Data Movement Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Local Data Movement Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -162,12 +182,22 @@ public class LocalDataMovementResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Local Data Movement Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Local Data Movement Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -188,7 +218,13 @@ public class LocalDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
LocalDataMovement existingLocalDataMovement = em.find(LocalDataMovement.class, dataMovementInterfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
LocalDataMovement localDataMovement;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -204,7 +240,12 @@ public class LocalDataMovementResource extends AppCatAbstractResource {
em.merge(localDataMovement);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -224,7 +265,12 @@ public class LocalDataMovementResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
LocalDataMovement localDataMovement = em.find(LocalDataMovement.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return localDataMovement != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/f1e16793/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java
index ab0113e..9a3ec88 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java
@@ -74,7 +74,12 @@ public class LocalSubmissionResource extends AppCatAbstractResource {
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -100,7 +105,12 @@ public class LocalSubmissionResource extends AppCatAbstractResource {
LocalSubmission localSubmission = (LocalSubmission) q.getSingleResult();
LocalSubmissionResource localSubmissionResource = (LocalSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_SUBMISSION, localSubmission);
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return localSubmissionResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
@@ -135,12 +145,22 @@ public class LocalSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -185,12 +205,22 @@ public class LocalSubmissionResource extends AppCatAbstractResource {
}
} else {
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -211,7 +241,12 @@ public class LocalSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
LocalSubmission existingLocalSubmission = em.find(LocalSubmission.class, jobSubmissionInterfaceId);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
LocalSubmission localSubmission;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
@@ -232,7 +267,12 @@ public class LocalSubmissionResource extends AppCatAbstractResource {
em.merge(localSubmission);
}
em.getTransaction().commit();
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
@@ -252,7 +292,12 @@ public class LocalSubmissionResource extends AppCatAbstractResource {
try {
em = AppCatalogJPAUtils.getEntityManager();
LocalSubmission localSubmission = em.find(LocalSubmission.class, identifier);
- em.close();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
return localSubmission != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);