You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/06/28 17:00:54 UTC
airavata git commit: Duplicate check query for gateway requests
Repository: airavata
Updated Branches:
refs/heads/develop 2b92f6586 -> cb4565d98
Duplicate check query for gateway requests
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/cb4565d9
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/cb4565d9
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/cb4565d9
Branch: refs/heads/develop
Commit: cb4565d9835ed38cb3108ce78d61d38cd1464bcf
Parents: 2b92f65
Author: Marcus Christie <ma...@apache.org>
Authored: Wed Jun 28 13:00:13 2017 -0400
Committer: Marcus Christie <ma...@apache.org>
Committed: Wed Jun 28 13:00:13 2017 -0400
----------------------------------------------------------------------
.../model/tenant/TenantApprovalStatus.java | 5 ++++-
.../model/workspace/GatewayApprovalStatus.java | 9 ++++----
.../profile/commons/utils/QueryConstants.java | 10 +++++++--
.../handlers/TenantProfileServiceHandler.java | 6 ++---
.../repositories/TenantProfileRepository.java | 23 +++++++++++++++++++-
.../workspace_model.thrift | 3 ++-
.../tenant_profile_model.thrift | 3 ++-
7 files changed, 44 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/cb4565d9/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/tenant/TenantApprovalStatus.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/tenant/TenantApprovalStatus.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/tenant/TenantApprovalStatus.java
index 4c43d6f..496fe0d 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/tenant/TenantApprovalStatus.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/tenant/TenantApprovalStatus.java
@@ -35,7 +35,8 @@ public enum TenantApprovalStatus implements org.apache.thrift.TEnum {
DEACTIVATED(3),
CANCELLED(4),
DENIED(5),
- CREATED(6);
+ CREATED(6),
+ DEPLOYED(7);
private final int value;
@@ -70,6 +71,8 @@ public enum TenantApprovalStatus implements org.apache.thrift.TEnum {
return DENIED;
case 6:
return CREATED;
+ case 7:
+ return DEPLOYED;
default:
return null;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cb4565d9/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/GatewayApprovalStatus.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/GatewayApprovalStatus.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/GatewayApprovalStatus.java
index e53ee20..3f83cf1 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/GatewayApprovalStatus.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/GatewayApprovalStatus.java
@@ -24,10 +24,6 @@
package org.apache.airavata.model.workspace;
-import java.util.Map;
-import java.util.HashMap;
-import org.apache.thrift.TEnum;
-
public enum GatewayApprovalStatus implements org.apache.thrift.TEnum {
REQUESTED(0),
APPROVED(1),
@@ -35,7 +31,8 @@ public enum GatewayApprovalStatus implements org.apache.thrift.TEnum {
DEACTIVATED(3),
CANCELLED(4),
DENIED(5),
- CREATED(6);
+ CREATED(6),
+ DEPLOYED(7);
private final int value;
@@ -70,6 +67,8 @@ public enum GatewayApprovalStatus implements org.apache.thrift.TEnum {
return DENIED;
case 6:
return CREATED;
+ case 7:
+ return DEPLOYED;
default:
return null;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cb4565d9/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/QueryConstants.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/QueryConstants.java b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/QueryConstants.java
index caa72d9..8b651aa 100644
--- a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/QueryConstants.java
+++ b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/QueryConstants.java
@@ -17,8 +17,14 @@ public class QueryConstants {
"where u.gatewayId LIKE :" + UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
public static final String FIND_GATEWAY_BY_ID = "SELECT g FROM GatewayEntity g " +
- "where g.gatewayId LIKE :" + Gateway._Fields.GATEWAY_ID.getFieldName() + " " +
- "AND g.gatewayApprovalStatus LIKE :" + Gateway._Fields.GATEWAY_APPROVAL_STATUS.getFieldName();
+ "where g.gatewayId LIKE :" + Gateway._Fields.GATEWAY_ID.getFieldName();
+
+ public static final String FIND_DUPLICATE_GATEWAY = "SELECT g FROM GatewayEntity g " +
+ "where g.gatewayApprovalStatus IN :" + Gateway._Fields.GATEWAY_APPROVAL_STATUS.getFieldName() + " " +
+ "and (g.gatewayId LIKE :" + Gateway._Fields.GATEWAY_ID.getFieldName() + " " +
+ " or g.gatewayName LIKE :" + Gateway._Fields.GATEWAY_NAME.getFieldName() + " " +
+ " or g.gatewayUrl LIKE :" + Gateway._Fields.GATEWAY_URL.getFieldName() + " " +
+ " )";
public static final String GET_ALL_GATEWAYS = "SELECT g FROM GatewayEntity g";
http://git-wip-us.apache.org/repos/asf/airavata/blob/cb4565d9/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
index dd84e0c..5f89fe6 100644
--- a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
+++ b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
@@ -214,10 +214,8 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
private boolean checkDuplicateGateway(Gateway gateway) throws TenantProfileServiceException {
try {
- Gateway duplicateGateway = tenantProfileRepository.getGateway(gateway.getGatewayId());
- return duplicateGateway != null && ((duplicateGateway.getGatewayId().equals(gateway.getGatewayId()))
- || (duplicateGateway.getGatewayName().equals(gateway.getGatewayName()))
- || (duplicateGateway.getGatewayURL().equals(gateway.getGatewayURL())));
+ Gateway duplicateGateway = tenantProfileRepository.getDuplicateGateway(gateway.getGatewayId(), gateway.getGatewayName(), gateway.getGatewayURL());
+ return duplicateGateway != null;
} catch (Exception ex) {
logger.error("Error checking if duplicate gateway-profile exists, reason: " + ex.getMessage(), ex);
TenantProfileServiceException exception = new TenantProfileServiceException();
http://git-wip-us.apache.org/repos/asf/airavata/blob/cb4565d9/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
index 049a033..fc590c2 100644
--- a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
+++ b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
@@ -28,6 +28,7 @@ import org.apache.airavata.service.profile.commons.utils.QueryConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -48,7 +49,6 @@ public class TenantProfileRepository extends AbstractRepository<Gateway, Gateway
try {
Map<String, Object> queryParam = new HashMap<String, Object>();
queryParam.put(Gateway._Fields.GATEWAY_ID.getFieldName(), gatewayId);
- queryParam.put(Gateway._Fields.GATEWAY_APPROVAL_STATUS.getFieldName(), GatewayApprovalStatus.APPROVED.name());
List<Gateway> gatewayList = select(QueryConstants.FIND_GATEWAY_BY_ID, 1, 0, queryParam);
if (!gatewayList.isEmpty()) {
gateway = gatewayList.get(0);
@@ -81,4 +81,25 @@ public class TenantProfileRepository extends AbstractRepository<Gateway, Gateway
throw e;
}
}
+
+ public Gateway getDuplicateGateway(String gatewayId, String gatewayName, String gatewayURL) throws Exception {
+
+ Gateway gateway = null;
+ try {
+ Map<String, Object> queryParams = new HashMap<String, Object>();
+ queryParams.put(Gateway._Fields.GATEWAY_ID.getFieldName(), gatewayId);
+ queryParams.put(Gateway._Fields.GATEWAY_NAME.getFieldName(), gatewayName);
+ queryParams.put(Gateway._Fields.GATEWAY_URL.getFieldName(), gatewayURL);
+ // Only considered APPROVED or CREATED or DEPLOYED gateways when looking for duplicates
+ queryParams.put(Gateway._Fields.GATEWAY_APPROVAL_STATUS.getFieldName(), Arrays.asList(GatewayApprovalStatus.APPROVED.name(), GatewayApprovalStatus.CREATED.name(), GatewayApprovalStatus.DEPLOYED.name()));
+ List<Gateway> gatewayList = select(QueryConstants.FIND_DUPLICATE_GATEWAY, 1, 0, queryParams);
+ if (!gatewayList.isEmpty()) {
+ gateway = gatewayList.get(0);
+ }
+ } catch (Exception ex) {
+ logger.error("Error while searching for duplicate gateway, reason: " + ex.getMessage(), ex);
+ throw ex;
+ }
+ return gateway;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cb4565d9/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift b/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
index 4845798..6604e0c 100644
--- a/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
+++ b/thrift-interface-descriptions/data-models/experiment-catalog-models/workspace_model.thrift
@@ -67,7 +67,8 @@ enum GatewayApprovalStatus {
DEACTIVATED,
CANCELLED,
DENIED,
- CREATED
+ CREATED,
+ DEPLOYED
}
struct Gateway {
http://git-wip-us.apache.org/repos/asf/airavata/blob/cb4565d9/thrift-interface-descriptions/data-models/user-tenant-group-models/tenant_profile_model.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/user-tenant-group-models/tenant_profile_model.thrift b/thrift-interface-descriptions/data-models/user-tenant-group-models/tenant_profile_model.thrift
index 557dddb..ee946df 100644
--- a/thrift-interface-descriptions/data-models/user-tenant-group-models/tenant_profile_model.thrift
+++ b/thrift-interface-descriptions/data-models/user-tenant-group-models/tenant_profile_model.thrift
@@ -32,7 +32,8 @@ enum TenantApprovalStatus {
DEACTIVATED,
CANCELLED,
DENIED,
- CREATED
+ CREATED,
+ DEPLOYED
}
struct Tenant {