when checking user exists should check with user's gateway id
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/3315c19b Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/3315c19b Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/3315c19b Branch: refs/heads/develop Commit: 3315c19b07038d6c2178507d441281ab6b868ad3 Parents: 9fd6be2 Author: scnakandala <[email protected]> Authored: Mon Jan 4 14:16:30 2016 -0500 Committer: scnakandala <[email protected]> Committed: Mon Jan 4 14:16:30 2016 -0500 ---------------------------------------------------------------------- .../server/handler/AiravataServerHandler.java | 20 ++++++++++---------- .../api/server/util/RegistryInitUtil.java | 2 +- .../manager/core/MetadataCatalogService.java | 2 +- .../experiment/catalog/ExpCatResourceUtils.java | 9 +++++---- .../catalog/impl/ExperimentCatalogImpl.java | 4 ++-- .../catalog/impl/ExperimentRegistry.java | 2 +- .../catalog/impl/ProjectRegistry.java | 2 +- .../src/main/resources/expcatalog-mysql.sql | 3 ++- 8 files changed, 23 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java index 67b616e..cba89dc 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java @@ -509,7 +509,7 @@ public class AiravataServerHandler implements Airavata.Iface { } List<Project> projects = new ArrayList<Project>(); try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -569,7 +569,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -629,7 +629,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -689,7 +689,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -749,7 +749,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -810,7 +810,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -871,7 +871,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -934,7 +934,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -995,7 +995,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); @@ -1158,7 +1158,7 @@ public class AiravataServerHandler implements Airavata.Iface { throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); } try { - if (!ExpCatResourceUtils.isUserExist(userName)){ + if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){ logger.error("User does not exist in the system. Please provide a valid user.."); AiravataSystemException exception = new AiravataSystemException(); exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java index 82cedba..9f61c65 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java @@ -93,7 +93,7 @@ public class RegistryInitUtil { } UserResource user; - if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser())){ + if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserGateway())){ user = ExpCatResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword(), ServerSettings.getDefaultUserGateway()); user.save(); }else { http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/modules/file-manager/file-manager-core/src/main/java/org/apache/airavata/file/manager/core/MetadataCatalogService.java ---------------------------------------------------------------------- diff --git a/modules/file-manager/file-manager-core/src/main/java/org/apache/airavata/file/manager/core/MetadataCatalogService.java b/modules/file-manager/file-manager-core/src/main/java/org/apache/airavata/file/manager/core/MetadataCatalogService.java index db00d98..5c09de5 100644 --- a/modules/file-manager/file-manager-core/src/main/java/org/apache/airavata/file/manager/core/MetadataCatalogService.java +++ b/modules/file-manager/file-manager-core/src/main/java/org/apache/airavata/file/manager/core/MetadataCatalogService.java @@ -41,7 +41,7 @@ public class MetadataCatalogService implements org.apache.airavata.file.manager. } /** - * Update exisiting metadata model + * Update existing metadata model * * @param metadataModel * @throws FileManagerException http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java index 2777ff0..035a456 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java @@ -85,7 +85,7 @@ public class ExpCatResourceUtils { } public static UserResource createUser(String username, String password, String gatewayId) throws RegistryException { - if (!isUserExist(username)) { + if (!isUserExist(username, gatewayId)) { UserResource userResource = new UserResource(); userResource.setUserName(username); userResource.setPassword(password); @@ -129,13 +129,14 @@ public class ExpCatResourceUtils { resource.save(); } - public static boolean isUserExist (String username) throws RegistryException{ + public static boolean isUserExist (String username, String gatewayId) throws RegistryException{ EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); QueryGenerator generator = new QueryGenerator(AbstractExpCatResource.USERS); generator.setParameter(AbstractExpCatResource.UserConstants.USERNAME, username); + generator.setParameter(AbstractExpCatResource.UserConstants.GATEWAY_ID, gatewayId); Query q = generator.selectQuery(em); int size = q.getResultList().size(); em.getTransaction().commit(); @@ -158,7 +159,7 @@ public class ExpCatResourceUtils { public static ExperimentCatResource getUser(String userName, String gatewayId) throws RegistryException{ EntityManager em = null; try { - if (isUserExist(userName)) { + if (isUserExist(userName, gatewayId)) { em = getEntityManager(); UserPK userPK = new UserPK(); userPK.setUserName(userName); @@ -314,7 +315,7 @@ public class ExpCatResourceUtils { if (!isGatewayExist(gatewayResource.getGatewayName())){ gatewayResource.save(); } - if (!isUserExist(userResource.getUserName())){ + if (!isUserExist(userResource.getUserName(), gatewayResource.getGatewayId())){ userResource.save(); } Gateway gateway = em.find(Gateway.class, gatewayResource.getGatewayId()); http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java index 7ef834e..48d31b0 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java @@ -68,7 +68,7 @@ public class ExperimentCatalogImpl implements ExperimentCatalog { gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway()); } - if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser())){ + if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserGateway())){ user = ExpCatResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword(), ServerSettings.getDefaultUserGateway()); user.save(); }else { @@ -91,7 +91,7 @@ public class ExperimentCatalogImpl implements ExperimentCatalog { gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(gateway); } - if (!ExpCatResourceUtils.isUserExist(username)){ + if (!ExpCatResourceUtils.isUserExist(username, gatewayResource.getGatewayId())){ user = ExpCatResourceUtils.createUser(username, password, gateway); user.save(); }else { http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java index 533f55b..5e10395 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java @@ -70,7 +70,7 @@ public class ExperimentRegistry { public String addExperiment(ExperimentModel experiment) throws RegistryException { String experimentId; try { - if (!ExpCatResourceUtils.isUserExist(experiment.getUserName())) { + if (!ExpCatResourceUtils.isUserExist(experiment.getUserName(), experiment.getGatewayId())) { ExpCatResourceUtils.addUser(experiment.getUserName(), null, experiment.getGatewayId()); } if (!workerResource.isProjectExists(experiment.getProjectId())) { http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java index 7d77308..ef44c64 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java @@ -57,7 +57,7 @@ public class ProjectRegistry { public String addProject (Project project, String gatewayId) throws RegistryException{ String projectId; try { - if (!ExpCatResourceUtils.isUserExist(project.getOwner())){ + if (!ExpCatResourceUtils.isUserExist(project.getOwner(), gatewayId)){ ExpCatResourceUtils.addUser(project.getOwner(), null, gatewayId); } ProjectResource projectResource = new ProjectResource(); http://git-wip-us.apache.org/repos/asf/airavata/blob/3315c19b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql ---------------------------------------------------------------------- diff --git a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql index b71b9b1..a3c335f 100644 --- a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql +++ b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql @@ -31,7 +31,8 @@ CREATE TABLE USERS ( USER_NAME VARCHAR(255), PASSWORD VARCHAR(255), - PRIMARY KEY(USER_NAME) + GATEWAY_ID VARCHAR(255), + PRIMARY KEY(USER_NAME, GATEWAY_ID) ); CREATE TABLE GATEWAY_WORKER
