This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch group-based-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 355d8d7daa8227143a133308e6ff6fc77e7d5521
Merge: 7d696e0 e520347
Author: Marcus Christie <machris...@apache.org>
AuthorDate: Thu Apr 12 14:45:46 2018 -0400

    Merge branch 'registry-refactoring' into group-based-auth

 .../StorageResourceDescription.java                | 204 +++++++++++++-
 .../model/data/movement/DataMovementInterface.java | 307 ++++++++++++++++++++-
 .../appcatalog/StorageInterfaceEntity.java         |  24 +-
 .../entities/appcatalog/StorageInterfacePK.java    |   1 +
 .../entities/appcatalog/StorageResourceEntity.java |  50 ++--
 .../appcatalog/ComputeResourceRepository.java      |  10 +-
 .../appcatalog/StorageResourceRepository.java      | 210 ++++++++++++++
 .../airavata/registry/core/utils/DBConstants.java  |   4 +
 .../utils/DozerConverter/StorageDateConverter.java |  34 +++
 .../registry/core/utils/ObjectMapperSingleton.java |   9 +-
 .../registry/core/utils/QueryConstants.java        |   5 +
 .../src/main/resources/dozer_mapping.xml           |  18 ++
 .../appcatalog/StorageResourceRepositoryTest.java  | 151 ++++++++++
 .../api/service/handler/RegistryServerHandler.java |  33 ++-
 .../data_movement_models.thrift                    |   3 +
 .../storage_resource_model.thrift                  |   2 +
 16 files changed, 1008 insertions(+), 57 deletions(-)

diff --cc 
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
index 6ba4835,e7fc469..8cc4444
--- 
a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
+++ 
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
@@@ -33,93 -13,34 +33,98 @@@ public interface QueryConstants 
      String FIND_ALL_USER_PROFILES_BY_GATEWAY_ID = "SELECT u FROM 
UserProfileEntity u " +
              "where u.gatewayId LIKE :"+ 
UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
  
 +    // Application Deployment Queries
 +    String FIND_APPLICATION_DEPLOYMENTS_FOR_GATEWAY_ID = "SELECT AD FROM " + 
ApplicationDeploymentEntity.class.getSimpleName() + " AD " +
 +            "WHERE AD.gatewayId LIKE :" + 
DBConstants.ApplicationDeployment.GATEWAY_ID;
 +    String FIND_APPLICATION_DEPLOYMENTS_FOR_APPLICATION_MODULE_ID = "SELECT 
AD FROM " + ApplicationDeploymentEntity.class.getSimpleName() + " AD " +
 +            "WHERE AD.appModuleId LIKE :" + 
DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID;
 +    String FIND_APPLICATION_DEPLOYMENTS_FOR_COMPUTE_HOST_ID = "SELECT AD FROM 
" + ApplicationDeploymentEntity.class.getSimpleName() + " AD " +
 +            "WHERE AD.computeHostId LIKE :" + 
DBConstants.ApplicationDeployment.COMPUTE_HOST_ID;
 +    String GET_ALL_APPLICATION_DEPLOYMENTS = "SELECT AD FROM " + 
ApplicationDeploymentEntity.class.getSimpleName() + " AD";
 +    String FIND_ACCESSIBLE_APPLICATION_DEPLOYMENTS = "SELECT AD FROM " + 
ApplicationDeploymentEntity.class.getSimpleName() + " AD " +
 +            "WHERE AD.gatewayId LIKE :" + 
DBConstants.ApplicationDeployment.GATEWAY_ID + " AND AD.appDeploymentId IN :" +
 +            
DBConstants.ApplicationDeployment.ACCESSIBLE_APPLICATION_DEPLOYMENT_IDS + " AND 
AD.computeHostId IN :" +
 +            DBConstants.ApplicationDeployment.ACCESSIBLE_COMPUTE_HOST_IDS;
 +
 +    // Application Module Queries
 +    String FIND_APPLICATION_MODULES_FOR_GATEWAY_ID = "SELECT AM FROM " + 
ApplicationModuleEntity.class.getSimpleName() + " AM " +
 +            "WHERE AM.gatewayId LIKE :" + 
DBConstants.ApplicationModule.GATEWAY_ID;
 +    String FIND_APPLICATION_MODULES_FOR_APPLICATION_MODULE_NAME = "SELECT AM 
FROM " + ApplicationModuleEntity.class.getSimpleName() + " AM " +
 +            "WHERE AM.appModuleName LIKE :" + 
DBConstants.ApplicationModule.APPLICATION_MODULE_NAME;
 +    String FIND_ACCESSIBLE_APPLICATION_MODULES = "SELECT AM FROM " + 
ApplicationModuleEntity.class.getSimpleName() + " AM " +
 +            ", " + ApplicationDeploymentEntity.class.getSimpleName() + " AD 
WHERE AM.appModuleId = AD.appModuleId AND AM.gatewayId LIKE :" +
 +            DBConstants.ApplicationModule.GATEWAY_ID + " AND 
AD.appDeploymentId IN :" + 
DBConstants.ApplicationDeployment.ACCESSIBLE_APPLICATION_DEPLOYMENT_IDS +
 +            " AND AD.computeHostId IN :" + 
DBConstants.ApplicationDeployment.ACCESSIBLE_COMPUTE_HOST_IDS;
 +
 +    // Application Interface Queries
 +    String FIND_APPLICATION_INTERFACES_FOR_GATEWAY_ID = "SELECT AI FROM " + 
ApplicationInterfaceEntity.class.getSimpleName() + " AI " +
 +            "WHERE AI.gatewayId LIKE :" + 
DBConstants.ApplicationInterface.GATEWAY_ID;
 +    String FIND_APPLICATION_INTERFACES_FOR_APPLICATION_NAME = "SELECT AI FROM 
" + ApplicationInterfaceEntity.class.getSimpleName() + " AI " +
 +            "WHERE AI.applicationName LIKE :" + 
DBConstants.ApplicationInterface.APPLICATION_NAME;
 +    String GET_ALL_APPLICATION_INTERFACES = "SELECT AI FROM " + 
ApplicationInterfaceEntity.class.getSimpleName() + " AI";
 +
 +    // Application Inputs Queries
 +    String FIND_APPLICATION_INPUTS = "SELECT AI FROM " + 
ApplicationInputEntity.class.getSimpleName() + " AI " +
 +            "WHERE AI.interfaceId LIKE :" + 
DBConstants.ApplicationInput.APPLICATION_INTERFACE_ID;
 +
 +    // Application Outputs Queries
 +    String FIND_APPLICATION_OUTPUTS = "SELECT AI FROM " + 
ApplicationOutputEntity.class.getSimpleName() + " AI " +
 +            "WHERE AI.interfaceId LIKE :" + 
DBConstants.ApplicationOutput.APPLICATION_INTERFACE_ID;
 +
      String FIND_ALL_GATEWAY_PROFILES = "SELECT G FROM " + 
GatewayProfileEntity.class.getSimpleName() + " G";
      String FIND_ALL_COMPUTE_RESOURCE_PREFERENCES = "SELECT DISTINCT CR FROM " 
+ ComputeResourcePreferenceEntity.class.getSimpleName() + " CR " +
 -            "WHERE CR.gatewayId LIKE : " + 
DBConstants.ComputeResourcePreference.GATEWAY_ID;
 +            "WHERE CR.gatewayId LIKE :" + 
DBConstants.ComputeResourcePreference.GATEWAY_ID;
      String FIND_ALL_STORAGE_RESOURCE_PREFERENCES = "SELECT DISTINCT S FROM " 
+ StoragePreferenceEntity.class.getSimpleName() + " S " +
 -            "WHERE S.gatewayId LIKE : " + 
DBConstants.StorageResourcePreference.GATEWAY_ID;
 +            "WHERE S.gatewayId LIKE :" + 
DBConstants.StorageResourcePreference.GATEWAY_ID;
  
      String FIND_COMPUTE_RESOURCE = "SELECT DISTINCT CR FROM " + 
ComputeResourceEntity.class.getSimpleName() + " CR " +
 -            "WHERE CR.hostName LIKE : " + 
DBConstants.ComputeResource.HOST_NAME;
 +            "WHERE CR.hostName LIKE :" + 
DBConstants.ComputeResource.HOST_NAME;
      String FIND_ALL_COMPUTE_RESOURCES = "SELECT CR FROM " + 
ComputeResourceEntity.class.getSimpleName() + " CR";
      String GET_FILE_SYSTEM = "SELECT DISTINCT FS FROM " + 
ComputeResourceFileSystemEntity.class.getSimpleName() + " FS " +
 -            "WHERE FS.computeResourceId LIKE: " + 
DBConstants.ComputeResource.COMPUTE_RESOURCE_ID;
 +            "WHERE FS.computeResourceId LIKE :" + 
DBConstants.ComputeResource.COMPUTE_RESOURCE_ID;
      String GET_JOB_MANAGER_COMMAND = "SELECT DISTINCT JM FROM " + 
JobManagerCommandEntity.class.getSimpleName() + " JM " +
 -            "WHERE JM.id.resourceJobManagerId LIKE: " + 
DBConstants.ResourceJobManager.RESOURCE_JOB_MANAGER_ID;
 +            "WHERE JM.resourceJobManagerId LIKE :" + 
DBConstants.ResourceJobManager.RESOURCE_JOB_MANAGER_ID;
      String GET_PARALLELISM_PREFIX = "SELECT DISTINCT PF FROM " + 
ParallelismCommandEntity.class.getSimpleName() + " PF " +
 -            "WHERE PF.id.resourceJobManagerId LIKE: " + 
DBConstants.ResourceJobManager.RESOURCE_JOB_MANAGER_ID;
 +            "WHERE PF.resourceJobManagerId LIKE :" + 
DBConstants.ResourceJobManager.RESOURCE_JOB_MANAGER_ID;
  
 +    String FIND_ACCESSIBLE_GROUP_RESOURCE_PROFILES = "SELECT G FROM " + 
GroupResourceProfileEntity.class.getSimpleName() + " G " +
 +            "WHERE G.gatewayId LIKE :" + 
DBConstants.GroupResourceProfile.GATEWAY_ID + " AND G.groupResourceProfileId IN 
:"
 +            + DBConstants.GroupResourceProfile.ACCESSIBLE_GROUP_RESOURCE_IDS;
      String FIND_ALL_GROUP_RESOURCE_PROFILES = "SELECT G FROM " + 
GroupResourceProfileEntity.class.getSimpleName() + " G " +
 -            "WHERE G.gatewayId LIKE : " + 
DBConstants.GroupResourceProfile.GATEWAY_ID;
 +            "WHERE G.gatewayId LIKE :" + 
DBConstants.GroupResourceProfile.GATEWAY_ID;
      String FIND_ALL_GROUP_COMPUTE_PREFERENCES = "SELECT GC FROM "+ 
GroupComputeResourcePrefEntity.class.getSimpleName() + " GC " +
 -            "WHERE GC.groupResourceProfileId LIKE : " + 
DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
 +            "WHERE GC.groupResourceProfileId LIKE :" + 
DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
      String FIND_ALL_GROUP_BATCH_QUEUE_RESOURCE_POLICY = "SELECT BQ FROM "+ 
BatchQueueResourcePolicyEntity.class.getSimpleName() + " BQ " +
 -            "WHERE BQ.groupResourceProfileId LIKE : " + 
DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
 +            "WHERE BQ.groupResourceProfileId LIKE :" + 
DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
      String FIND_ALL_GROUP_COMPUTE_RESOURCE_POLICY = "SELECT CR FROM "+ 
ComputeResourcePolicyEntity.class.getSimpleName() + " CR " +
 -            "WHERE CR.groupResourceProfileId LIKE : " + 
DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
 +            "WHERE CR.groupResourceProfileId LIKE :" + 
DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
 +
 +    String GET_ALL_USER_RESOURCE_PROFILE = "SELECT URP FROM " + 
UserResourceProfileEntity.class.getSimpleName() + " URP";
 +    String GET_ALL_GATEWAY_ID = "SELECT DISTINCT URP FROM " + 
UserResourceProfileEntity.class.getSimpleName() + " URP " +
 +            "WHERE URP.gatewayId LIKE :" + 
DBConstants.UserResourceProfile.GATEWAY_ID;
 +
 +    String GET_ALL_USER_COMPUTE_RESOURCE_PREFERENCE = "SELECT UCRP FROM " + 
UserComputeResourcePreferenceEntity.class.getSimpleName() + " UCRP " +
 +            "WHERE UCRP.userId LIKE :" + 
DBConstants.UserComputeResourcePreference.USER_ID + " AND UCRP.gatewayId LIKE 
:" +
 +            DBConstants.UserComputeResourcePreference.GATEWAY_ID;
 +
 +    String GET_ALL_USER_STORAGE_PREFERENCE = "SELECT USP FROM " + 
UserStoragePreferenceEntity.class.getSimpleName() + " USP " +
 +            "WHERE USP.userId LIKE :" + 
DBConstants.UserStoragePreference.USER_ID + " AND USP.gatewayId LIKE :" +
 +            DBConstants.UserStoragePreference.GATEWAY_ID;
 +
 +    String FIND_ALL_CHILD_DATA_PRODUCTS = "SELECT DP FROM " + 
DataProductEntity.class.getSimpleName() + " DP " +
 +            "WHERE DP.parentProductUri LIKE :" + 
DBConstants.DataProduct.PARENT_PRODUCT_URI;
 +    String FIND_DATA_PRODUCT_BY_NAME = "SELECT DP FROM " + 
DataProductEntity.class.getSimpleName() + " DP " +
 +            "WHERE DP.gatewayId LIKE :" + DBConstants.DataProduct.GATEWAY_ID 
+ " AND DP.ownerName LIKE :" +
 +            DBConstants.DataProduct.OWNER_NAME + " AND dp.productName LIKE :" 
+ DBConstants.DataProduct.PRODUCT_NAME;
 +
 +    String GET_ALL_WORKFLOWS = "SELECT W FROM " + 
WorkflowEntity.class.getSimpleName() + " W " +
 +            "WHERE W.gatewayId LIKE :" + DBConstants.Workflow.GATEWAY_ID;
 +    String GET_WORKFLOW_GIVEN_NAME = "SELECT W FROM " + 
WorkflowEntity.class.getSimpleName() + " W " +
 +            "WHERE W.workflowName LIKE :" + 
DBConstants.Workflow.WORKFLOW_NAME;
  
+     String FIND_STORAGE_RESOURCE = "SELECT DISTINCT SR FROM " + 
StorageResourceEntity.class.getSimpleName() + " SR " +
+             "WHERE SR.hostName LIKE :" + 
DBConstants.StorageResource.HOST_NAME;
+     String FIND_ALL_STORAGE_RESOURCES = "SELECT SR FROM " + 
StorageResourceEntity.class.getSimpleName() + " SR";
+     String FIND_ALL_AVAILABLE_STORAGE_RESOURCES = "SELECT SR FROM " + 
StorageResourceEntity.class.getSimpleName() + " SR " +
+             "WHERE SR.enabled = TRUE";
  }
diff --cc 
modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
index c22436f,e100445..5cce58b
--- 
a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
+++ 
b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
@@@ -105,23 -68,8 +105,23 @@@ import org.apache.airavata.registry.cor
  import 
org.apache.airavata.registry.core.repositories.appcatalog.ComputeResourceRepository;
  import 
org.apache.airavata.registry.core.repositories.appcatalog.GroupResourceProfileRepository;
  import 
org.apache.airavata.registry.core.repositories.appcatalog.GwyResourceProfileRepository;
+ import 
org.apache.airavata.registry.core.repositories.appcatalog.StorageResourceRepository;
 -import org.apache.airavata.registry.cpi.*;
 +import 
org.apache.airavata.registry.core.repositories.appcatalog.UserResourceProfileRepository;
 +import 
org.apache.airavata.registry.core.repositories.replicacatalog.DataProductRepository;
 +import 
org.apache.airavata.registry.core.repositories.replicacatalog.DataReplicaLocationRepository;
 +import 
org.apache.airavata.registry.core.repositories.workflowcatalog.WorkflowRepository;
 +import org.apache.airavata.registry.core.utils.DBConstants;
- import org.apache.airavata.registry.cpi.AppCatalog;
 +import org.apache.airavata.registry.cpi.AppCatalogException;
 +import org.apache.airavata.registry.cpi.CompositeIdentifier;
 +import org.apache.airavata.registry.cpi.ComputeResource;
 +import org.apache.airavata.registry.cpi.ExpCatChildDataType;
 +import org.apache.airavata.registry.cpi.ExpCatParentDataType;
 +import org.apache.airavata.registry.cpi.ExperimentCatalog;
 +import org.apache.airavata.registry.cpi.ExperimentCatalogException;
 +import org.apache.airavata.registry.cpi.ExperimentCatalogModelType;
 +import org.apache.airavata.registry.cpi.RegistryException;
 +import org.apache.airavata.registry.cpi.ResultOrderType;
 +import org.apache.airavata.registry.cpi.WorkflowCatalogException;
  import org.apache.airavata.registry.cpi.utils.Constants;
  import org.apache.thrift.TException;
  import org.slf4j.Logger;
@@@ -138,13 -81,10 +138,13 @@@ public class RegistryServerHandler impl
      private final static Logger logger = 
LoggerFactory.getLogger(RegistryServerHandler.class);
  
      private ExperimentCatalog experimentCatalog;
--    private AppCatalog appCatalog;
 -    private ReplicaCatalog dataCatalog;
 -    private WorkflowCatalog workflowCatalog;
 -    StorageResourceRepository storageResourceRepository = new 
StorageResourceRepository();
 +    private ApplicationDeploymentRepository applicationDeploymentRepository = 
new ApplicationDeploymentRepository();
 +    private ApplicationInterfaceRepository applicationInterfaceRepository = 
new ApplicationInterfaceRepository();
 +    private UserResourceProfileRepository userResourceProfileRepository = new 
UserResourceProfileRepository();
 +    private DataProductRepository dataProductRepository = new 
DataProductRepository();
 +    private DataReplicaLocationRepository dataReplicaLocationRepository = new 
DataReplicaLocationRepository();
 +    private WorkflowRepository workflowRepository = new WorkflowRepository();
++    private StorageResourceRepository storageResourceRepository = new 
StorageResourceRepository();
  
      /**
       * Fetch Apache Registry API version
@@@ -2951,7 -2920,7 +2948,6 @@@
      @Override
      public boolean deleteDataMovementInterface(String resourceId, String 
dataMovementInterfaceId, DMType dmType) throws RegistryServiceException, 
TException {
          try {
--            appCatalog = RegistryFactory.getAppCatalog();
              switch (dmType){
                  case COMPUTE_RESOURCE:
                      new 
ComputeResourceRepository().removeDataMovementInterface(resourceId, 
dataMovementInterfaceId);
@@@ -3859,7 -3832,7 +3853,6 @@@
      public String createExperiment(String gatewayId, ExperimentModel 
experiment) throws RegistryServiceException, TException {
          try {
              experimentCatalog = 
RegistryFactory.getExperimentCatalog(gatewayId);
--            appCatalog = RegistryFactory.getAppCatalog();
              if (!validateString(experiment.getExperimentName())){
                  logger.error("Cannot create experiments with empty experiment 
name");
                  AiravataSystemException exception = new 
AiravataSystemException();
@@@ -4200,7 -4173,7 +4193,6 @@@
      public String addGateway(Gateway gateway) throws 
RegistryServiceException, DuplicateEntryException, TException {
          try {
              experimentCatalog = RegistryFactory.getDefaultExpCatalog();
--            appCatalog = RegistryFactory.getAppCatalog();
              if (!validateString(gateway.getGatewayId())){
                  logger.error("Gateway id cannot be empty...");
                  throw new 
AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
@@@ -4334,9 -4306,27 +4326,16 @@@
          
dataMovementInterface.setDataMovementInterfaceId(dataMovementInterfaceId);
          dataMovementInterface.setPriorityOrder(priorityOrder);
          dataMovementInterface.setDataMovementProtocol(protocolType);
-         return computeResource.addDataMovementProtocol(computeResourceId, 
dmType, dataMovementInterface);
+         if (dmType.equals(DMType.COMPUTE_RESOURCE)) {
+             return computeResource.addDataMovementProtocol(computeResourceId, 
dmType, dataMovementInterface);
+         }
+         else if (dmType.equals(DMType.STORAGE_RESOURCE)) {
+             dataMovementInterface.setStorageResourceId(computeResourceId);
+             return 
storageResourceRepository.addDataMovementInterface(dataMovementInterface);
+         }
+         return null;
      }
  
 -    private WorkflowCatalog getWorkflowCatalog() {
 -        if (workflowCatalog == null) {
 -            try {
 -                workflowCatalog = 
RegistryFactory.getAppCatalog().getWorkflowCatalog();
 -            } catch (Exception e) {
 -                logger.error("Unable to create Workflow Catalog", e);
 -            }
 -        }
 -        return workflowCatalog;
 -    }
 -
      /**
       * Register a User Resource Profile.
       *

-- 
To stop receiving notification emails like this one, please contact
machris...@apache.org.

Reply via email to