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:25 UTC
[2/3] airavata git commit: fixing concurrent access issue at registry
level
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);