You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/10/17 22:41:48 UTC
[3/3] airavata git commit: updating getting started guide and fixing
some sharing issues
updating getting started guide and fixing some sharing issues
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/273d074a
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/273d074a
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/273d074a
Branch: refs/heads/develop
Commit: 273d074ace42f554ca727dd044ee342c917cac29
Parents: b85d3db
Author: scnakandala <su...@gmail.com>
Authored: Mon Oct 17 18:41:41 2016 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Mon Oct 17 18:41:41 2016 -0400
----------------------------------------------------------------------
.../server/handler/AiravataServerHandler.java | 234 +++++------
.../migrator/airavata/AiravataDataMigrator.java | 6 +-
.../registry/db/entities/EntityEntity.java | 14 +
.../db/repositories/AbstractRepository.java | 4 +-
.../db/repositories/EntityRepository.java | 21 +-
.../repositories/GroupMembershipRepository.java | 4 +-
.../db/repositories/SharingRepository.java | 2 +-
.../db/repositories/UserGroupRepository.java | 2 +-
.../db/repositories/UserRepository.java | 2 +-
.../sharing/registry/db/utils/DBConstants.java | 1 +
.../registry/db/utils/DatabaseCreator.java | 4 +-
.../sharing/registry/server/ServerMain.java | 12 +-
.../server/SharingRegistryServerHandler.java | 27 +-
.../main/resources/sharing-registry-derby.sql | 1 +
.../main/resources/sharing-registry-mysql.sql | 1 +
.../SharingRegistryServerHandlerTest.java | 14 +-
.../registry/SharingRegistryServiceTest.java | 233 ++++++++++-
.../sharing/registry/models/Entity.java | 138 ++++++-
.../registry/models/EntitySearchField.java | 13 +-
.../service/cpi/SharingRegistryService.java | 392 +++++++++----------
.../sharing-service-docs/api-docs/index.html | 4 +-
.../api-docs/sharing_cpi.html | 24 +-
.../api-docs/sharing_models.html | 19 +-
.../sharing-service-docs/index.html | 270 ++++++++++++-
.../thrift_models/sharing_cpi.thrift | 16 +-
.../thrift_models/sharing_models.thrift | 14 +-
26 files changed, 1029 insertions(+), 443 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/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 36770ea..5570157 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
@@ -123,7 +123,7 @@ public class AiravataServerHandler implements Airavata.Iface {
user.setDomainId(domain.domainId);
user.setUserId(ServerSettings.getDefaultUser()+"@"+ServerSettings.getDefaultUserGateway());
user.setUserName(ServerSettings.getDefaultUser());
- sharingRegistryServerHandler.registerUser(user);
+ sharingRegistryServerHandler.createUser(user);
//Creating Entity Types for each domain
EntityType entityType = new EntityType();
@@ -671,7 +671,7 @@ public class AiravataServerHandler implements Airavata.Iface {
entity.setName(project.getName());
entity.setDescription(project.getDescription());
- sharingRegistryServerHandler.registerEntity(entity);
+ sharingRegistryServerHandler.createEntity(entity);
}
logger.debug("Airavata created project with project Id : " + projectId + " for gateway Id : " + gatewayId);
@@ -808,7 +808,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@Override
@SecurityCheck
public List<Project> getUserProjects(AuthzToken authzToken, String gatewayId, String userName,
- int limit, int offset)
+ int limit, int offset)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
if (ServerSettings.isEnableSharing()){
@@ -998,7 +998,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@Override
@SecurityCheck
public List<ExperimentModel> getUserExperiments(AuthzToken authzToken, String gatewayId, String userName, int limit,
- int offset) throws InvalidRequestException,
+ int offset) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
return getRegistryServiceClient().getUserExperiments(gatewayId, userName, limit, offset);
@@ -1049,7 +1049,7 @@ public class AiravataServerHandler implements Airavata.Iface {
entity.setName(experiment.getExperimentName());
entity.setDescription(experiment.getDescription());
- sharingRegistryServerHandler.registerEntity(entity);
+ sharingRegistryServerHandler.createEntity(entity);
}
ExperimentStatusChangeEvent event = new ExperimentStatusChangeEvent(ExperimentState.CREATED,
@@ -1245,7 +1245,7 @@ public class AiravataServerHandler implements Airavata.Iface {
RegistryService.Client regClient = getRegistryServiceClient();
ExperimentModel experimentModel = regClient.getExperiment(airavataExperimentId);
if(ServerSettings.isEnableSharing() && !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(experimentModel.getUserName())
- || !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(experimentModel.getGatewayId())){
+ || !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(experimentModel.getGatewayId())){
try {
String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
String userId = authzToken.getClaimsMap().get(Constants.USER_NAME);
@@ -1567,9 +1567,9 @@ public class AiravataServerHandler implements Airavata.Iface {
existingExperiment.getErrors().clear();
}
if(existingExperiment.getUserConfigurationData() != null && existingExperiment.getUserConfigurationData()
- .getComputationalResourceScheduling() != null){
+ .getComputationalResourceScheduling() != null){
String compResourceId = existingExperiment.getUserConfigurationData()
- .getComputationalResourceScheduling().getResourceHostId();
+ .getComputationalResourceScheduling().getResourceHostId();
ComputeResourceDescription computeResourceDescription = regClient.getComputeResource(compResourceId);
if(!computeResourceDescription.isEnabled()){
@@ -1589,7 +1589,7 @@ public class AiravataServerHandler implements Airavata.Iface {
entity.setName(existingExperiment.getExperimentName());
entity.setDescription(existingExperiment.getDescription());
- sharingRegistryServerHandler.registerEntity(entity);
+ sharingRegistryServerHandler.createEntity(entity);
}
return expId;
@@ -2127,7 +2127,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public String registerComputeResource(AuthzToken authzToken, ComputeResourceDescription computeResourceDescription)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().registerComputeResource(computeResourceDescription);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while saving compute resource...", e);
@@ -2149,7 +2149,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public ComputeResourceDescription getComputeResource(AuthzToken authzToken, String computeResourceId)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().getComputeResource(computeResourceId);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(computeResourceId, "Error while retrieving compute resource...", e);
@@ -2193,7 +2193,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean updateComputeResource(AuthzToken authzToken, String computeResourceId, ComputeResourceDescription computeResourceDescription)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().updateComputeResource(computeResourceId, computeResourceDescription);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(computeResourceId, "Error while updating compute resource...", e);
@@ -2215,7 +2215,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean deleteComputeResource(AuthzToken authzToken, String computeResourceId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().deleteComputeResource(computeResourceId);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(computeResourceId, "Error while deleting compute resource...", e);
@@ -2351,7 +2351,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public String addLocalSubmissionDetails(AuthzToken authzToken, String computeResourceId, int priorityOrder, LOCALSubmission localSubmission)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().addLocalSubmissionDetails(computeResourceId, priorityOrder, localSubmission);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(computeResourceId, "Error while adding job submission interface to resource compute resource...", e);
@@ -2374,7 +2374,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean updateLocalSubmissionDetails(AuthzToken authzToken, String jobSubmissionInterfaceId, LOCALSubmission localSubmission)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().updateLocalSubmissionDetails(jobSubmissionInterfaceId, localSubmission);
} catch (Exception e) {
logger.error(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e);
@@ -2415,7 +2415,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public String addSSHJobSubmissionDetails(AuthzToken authzToken, String computeResourceId, int priorityOrder, SSHJobSubmission sshJobSubmission)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().addSSHJobSubmissionDetails(computeResourceId, priorityOrder, sshJobSubmission);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(computeResourceId, "Error while adding job submission interface to resource compute resource...", e);
@@ -2511,19 +2511,19 @@ public class AiravataServerHandler implements Airavata.Iface {
@Override
@SecurityCheck
- public String addUNICOREJobSubmissionDetails(AuthzToken authzToken, String computeResourceId, int priorityOrder,
+ public String addUNICOREJobSubmissionDetails(AuthzToken authzToken, String computeResourceId, int priorityOrder,
UnicoreJobSubmission unicoreJobSubmission)
- throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
- return getRegistryServiceClient().addUNICOREJobSubmissionDetails(computeResourceId, priorityOrder, unicoreJobSubmission);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- logger.error("Error while adding job submission interface to resource compute resource...", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage());
- throw exception;
- }
- }
+ throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+ try {
+ return getRegistryServiceClient().addUNICOREJobSubmissionDetails(computeResourceId, priorityOrder, unicoreJobSubmission);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ logger.error("Error while adding job submission interface to resource compute resource...", e);
+ AiravataSystemException exception = new AiravataSystemException();
+ exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+ exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage());
+ throw exception;
+ }
+ }
@Override
@SecurityCheck
@@ -2553,7 +2553,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean updateSSHJobSubmissionDetails(AuthzToken authzToken, String jobSubmissionInterfaceId, SSHJobSubmission sshJobSubmission)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().updateSSHJobSubmissionDetails(jobSubmissionInterfaceId, sshJobSubmission);
} catch (Exception e) {
logger.error(jobSubmissionInterfaceId, "Error while adding job submission interface to resource compute resource...", e);
@@ -2617,7 +2617,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public String addLocalDataMovementDetails(AuthzToken authzToken, String resourceId, DMType dmType, int priorityOrder,
LOCALDataMovement localDataMovement) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().addLocalDataMovementDetails(resourceId, dmType, priorityOrder, localDataMovement);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(resourceId, "Error while adding data movement interface to resource resource...", e);
@@ -2640,7 +2640,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean updateLocalDataMovementDetails(AuthzToken authzToken, String dataMovementInterfaceId, LOCALDataMovement localDataMovement)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().updateLocalDataMovementDetails(dataMovementInterfaceId, localDataMovement);
} catch (Exception e) {
logger.error(dataMovementInterfaceId, "Error while updating local data movement interface..", e);
@@ -2682,7 +2682,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public String addSCPDataMovementDetails(AuthzToken authzToken, String resourceId, DMType dmType, int priorityOrder, SCPDataMovement scpDataMovement)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().addSCPDataMovementDetails(resourceId, dmType, priorityOrder, scpDataMovement);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(resourceId, "Error while adding data movement interface to resource compute resource...", e);
@@ -2706,7 +2706,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean updateSCPDataMovementDetails(AuthzToken authzToken, String dataMovementInterfaceId, SCPDataMovement scpDataMovement)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().updateSCPDataMovementDetails(dataMovementInterfaceId, scpDataMovement);
} catch (Exception e) {
logger.error(dataMovementInterfaceId, "Error while adding job submission interface to resource compute resource...", e);
@@ -2794,7 +2794,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public String addGridFTPDataMovementDetails(AuthzToken authzToken, String computeResourceId, DMType dmType, int priorityOrder,
GridFTPDataMovement gridFTPDataMovement) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().addGridFTPDataMovementDetails(computeResourceId, dmType, priorityOrder, gridFTPDataMovement);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(computeResourceId, "Error while adding data movement interface to resource compute resource...", e);
@@ -2818,7 +2818,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean updateGridFTPDataMovementDetails(AuthzToken authzToken, String dataMovementInterfaceId, GridFTPDataMovement gridFTPDataMovement)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().updateGridFTPDataMovementDetails(dataMovementInterfaceId, gridFTPDataMovement);
} catch (Exception e) {
logger.error(dataMovementInterfaceId, "Error while adding job submission interface to resource compute resource...", e);
@@ -3035,7 +3035,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public String registerGatewayResourceProfile(AuthzToken authzToken, GatewayResourceProfile gatewayResourceProfile)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().registerGatewayResourceProfile(gatewayResourceProfile);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while registering gateway resource profile...", e);
@@ -3128,7 +3128,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public boolean addGatewayComputeResourcePreference(AuthzToken authzToken, String gatewayID, String computeResourceId,
ComputeResourcePreference computeResourcePreference) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().addGatewayComputeResourcePreference(gatewayID, computeResourceId, computeResourcePreference);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(gatewayID, "Error while registering gateway resource profile preference...", e);
@@ -3166,7 +3166,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public ComputeResourcePreference getGatewayComputeResourcePreference(AuthzToken authzToken, String gatewayID, String computeResourceId)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().getGatewayComputeResourcePreference(gatewayID, computeResourceId);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
@@ -3202,7 +3202,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public List<ComputeResourcePreference> getAllGatewayComputeResourcePreferences(AuthzToken authzToken, String gatewayID)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().getAllGatewayComputeResourcePreferences(gatewayID);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(gatewayID, "Error while reading gateway compute resource preferences...", e);
@@ -3255,7 +3255,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public boolean updateGatewayComputeResourcePreference(AuthzToken authzToken, String gatewayID, String computeResourceId,
ComputeResourcePreference computeResourcePreference)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().updateGatewayComputeResourcePreference(gatewayID, computeResourceId, computeResourcePreference);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
@@ -3292,7 +3292,7 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean deleteGatewayComputeResourcePreference(AuthzToken authzToken, String gatewayID, String computeResourceId)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
+ try {
return getRegistryServiceClient().deleteGatewayComputeResourcePreference(gatewayID, computeResourceId);
} catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
@@ -3627,109 +3627,109 @@ public class AiravataServerHandler implements Airavata.Iface {
@Override
@SecurityCheck
- public List<String> getAllWorkflows(AuthzToken authzToken, String gatewayId) throws InvalidRequestException,
- AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+ public List<String> getAllWorkflows(AuthzToken authzToken, String gatewayId) throws InvalidRequestException,
+ AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- return getRegistryServiceClient().getAllWorkflows(gatewayId);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- String msg = "Error in retrieving all workflow template Ids.";
- logger.error(msg, e);
- AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ return getRegistryServiceClient().getAllWorkflows(gatewayId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ String msg = "Error in retrieving all workflow template Ids.";
+ logger.error(msg, e);
+ AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg+" More info : " + e.getMessage());
throw exception;
- }
- }
+ }
+ }
- @Override
+ @Override
@SecurityCheck
- public WorkflowModel getWorkflow(AuthzToken authzToken, String workflowTemplateId)
- throws InvalidRequestException, AiravataClientException, AuthorizationException, AiravataSystemException, TException {
- try {
- return getRegistryServiceClient().getWorkflow(workflowTemplateId);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- String msg = "Error in retrieving the workflow "+workflowTemplateId+".";
- logger.error(msg, e);
- AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ public WorkflowModel getWorkflow(AuthzToken authzToken, String workflowTemplateId)
+ throws InvalidRequestException, AiravataClientException, AuthorizationException, AiravataSystemException, TException {
+ try {
+ return getRegistryServiceClient().getWorkflow(workflowTemplateId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ String msg = "Error in retrieving the workflow "+workflowTemplateId+".";
+ logger.error(msg, e);
+ AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg+" More info : " + e.getMessage());
throw exception;
- }
- }
+ }
+ }
- @Override
+ @Override
@SecurityCheck
- public void deleteWorkflow(AuthzToken authzToken, String workflowTemplateId)
- throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
- getRegistryServiceClient().deleteWorkflow(workflowTemplateId);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- String msg = "Error in deleting the workflow "+workflowTemplateId+".";
- logger.error(msg, e);
- AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ public void deleteWorkflow(AuthzToken authzToken, String workflowTemplateId)
+ throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+ try {
+ getRegistryServiceClient().deleteWorkflow(workflowTemplateId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ String msg = "Error in deleting the workflow "+workflowTemplateId+".";
+ logger.error(msg, e);
+ AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg+" More info : " + e.getMessage());
throw exception;
- }
- }
+ }
+ }
- @Override
+ @Override
@SecurityCheck
- public String registerWorkflow(AuthzToken authzToken, String gatewayId, WorkflowModel workflow)
- throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+ public String registerWorkflow(AuthzToken authzToken, String gatewayId, WorkflowModel workflow)
+ throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- return getRegistryServiceClient().registerWorkflow(gatewayId, workflow);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- String msg = "Error in registering the workflow "+workflow.getName()+".";
- logger.error(msg, e);
- AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ return getRegistryServiceClient().registerWorkflow(gatewayId, workflow);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ String msg = "Error in registering the workflow "+workflow.getName()+".";
+ logger.error(msg, e);
+ AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg+" More info : " + e.getMessage());
throw exception;
- }
- }
+ }
+ }
- @Override
+ @Override
@SecurityCheck
- public void updateWorkflow(AuthzToken authzToken, String workflowTemplateId, WorkflowModel workflow)
- throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
- getRegistryServiceClient().updateWorkflow(workflowTemplateId, workflow);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- String msg = "Error in updating the workflow "+workflow.getName()+".";
- logger.error(msg, e);
- AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ public void updateWorkflow(AuthzToken authzToken, String workflowTemplateId, WorkflowModel workflow)
+ throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+ try {
+ getRegistryServiceClient().updateWorkflow(workflowTemplateId, workflow);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ String msg = "Error in updating the workflow "+workflow.getName()+".";
+ logger.error(msg, e);
+ AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg+" More info : " + e.getMessage());
throw exception;
- }
- }
+ }
+ }
- @Override
+ @Override
@SecurityCheck
- public String getWorkflowTemplateId(AuthzToken authzToken, String workflowName)
- throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
- return getRegistryServiceClient().getWorkflowTemplateId(workflowName);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- String msg = "Error in retrieving the workflow template id for "+workflowName+".";
- logger.error(msg, e);
- AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ public String getWorkflowTemplateId(AuthzToken authzToken, String workflowName)
+ throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+ try {
+ return getRegistryServiceClient().getWorkflowTemplateId(workflowName);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ String msg = "Error in retrieving the workflow template id for "+workflowName+".";
+ logger.error(msg, e);
+ AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg+" More info : " + e.getMessage());
throw exception;
- }
- }
+ }
+ }
- @Override
+ @Override
@SecurityCheck
- public boolean isWorkflowExistWithName(AuthzToken authzToken, String workflowName)
- throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- try {
- return getRegistryServiceClient().isWorkflowExistWithName(workflowName);
- } catch (ApplicationSettingsException | RegistryServiceException e) {
- String msg = "Error in veriying the workflow for workflow name "+workflowName+".";
- logger.error(msg, e);
- AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ public boolean isWorkflowExistWithName(AuthzToken authzToken, String workflowName)
+ throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
+ try {
+ return getRegistryServiceClient().isWorkflowExistWithName(workflowName);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
+ String msg = "Error in veriying the workflow for workflow name "+workflowName+".";
+ logger.error(msg, e);
+ AiravataSystemException exception = new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage(msg+" More info : " + e.getMessage());
throw exception;
- }
- }
+ }
+ }
/**
@@ -3878,11 +3878,11 @@ public class AiravataServerHandler implements Airavata.Iface {
if(permissionType.equals(ResourcePermissionType.WRITE))
sharingRegistryServerHandler.getListOfSharedUsers(authzToken.getClaimsMap().get(Constants.GATEWAY_ID),
resourceId, authzToken.getClaimsMap().get(Constants.GATEWAY_ID)
- + ":WRITE").stream().forEach(u->accessibleUsers.add(u.userId));
+ + ":WRITE").stream().forEach(u->accessibleUsers.add(u.userId));
else if(permissionType.equals(ResourcePermissionType.READ))
sharingRegistryServerHandler.getListOfSharedUsers(authzToken.getClaimsMap().get(Constants.GATEWAY_ID),
resourceId, authzToken.getClaimsMap().get(Constants.GATEWAY_ID)
- + ":READ").stream().forEach(u->accessibleUsers.add(u.userId));
+ + ":READ").stream().forEach(u->accessibleUsers.add(u.userId));
return accessibleUsers;
} catch (Exception e) {
String msg = "Error in getting all accessible users for resource. Resource ID : " + resourceId + " Resource Type : " + resourceType.toString() ;
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
index e38a760..a8ec19f 100644
--- a/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
+++ b/modules/sharing-registry/sharing-data-migrator/src/main/java/org/apache/airavata/sharing/registry/migrator/airavata/AiravataDataMigrator.java
@@ -106,7 +106,7 @@ public class AiravataDataMigrator {
user.setDomainId(rs.getString("GATEWAY_ID"));
user.setUserName(rs.getString("USER_NAME"));
- govRegistryServerHandler.registerUser(user);
+ govRegistryServerHandler.createUser(user);
}
//Creating project entries
@@ -128,7 +128,7 @@ public class AiravataDataMigrator {
Map<String, String> metadata = new HashMap<>();
metadata.put("CREATION_TIME", rs.getDate("CREATION_TIME").toString());
- govRegistryServerHandler.registerEntity(entity);
+ govRegistryServerHandler.createEntity(entity);
}
//Creating experiment entries
@@ -158,7 +158,7 @@ public class AiravataDataMigrator {
metadata.put("GATEWAY_INSTANCE_ID", rs.getString("GATEWAY_INSTANCE_ID"));
metadata.put("ARCHIVE", rs.getString("ARCHIVE"));
- govRegistryServerHandler.registerEntity(entity);
+ govRegistryServerHandler.createEntity(entity);
}
expCatConnection.close();
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
index 7ee8225..1fbf4f4 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/entities/EntityEntity.java
@@ -40,6 +40,7 @@ public class EntityEntity {
private String description;
private ByteBuffer binaryData;
private String fullText;
+ private Long originalEntityCreationTime;
private Long createdTime;
private Long updatedTime;
@@ -134,6 +135,16 @@ public class EntityEntity {
}
@Basic
+ @Column(name = "ORIGINAL_ENTITY_CREATION_TIME")
+ public Long getOriginalEntityCreationTime() {
+ return originalEntityCreationTime;
+ }
+
+ public void setOriginalEntityCreationTime(Long originalEntityCreationTime) {
+ this.originalEntityCreationTime = originalEntityCreationTime;
+ }
+
+ @Basic
@Column(name = "CREATED_TIME")
public Long getCreatedTime() {
return createdTime;
@@ -167,6 +178,8 @@ public class EntityEntity {
if (description != null ? !description.equals(that.description) : that.description != null) return false;
if (binaryData.equals(that.binaryData)) return false;
if (fullText != null ? !fullText.equals(that.fullText) : that.fullText != null) return false;
+ if (originalEntityCreationTime != null ? !originalEntityCreationTime.equals(that.originalEntityCreationTime)
+ : that.originalEntityCreationTime != null) return false;
if (createdTime != null ? !createdTime.equals(that.createdTime) : that.createdTime != null) return false;
if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
if (ownerId != null ? !ownerId.equals(that.ownerId) : that.ownerId != null) return false;
@@ -181,6 +194,7 @@ public class EntityEntity {
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (binaryData != null ? binaryData.hashCode() : 0);
result = 31 * result + (fullText != null ? fullText.hashCode() : 0);
+ result = 31 * result + (originalEntityCreationTime != null ? originalEntityCreationTime.hashCode() : 0);
result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0);
return result;
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
index a53a6a2..9f5a706 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
@@ -121,8 +121,8 @@ public abstract class AbstractRepository<T, E, Id> {
return gatewayList;
}
- private String getSelectQuery(Map<String, String> filters){
- String query = "SELECT p from " + dbEntityGenericClass.getSimpleName() + " as p";
+ public String getSelectQuery(Map<String, String> filters){
+ String query = "SELECT DISTINCT p from " + dbEntityGenericClass.getSimpleName() + " as p";
if(filters != null && filters.size() != 0){
query += " WHERE ";
for(String k : filters.keySet()){
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
index a762f00..6d60aa9 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class EntityRepository extends AbstractRepository<Entity, EntityEntity, EntityPK> {
private final static Logger logger = LoggerFactory.getLogger(EntityRepository.class);
@@ -51,7 +52,7 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, E
groupIdString += groupId + "','";
groupIdString = groupIdString.substring(0, groupIdString.length()-2);
- String query = "SELECT E FROM " + EntityEntity.class.getSimpleName() + " E, " + SharingEntity.class.getSimpleName() + " S WHERE " +
+ String query = "SELECT DISTINCT E FROM " + EntityEntity.class.getSimpleName() + " E, " + SharingEntity.class.getSimpleName() + " S WHERE " +
"E." + DBConstants.EntityTable.ENTITY_ID + " = S." + DBConstants.SharingTable.ENTITY_ID + " AND " +
"E." + DBConstants.EntityTable.DOMAIN_ID + " = S." + DBConstants.SharingTable.DOMAIN_ID + " AND " +
"E." + DBConstants.EntityTable.DOMAIN_ID + " = '" + domainId + "' AND " +
@@ -63,9 +64,11 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, E
query += "E." + DBConstants.EntityTable.NAME + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
}else if(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)){
query += "E." + DBConstants.EntityTable.DESCRIPTION + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
+ }else if(searchCriteria.getSearchField().equals(EntitySearchField.PERMISSION_TYPE_ID)){
+ query += "S." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = '" + searchCriteria.getValue() + "' AND ";
}else if(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)){
query += "E." + DBConstants.EntityTable.FULL_TEXT + " LIKE '%" + searchCriteria.getValue() + "%' AND ";
- }else if(searchCriteria.getSearchField().equals(EntitySearchField.PRRENT_ENTITY_ID)){
+ }else if(searchCriteria.getSearchField().equals(EntitySearchField.PARRENT_ENTITY_ID)){
query += "E." + DBConstants.EntityTable.PARENT_ENTITY_ID + " = '" + searchCriteria.getValue() + "' AND ";
}else if(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_TIME)){
if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
@@ -84,6 +87,20 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, E
query = query.substring(0, query.length() - 5);
return select(query, offset, limit);
+ }
+
+ public String getSelectQuery(Map<String, String> filters){
+ String query = "SELECT p from " + EntityEntity.class.getSimpleName() + " as p";
+ if(filters != null && filters.size() != 0){
+ query += " WHERE ";
+ for(String k : filters.keySet()){
+ query += "p." + k + " = '" + filters.get(k) + "' AND ";
+ }
+ query = query.substring(0, query.length()-5);
+ }
+
+ query += " ORDER BY p."+DBConstants.EntityTable.ORIGINAL_ENTITY_CREATION_TIME+" DESC";
+ return query;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
index ccf27cb..087cc72 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/GroupMembershipRepository.java
@@ -36,7 +36,7 @@ public class GroupMembershipRepository extends AbstractRepository<GroupMembershi
}
public List<User> getAllChildUsers(String domainId, String groupId) throws SharingRegistryException {
- String queryString = "SELECT U FROM " + UserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName()
+ String queryString = "SELECT DISTINCT U FROM " + UserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName()
+ " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = U." + DBConstants.UserTable.USER_ID + " AND " +
"GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = U." + DBConstants.UserTable.DOMAIN_ID + " AND " +
"GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + "='" + domainId + "' AND "+
@@ -48,7 +48,7 @@ public class GroupMembershipRepository extends AbstractRepository<GroupMembershi
}
public List<UserGroup> getAllChildGroups(String domainId, String groupId) throws SharingRegistryException {
- String queryString = "SELECT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
+ String queryString = "SELECT DISTINCT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
+ " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
"GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " +
"GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"='"+domainId + "' AND "+
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
index 1237808..a9a6b5d 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/SharingRepository.java
@@ -50,7 +50,7 @@ public class SharingRepository extends AbstractRepository<Sharing, SharingEntity
}
public List<Sharing> getCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException {
- String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
+ String query = "SELECT DISTINCT p from " + SharingEntity.class.getSimpleName() + " as p";
query += " WHERE ";
query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = '" + domainId + "' AND ";
query += "p." + DBConstants.SharingTable.ENTITY_ID + " = '" + entityId + "' AND ";
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
index c86bb22..778ecde 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserGroupRepository.java
@@ -40,7 +40,7 @@ public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroup
}
public List<UserGroup> getAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
- String query = "SELECT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
+ String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
query += " WHERE ";
query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
index 6df5d70..8501d94 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/UserRepository.java
@@ -41,7 +41,7 @@ public class UserRepository extends AbstractRepository<User, UserEntity, UserPK>
public List<User> getAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
- String query = "SELECT u from " + UserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s";
+ String query = "SELECT DISTINCT u from " + UserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s";
query += " WHERE ";
query += "u." + DBConstants.UserTable.USER_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
query += "u." + DBConstants.UserTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
index 00dd367..b269ce1 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DBConstants.java
@@ -90,6 +90,7 @@ public class DBConstants {
public static final String CREATED_TIME = "createdTime";
public static final String UPDATED_TIME = "updatedTime";
public static final String DOMAIN_ID = "domainId";
+ public static final String ORIGINAL_ENTITY_CREATION_TIME = "originalEntityCreationTime";
}
public static class SharingTable {
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
index 5aa423c..5fe5e47 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/utils/DatabaseCreator.java
@@ -265,9 +265,9 @@ public class DatabaseCreator {
logger.info("Script file not found at " + dbscriptName + ". Uses default database script file");
DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
if(databaseType.equals(DatabaseType.derby)){
- is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-derby.sql");
+ is = DatabaseCreator.class.getClassLoader().getResourceAsStream("sharing-registry-derby.sql");
}else if(databaseType.equals(DatabaseType.mysql)){
- is = DatabaseCreator.class.getClassLoader().getResourceAsStream("experiment-mysql.sql");
+ is = DatabaseCreator.class.getClassLoader().getResourceAsStream("sharing-registry-mysql.sql");
}
}
reader = new BufferedReader(new InputStreamReader(is));
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/ServerMain.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/ServerMain.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/ServerMain.java
index 54e1722..a34f8c8 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/ServerMain.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/ServerMain.java
@@ -55,15 +55,19 @@ public class ServerMain {
serverStartedFile.deleteOnExit();
new RandomAccessFile(serverStartedFile, "rw").getChannel().lock();
} catch (FileNotFoundException e) {
- logger.error(e.getMessage(), e);
+ logger.warn(e.getMessage(), e);
} catch (IOException e) {
- logger.error(e.getMessage(), e);
+ logger.warn(e.getMessage(), e);
}
}
private static String getServerStartedFileName() {
- return new File(new File(System.getenv("" +
- "SHARING_REGISTRY_HOME"), "bin"), serverStartedFileNamePrefix + "_" + Integer.toString(serverPID)).toString();
+ String SHARING_REGISTRY_HOME = System.getenv("" +"SHARING_REGISTRY_HOME");
+ if(SHARING_REGISTRY_HOME==null)
+ SHARING_REGISTRY_HOME = "/tmp";
+ else
+ SHARING_REGISTRY_HOME = SHARING_REGISTRY_HOME + "bin";
+ return new File(SHARING_REGISTRY_HOME, serverStartedFileNamePrefix + "_" + Integer.toString(serverPID)).toString();
}
private static int getPID() {
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
index 5dc3dbc..4f88e16 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -67,6 +67,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
*/
@Override
public String createDomain(Domain domain) throws SharingRegistryException, TException {
+ domain.setDomainId(domain.name);
if(domainRepository.get(domain.domainId) != null)
throw new SharingRegistryException("There exist domain with given domain id");
@@ -76,7 +77,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
//create the global permission for the domain
PermissionType permissionType = new PermissionType();
- permissionType.setPermissionTypeId(domain.domainId+":"+ OWNER_PERMISSION_NAME);
+ permissionType.setPermissionTypeId(OWNER_PERMISSION_NAME);
permissionType.setDomainId(domain.domainId);
permissionType.setName(OWNER_PERMISSION_NAME);
permissionType.setDescription("GLOBAL permission to " + domain.domainId);
@@ -118,7 +119,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
* *
*/
@Override
- public String registerUser(User user) throws SharingRegistryException, TException {
+ public String createUser(User user) throws SharingRegistryException, TException {
UserPK userPK = new UserPK();
userPK.setUserId(user.getUserId());
userPK.setDomainId(user.domainId);
@@ -137,7 +138,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
userGroup.setOwnerId(user.userId);
userGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
userGroup.setGroupCardinality(GroupCardinality.SINGLE_USER);
- createGroup(userGroup);
+ userGroupRepository.create(userGroup);
return user.userId;
}
@@ -203,10 +204,13 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
userGroupPK.setDomainId(group.domainId);
if(userGroupRepository.get(userGroupPK) != null)
throw new SharingRegistryException("There exist group with given group id");
-
+ //Client created groups are always of type MULTI_USER
+ group.setGroupCardinality(GroupCardinality.MULTI_USER);
group.setCreatedTime(System.currentTimeMillis());
group.setUpdatedTime(System.currentTimeMillis());
userGroupRepository.create(group);
+
+ addUsersToGroup(group.domainId, Arrays.asList(group.ownerId), group.groupId);
return group.groupId;
}
@@ -217,8 +221,14 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
userGroupPK.setGroupId(group.groupId);
userGroupPK.setDomainId(group.domainId);
UserGroup oldGroup = userGroupRepository.get(userGroupPK);
+ //Client created groups are always of type MULTI_USER
+ group.setGroupCardinality(GroupCardinality.MULTI_USER);
group.setCreatedTime(oldGroup.createdTime);
group = getUpdatedObject(oldGroup, group);
+
+ if(!group.ownerId.equals(oldGroup.ownerId))
+ throw new SharingRegistryException("Group owner cannot be changed");
+
userGroupRepository.update(group);
return true;
}
@@ -427,7 +437,7 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
* *
*/
@Override
- public String registerEntity(Entity entity) throws SharingRegistryException, TException {
+ public String createEntity(Entity entity) throws SharingRegistryException, TException {
EntityPK entityPK = new EntityPK();
entityPK.setDomainId(entity.domainId);
entityPK.setEntityId(entity.entityId);
@@ -444,11 +454,14 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
user.setDomainId(entity.domainId);
user.setUserName(user.userId.split("@")[0]);
- registerUser(user);
+ createUser(user);
}
-
entity.setCreatedTime(System.currentTimeMillis());
entity.setUpdatedTime(System.currentTimeMillis());
+
+ if(entity.originalEntityCreationTime==0){
+ entity.originalEntityCreationTime = entity.createdTime;
+ }
entityRepository.create(entity);
//Assigning global permission for the owner
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
index 0b5167a..923894e 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
+++ b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
@@ -101,6 +101,7 @@ CREATE TABLE ENTITY (
DESCRIPTION VARCHAR(255),
BINARY_DATA BLOB,
FULL_TEXT CLOB,
+ ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
CREATED_TIME BIGINT NOT NULL,
UPDATED_TIME BIGINT NOT NULL,
PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
index ce7a9bf..9bfe64a 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
+++ b/modules/sharing-registry/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
@@ -101,6 +101,7 @@ CREATE TABLE ENTITY (
DESCRIPTION VARCHAR(255),
BINARY_DATA BLOB,
FULL_TEXT TEXT,
+ ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
CREATED_TIME BIGINT NOT NULL,
UPDATED_TIME BIGINT NOT NULL,
PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
index 499fc88..d11e744 100644
--- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
@@ -71,7 +71,7 @@ public class SharingRegistryServerHandlerTest {
user1.setCreatedTime(System.currentTimeMillis());
user1.setUpdatedTime(System.currentTimeMillis());
- Assert.assertNotNull(sharingRegistryServerHandler.registerUser(user1));
+ Assert.assertNotNull(sharingRegistryServerHandler.createUser(user1));
User user2 = new User();
String userName2 = "test-user-2." + System.currentTimeMillis();
@@ -82,7 +82,7 @@ public class SharingRegistryServerHandlerTest {
user2.setCreatedTime(System.currentTimeMillis());
user2.setUpdatedTime(System.currentTimeMillis());
- Assert.assertNotNull(sharingRegistryServerHandler.registerUser(user2));
+ Assert.assertNotNull(sharingRegistryServerHandler.createUser(user2));
User user3 = new User();
String userName3 = "test-user-3." + System.currentTimeMillis();
@@ -93,7 +93,7 @@ public class SharingRegistryServerHandlerTest {
user3.setCreatedTime(System.currentTimeMillis());
user3.setUpdatedTime(System.currentTimeMillis());
- Assert.assertNotNull(sharingRegistryServerHandler.registerUser(user3));
+ Assert.assertNotNull(sharingRegistryServerHandler.createUser(user3));
Assert.assertTrue(sharingRegistryServerHandler.getUsers(domainId, 0, 10).size() > 0);
@@ -205,7 +205,7 @@ public class SharingRegistryServerHandlerTest {
entity1.setCreatedTime(System.currentTimeMillis());
entity1.setUpdatedTime(System.currentTimeMillis());
- String entityId1 = sharingRegistryServerHandler.registerEntity(entity1);
+ String entityId1 = sharingRegistryServerHandler.createEntity(entity1);
Assert.assertNotNull(entityId1);
Entity entity2 = new Entity();
@@ -220,7 +220,7 @@ public class SharingRegistryServerHandlerTest {
entity2.setCreatedTime(System.currentTimeMillis());
entity2.setUpdatedTime(System.currentTimeMillis());
- String entityId2 = sharingRegistryServerHandler.registerEntity(entity2);
+ String entityId2 = sharingRegistryServerHandler.createEntity(entity2);
Assert.assertNotNull(entityId2);
Entity entity3 = new Entity();
@@ -235,7 +235,7 @@ public class SharingRegistryServerHandlerTest {
entity3.setCreatedTime(System.currentTimeMillis());
entity3.setUpdatedTime(System.currentTimeMillis());
- String entityId3 = sharingRegistryServerHandler.registerEntity(entity3);
+ String entityId3 = sharingRegistryServerHandler.createEntity(entity3);
Assert.assertNotNull(entityId3);
sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId1, Arrays.asList(userId2), permissionTypeId1, true);
@@ -253,7 +253,7 @@ public class SharingRegistryServerHandlerTest {
entity4.setCreatedTime(System.currentTimeMillis());
entity4.setUpdatedTime(System.currentTimeMillis());
- String entityId4 = sharingRegistryServerHandler.registerEntity(entity4);
+ String entityId4 = sharingRegistryServerHandler.createEntity(entity4);
Assert.assertNotNull(entityId4);
Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId4, permissionTypeId1));
http://git-wip-us.apache.org/repos/asf/airavata/blob/273d074a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
index 3357eb5..c05924a 100644
--- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
@@ -20,27 +20,36 @@
*/
package org.apache.airavata.sharing.registry;
-import org.apache.airavata.sharing.registry.models.Domain;
-import org.apache.airavata.sharing.registry.models.User;
+import org.apache.airavata.sharing.registry.models.*;
+import org.apache.airavata.sharing.registry.server.ServerMain;
import org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
-import org.junit.Ignore;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
+
public class SharingRegistryServiceTest {
private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServiceTest.class);
+ @BeforeClass
+ public static void setUp() throws InterruptedException {
+ ServerMain serverMain = new ServerMain();
+ serverMain.main(new String[]{});
+ Thread.sleep(1000*2);
+ }
+
@Test
- @Ignore("Test is only for demonstration purposes")
public void test() throws TException {
- String serverHost = "gw56.iu.xsede.org";
+ String serverHost = "localhost";
int serverPort = 7878;
TTransport transport = new TSocket(serverHost, serverPort);
@@ -56,29 +65,213 @@ public class SharingRegistryServiceTest {
String domainId = sharingServiceClient.createDomain(domain);
- User user = new User();
- String userName = "test-user";
- String userId1 = userName + "@" + domainId;
+ User user1 = new User();
+ //required
+ user1.setUserId("test-user-1");
+ //required
+ user1.setUserName("test-user-1");
+ //required
+ user1.setDomainId(domainId);
+ //required
+ user1.setFirstName("John");
+ //required
+ user1.setLastName("Doe");
+ //required
+ user1.setEmail("john.doe@abc.com");
+ //optional - this should be bytes of the users image icon
+ //byte[] icon1 = new byte[10];
+ //user1.setIcon(icon1);
+
+ sharingServiceClient.createUser(user1);
+
+ User user2 = new User();
+ //required
+ user2.setUserId("test-user-2");
+ //required
+ user2.setUserName("test-user-2");
+ //required
+ user2.setDomainId(domainId);
+ //required
+ user2.setFirstName("John");
+ //required
+ user2.setLastName("Doe");
+ //required
+ user2.setEmail("john.doe@abc.com");
+ //optional - this should be bytes of the users image icon
+ //byte[] icon2 = new byte[10];
+ //user2.setIcon(icon2);
+
+ sharingServiceClient.createUser(user2);
+
+ User user3 = new User();
//required
- user.setUserId(userId1);
+ user3.setUserId("test-user-3");
//required
- user.setUserName(userName);
+ user3.setUserName("test-user-3");
//required
- user.setDomainId(domainId);
+ user3.setDomainId(domainId);
//required
- user.setFirstName("John");
+ user3.setFirstName("John");
//required
- user.setLastName("Doe");
+ user3.setLastName("Doe");
//required
- user.setEmail("john.doe@abc.com");
+ user3.setEmail("john.doe@abc.com");
//optional - this should be bytes of the users image icon
- byte[] icon = new byte[10];
- user.setIcon(icon);
+ //byte[] icon3 = new byte[10];
+ //user3.setIcon(icon3);
+
+ sharingServiceClient.createUser(user3);
+
+ UserGroup userGroup1 = new UserGroup();
+ //required
+ userGroup1.setGroupId("test-group-1");
+ //required
+ userGroup1.setDomainId(domainId);
+ //required
+ userGroup1.setName("test-group-1");
+ //optional
+ userGroup1.setDescription("test group description");
+ //required
+ userGroup1.setOwnerId("test-user-1");
+ //required
+ userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
+
+ sharingServiceClient.createGroup(userGroup1);
+
+ UserGroup userGroup2 = new UserGroup();
+ //required
+ userGroup2.setGroupId("test-group-2");
+ //required
+ userGroup2.setDomainId(domainId);
+ //required
+ userGroup2.setName("test-group-2");
+ //optional
+ userGroup2.setDescription("test group description");
+ //required
+ userGroup2.setOwnerId("test-user-2");
+ //required
+ userGroup2.setGroupType(GroupType.USER_LEVEL_GROUP);
+
+ sharingServiceClient.createGroup(userGroup2);
+
+ sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-3"), "test-group-2");
+
+ sharingServiceClient.addChildGroupsToParentGroup(domainId, Arrays.asList("test-group-2"), "test-group-1");
+
+ PermissionType permissionType1 = new PermissionType();
+ //required
+ permissionType1.setPermissionTypeId("READ");
+ //required
+ permissionType1.setDomainId(domainId);
+ //required
+ permissionType1.setName("READ");
+ //optional
+ permissionType1.setDescription("READ description");
+ sharingServiceClient.createPermissionType(permissionType1);
+
+ PermissionType permissionType2 = new PermissionType();
+ permissionType2.setPermissionTypeId("WRITE");
+ permissionType2.setDomainId(domainId);
+ permissionType2.setName("WRITE");
+ permissionType2.setDescription("WRITE description");
+ sharingServiceClient.createPermissionType(permissionType2);
+
+ EntityType entityType1 = new EntityType();
+ //required
+ entityType1.setEntityTypeId("PROJECT");
+ //required
+ entityType1.setDomainId(domainId);
+ //required
+ entityType1.setName("PROJECT");
+ //optional
+ entityType1.setDescription("PROJECT entity type description");
+ sharingServiceClient.createEntityType(entityType1);
+
+ EntityType entityType2 = new EntityType();
+ entityType2.setEntityTypeId("EXPERIMENT");
+ entityType2.setDomainId(domainId);
+ entityType2.setName("EXPERIMENT");
+ entityType2.setDescription("EXPERIMENT entity type");
+ sharingServiceClient.createEntityType(entityType2);
+
+
+ //Creating entities
+ Entity entity1 = new Entity();
+ //required
+ entity1.setEntityId("test-project-1");
+ //required
+ entity1.setDomainId(domainId);
+ //required
+ entity1.setEntityTypeId("PROJECT");
+ //required
+ entity1.setOwnerId("test-user-1");
+ //required
+ entity1.setName("test-project-1");
+ //optional
+ entity1.setDescription("test project 1 description");
+ //optional
+ entity1.setFullText("test project 1 stampede gaussian seagrid");
+ //optional - If not set this will be default to current system time
+ entity1.setOriginalEntityCreationTime(System.currentTimeMillis());
+ sharingServiceClient.createEntity(entity1);
+
+ Entity entity2 = new Entity();
+ entity2.setEntityId("test-experiment-1");
+ entity2.setDomainId(domainId);
+ entity2.setEntityTypeId("EXPERIMENT");
+ entity2.setOwnerId("test-user-1");
+ entity2.setName("test-experiment-1");
+ entity2.setDescription("test experiment 1 description");
+ entity2.setParentEntityId("test-project-1");
+ entity2.setFullText("test experiment 1 benzene");
+ sharingServiceClient.createEntity(entity2);
+
+ Entity entity3 = new Entity();
+ entity3.setEntityId("test-experiment-2");
+ entity3.setDomainId(domainId);
+ entity3.setEntityTypeId("EXPERIMENT");
+ entity3.setOwnerId("test-user-1");
+ entity3.setName("test-experiment-2");
+ entity3.setDescription("test experiment 2 description");
+ entity3.setParentEntityId("test-project-1");
+ entity3.setFullText("test experiment 1 3-methyl 1-butanol");
+ sharingServiceClient.createEntity(entity3);
+
+ sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
+ sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true);
+
+ //true
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-project-1", "WRITE"));
+ //true
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "WRITE"));
+ //true
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "WRITE"));
+
+ //false
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "READ"));
+ //true
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "READ"));
+
+ //false
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-project-1", "READ"));
+ //true
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "READ"));
+ //false
+ System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "WRITE"));
+
+ ArrayList<SearchCriteria> filters = new ArrayList<>();
+ SearchCriteria searchCriteria = new SearchCriteria();
+ searchCriteria.setSearchCondition(SearchCondition.LIKE);
+ searchCriteria.setValue("experiment");
+ searchCriteria.setSearchField(EntitySearchField.NAME);
+ filters.add(searchCriteria);
- //can be manually set. otherwise will be set to the current time by the system
- user.setCreatedTime(System.currentTimeMillis());
- user.setUpdatedTime(System.currentTimeMillis());
+ searchCriteria = new SearchCriteria();
+ searchCriteria.setSearchCondition(SearchCondition.EQUAL);
+ searchCriteria.setValue("READ");
+ searchCriteria.setSearchField(EntitySearchField.PERMISSION_TYPE_ID);
+ filters.add(searchCriteria);
- sharingServiceClient.registerUser(user);
+ System.out.println(sharingServiceClient.searchEntities(domainId, "test-user-2", "EXPERIMENT", filters, 0, -1).size());
}
}
\ No newline at end of file