You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ya...@apache.org on 2025/11/10 23:43:04 UTC
(airavata) 14/24: update RegistryServerHandler
This is an automated email from the ASF dual-hosted git repository.
yasith pushed a commit to branch resource-mgmt-rest-api
in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 7e5c101d27a9475dd785f91f25ad06a4f288ab6e
Author: yasithdev <ya...@icloud.com>
AuthorDate: Mon Nov 10 18:39:59 2025 -0500
update RegistryServerHandler
---
.../api/service/handler/RegistryServerHandler.java | 3455 +++-----------------
.../apache/airavata/service/RegistryService.java | 2756 ++++++++++++++++
2 files changed, 3287 insertions(+), 2924 deletions(-)
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java b/airavata-api/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
index a3432e3f75..c6ef52e8e2 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
@@ -65,15 +65,8 @@ import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.api.RegistryService;
import org.apache.airavata.registry.api.exception.RegistryServiceException;
import org.apache.airavata.registry.api.registry_apiConstants;
-import org.apache.airavata.registry.core.entities.expcatalog.JobPK;
-import org.apache.airavata.registry.core.repositories.appcatalog.*;
-import org.apache.airavata.registry.core.repositories.expcatalog.*;
-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.*;
-import org.apache.airavata.registry.cpi.utils.Constants;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.apache.airavata.registry.cpi.RegistryException;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,41 +74,22 @@ import org.slf4j.LoggerFactory;
public class RegistryServerHandler implements RegistryService.Iface {
private static final Logger logger = LoggerFactory.getLogger(RegistryServerHandler.class);
- private ApplicationDeploymentRepository applicationDeploymentRepository = new ApplicationDeploymentRepository();
- private ApplicationInterfaceRepository applicationInterfaceRepository = new ApplicationInterfaceRepository();
- private StorageResourceRepository storageResourceRepository = new StorageResourceRepository();
- private UserResourceProfileRepository userResourceProfileRepository = new UserResourceProfileRepository();
- private GatewayRepository gatewayRepository = new GatewayRepository();
- private ProjectRepository projectRepository = new ProjectRepository();
- private NotificationRepository notificationRepository = new NotificationRepository();
- private ExperimentSummaryRepository experimentSummaryRepository = new ExperimentSummaryRepository();
- private ExperimentRepository experimentRepository = new ExperimentRepository();
- private ExperimentOutputRepository experimentOutputRepository = new ExperimentOutputRepository();
- private ExperimentStatusRepository experimentStatusRepository = new ExperimentStatusRepository();
- private ExperimentErrorRepository experimentErrorRepository = new ExperimentErrorRepository();
- private ProcessRepository processRepository = new ProcessRepository();
- private ProcessOutputRepository processOutputRepository = new ProcessOutputRepository();
- private ProcessWorkflowRepository processWorkflowRepository = new ProcessWorkflowRepository();
- private ProcessStatusRepository processStatusRepository = new ProcessStatusRepository();
- private ProcessErrorRepository processErrorRepository = new ProcessErrorRepository();
- private TaskRepository taskRepository = new TaskRepository();
- private TaskStatusRepository taskStatusRepository = new TaskStatusRepository();
- private TaskErrorRepository taskErrorRepository = new TaskErrorRepository();
- private JobRepository jobRepository = new JobRepository();
- private JobStatusRepository jobStatusRepository = new JobStatusRepository();
- private QueueStatusRepository queueStatusRepository = new QueueStatusRepository();
- private DataProductRepository dataProductRepository = new DataProductRepository();
- private DataReplicaLocationRepository dataReplicaLocationRepository = new DataReplicaLocationRepository();
- private WorkflowRepository workflowRepository = new WorkflowRepository();
- private GatewayGroupsRepository gatewayGroupsRepository = new GatewayGroupsRepository();
- private ParserRepository parserRepository = new ParserRepository();
- private ParserInputRepository parserInputRepository = new ParserInputRepository();
- private ParserOutputRepository parserOutputRepository = new ParserOutputRepository();
- private ParsingTemplateRepository parsingTemplateRepository = new ParsingTemplateRepository();
- private UserRepository userRepository = new UserRepository();
- private ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- private GatewayUsageReportingCommandRepository usageReportingCommandRepository =
- new GatewayUsageReportingCommandRepository();
+ private org.apache.airavata.service.RegistryService registryService = new org.apache.airavata.service.RegistryService();
+
+ // Helper method to convert domain exceptions to Thrift exceptions
+ private RegistryServiceException convertToRegistryServiceException(RegistryException e, String context) {
+ logger.error(context, e);
+ RegistryServiceException exception = new RegistryServiceException();
+ exception.setMessage(context + ". More info : " + e.getMessage());
+ return exception;
+ }
+
+ private RegistryServiceException convertToRegistryServiceException(AppCatalogException e, String context) {
+ logger.error(context, e);
+ RegistryServiceException exception = new RegistryServiceException();
+ exception.setMessage(context + ". More info : " + e.getMessage());
+ return exception;
+ }
/**
* Fetch Apache Registry API version
@@ -135,7 +109,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean isUserExists(String gatewayId, String userName) throws RegistryServiceException, TException {
try {
- return userRepository.isUserExists(gatewayId, userName);
+ return registryService.isUserExists(gatewayId, userName);
} catch (RegistryException e) {
logger.error("Error while verifying user", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -154,7 +128,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<String> getAllUsersInGateway(String gatewayId) throws RegistryServiceException, TException {
try {
- return userRepository.getAllUsernamesInGateway(gatewayId);
+ return registryService.getAllUsersInGateway(gatewayId);
} catch (RegistryException e) {
logger.error("Error while retrieving users", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -173,15 +147,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public Gateway getGateway(String gatewayId) throws RegistryServiceException, TException {
try {
- if (!gatewayRepository.isGatewayExist(gatewayId)) {
- logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
- throw exception;
- }
- Gateway gateway = gatewayRepository.getGateway(gatewayId);
- logger.debug("Airavata retrieved gateway with gateway id : " + gateway.getGatewayId());
- return gateway;
+ return registryService.getGateway(gatewayId);
} catch (RegistryException e) {
logger.error("Error while getting the gateway", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -200,15 +166,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteGateway(String gatewayId) throws RegistryServiceException, TException {
try {
- if (!gatewayRepository.isGatewayExist(gatewayId)) {
- logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
- throw exception;
- }
- gatewayRepository.removeGateway(gatewayId);
- logger.debug("Airavata deleted gateway with gateway id : " + gatewayId);
- return true;
+ return registryService.deleteGateway(gatewayId);
} catch (RegistryException e) {
logger.error("Error while deleting the gateway", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -223,9 +181,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<Gateway> getAllGateways() throws RegistryServiceException, TException {
try {
- List<Gateway> gateways = gatewayRepository.getAllGateways();
- logger.debug("Airavata retrieved all available gateways...");
- return gateways;
+ return registryService.getAllGateways();
} catch (RegistryException e) {
logger.error("Error while getting all the gateways", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -244,7 +200,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean isGatewayExist(String gatewayId) throws RegistryServiceException, TException {
try {
- return gatewayRepository.isGatewayExist(gatewayId);
+ return registryService.isGatewayExist(gatewayId);
} catch (RegistryException e) {
logger.error("Error while getting gateway", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -257,8 +213,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteNotification(String gatewayId, String notificationId)
throws RegistryServiceException, TException {
try {
- notificationRepository.deleteNotification(notificationId);
- return true;
+ return registryService.deleteNotification(gatewayId, notificationId);
} catch (RegistryException e) {
logger.error("Error while deleting notification", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -271,7 +226,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
public Notification getNotification(String gatewayId, String notificationId)
throws RegistryServiceException, TException {
try {
- return notificationRepository.getNotification(notificationId);
+ return registryService.getNotification(gatewayId, notificationId);
} catch (RegistryException e) {
logger.error("Error while retrieving notification", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -283,8 +238,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<Notification> getAllNotifications(String gatewayId) throws RegistryServiceException, TException {
try {
- List<Notification> notifications = notificationRepository.getAllGatewayNotifications(gatewayId);
- return notifications;
+ return registryService.getAllNotifications(gatewayId);
} catch (RegistryException e) {
logger.error("Error while getting all notifications", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -304,16 +258,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public Project getProject(String projectId) throws RegistryServiceException, TException {
try {
- if (!projectRepository.isProjectExist(projectId)) {
- logger.error("Project does not exist in the system. Please provide a valid project ID...");
- ProjectNotFoundException exception = new ProjectNotFoundException();
- exception.setMessage("Project does not exist in the system. Please provide a valid project ID...");
- throw exception;
- }
- logger.debug("Airavata retrieved project with project Id : " + projectId);
-
- Project project = projectRepository.getProject(projectId);
- return project;
+ return registryService.getProject(projectId);
} catch (RegistryException e) {
logger.error("Error while retrieving the project", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -335,21 +280,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteProject(String projectId) throws RegistryServiceException, TException {
try {
- if (!projectRepository.isProjectExist(projectId)) {
- logger.error("Project does not exist in the system. Please provide a valid project ID...");
- ProjectNotFoundException exception = new ProjectNotFoundException();
- exception.setMessage("Project does not exist in the system. Please provide a valid project ID...");
- throw exception;
- }
-
- projectRepository.removeProject(projectId);
- logger.debug("Airavata deleted project with project Id : " + projectId);
- return true;
+ return registryService.deleteProject(projectId);
} catch (RegistryException e) {
- logger.error("Error while removing the project", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while removing the project. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while removing the project");
}
}
@@ -365,38 +298,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<Project> getUserProjects(String gatewayId, String userName, int limit, int offset)
throws RegistryServiceException, TException {
- if (!validateString(userName)) {
- logger.error("Username cannot be empty. Please provide a valid user..");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Username cannot be empty. Please provide a valid user..");
- throw exception;
- }
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- List<Project> projects = new ArrayList<>();
try {
- if (!userRepository.isUserExists(gatewayId, userName)) {
- logger.warn("User does not exist in the system. Please provide a valid user..");
- return projects;
- }
- Map<String, String> filters = new HashMap<>();
- filters.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
- filters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
- projects = projectRepository.searchProjects(
- filters,
- limit,
- offset,
- Constants.FieldConstants.ProjectConstants.CREATION_TIME,
- ResultOrderType.DESC);
- logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId);
- return projects;
+ return registryService.getUserProjects(gatewayId, userName, limit, offset);
} catch (RegistryException e) {
- logger.error("Error while retrieving projects", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving projects. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving projects");
}
}
@@ -420,43 +325,12 @@ public class RegistryServerHandler implements RegistryService.Iface {
int limit,
int offset)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- // FIXME: for now allowing to pass null accessibleExpIds (only admin users should call this method)
- // if (accessibleExpIds == null) {
- // logger.debug("accessibleExpIds is null, defaulting to an empty list");
- // accessibleExpIds = Collections.emptyList();
- // }
- try {
- Map<String, String> filters = new HashMap<>();
- filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);
- filters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, fromTime + "");
- filters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, toTime + "");
- if (userName != null) {
- filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
- }
- if (applicationName != null) {
- filters.put(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID, applicationName);
- }
- if (resourceHostName != null) {
- filters.put(Constants.FieldConstants.ExperimentConstants.RESOURCE_HOST_ID, resourceHostName);
- }
-
- // Cap the max returned experiment summaries at 1000
- limit = Math.min(limit, 1000);
-
- ExperimentStatistics result = experimentSummaryRepository.getAccessibleExperimentStatistics(
- accessibleExpIds, filters, limit, offset);
- logger.debug("Airavata retrieved experiments for gateway id : " + gatewayId + " between : "
- + AiravataUtils.getTime(fromTime) + " and " + AiravataUtils.getTime(toTime));
- return result;
- } catch (Exception e) {
- logger.error("Error while retrieving experiments", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving experiments. More info : " + e.getMessage());
- throw exception;
+ try {
+ return registryService.getExperimentStatistics(
+ gatewayId, fromTime, toTime, userName, applicationName, resourceHostName,
+ accessibleExpIds, limit, offset);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving experiments");
}
}
@@ -472,39 +346,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<ExperimentModel> getExperimentsInProject(String gatewayId, String projectId, int limit, int offset)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- if (!validateString(projectId)) {
- logger.error("Project id cannot be empty. Please provide a valid project ID...");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Project id cannot be empty. Please provide a valid project ID...");
- throw exception;
- }
try {
- if (!projectRepository.isProjectExist(projectId)) {
- logger.error("Project does not exist in the system. Please provide a valid project ID...");
- ProjectNotFoundException exception = new ProjectNotFoundException();
- exception.setMessage("Project does not exist in the system. Please provide a valid project ID...");
- throw exception;
- }
-
- List<ExperimentModel> experiments = experimentRepository.getExperimentList(
- gatewayId,
- Constants.FieldConstants.ExperimentConstants.PROJECT_ID,
- projectId,
- limit,
- offset,
- Constants.FieldConstants.ExperimentConstants.CREATION_TIME,
- ResultOrderType.DESC);
- logger.debug("Airavata retrieved experiments for project : " + projectId);
- return experiments;
- } catch (Exception e) {
- logger.error("Error while retrieving the experiments", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving the experiments. More info : " + e.getMessage());
- throw exception;
+ return registryService.getExperimentsInProject(gatewayId, projectId, limit, offset);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving the experiments");
}
}
@@ -520,38 +365,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<ExperimentModel> getUserExperiments(String gatewayId, String userName, int limit, int offset)
throws RegistryServiceException, TException {
- if (!validateString(userName)) {
- logger.error("Username cannot be empty. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Username cannot be empty. Please provide a valid user..");
- throw exception;
- }
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- List<ExperimentModel> experiments = new ArrayList<ExperimentModel>();
try {
- if (!userRepository.isUserExists(gatewayId, userName)) {
- logger.warn("User does not exist in the system. Please provide a valid user..");
- return experiments;
- }
- experiments = experimentRepository.getExperimentList(
- gatewayId,
- Constants.FieldConstants.ExperimentConstants.USER_NAME,
- userName,
- limit,
- offset,
- Constants.FieldConstants.ExperimentConstants.CREATION_TIME,
- ResultOrderType.DESC);
- logger.debug("Airavata retrieved experiments for user : " + userName);
- return experiments;
- } catch (Exception e) {
- logger.error("Error while retrieving the experiments", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving the experiments. More info : " + e.getMessage());
- throw exception;
+ return registryService.getUserExperiments(gatewayId, userName, limit, offset);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving the experiments");
}
}
@@ -565,25 +382,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteExperiment(String experimentId) throws RegistryServiceException, TException {
try {
- if (!experimentRepository.isExperimentExist(experimentId)) {
- throw new ExperimentNotFoundException(
- "Requested experiment id " + experimentId + " does not exist in the system..");
- }
- ExperimentModel experimentModel = experimentRepository.getExperiment(experimentId);
-
- if (!(experimentModel.getExperimentStatus().get(0).getState() == ExperimentState.CREATED)) {
- logger.error("Error while deleting the experiment");
- throw new ExperimentCatalogException(
- "Experiment is not in CREATED state. Hence cannot deleted. ID:" + experimentId);
- }
- experimentRepository.removeExperiment(experimentId);
- logger.debug("Airavata removed experiment with experiment id : " + experimentId);
- return true;
- } catch (Exception e) {
- logger.error("Error while deleting the experiment", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting the experiment. More info : " + e.getMessage());
- throw exception;
+ return registryService.deleteExperiment(experimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while deleting the experiment");
}
}
@@ -660,39 +461,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ExperimentModel getDetailedExperimentTree(String airavataExperimentId)
throws RegistryServiceException, TException {
try {
- ExperimentModel experimentModel = getExperimentInternal(airavataExperimentId);
- List<ProcessModel> processList = processRepository.getProcessList(
- Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentModel.getExperimentId());
- if (processList != null) {
- processList.stream().forEach(p -> {
- // Process already has the task object
- (p).getTasks().stream().forEach(t -> {
- try {
- List<JobModel> jobList = jobRepository.getJobList(
- Constants.FieldConstants.JobConstants.TASK_ID, ((TaskModel) t).getTaskId());
- if (jobList != null) {
- Collections.sort(jobList, new Comparator<JobModel>() {
- @Override
- public int compare(JobModel o1, JobModel o2) {
- return (int) (o1.getCreationTime() - o2.getCreationTime());
- }
- });
- t.setJobs(jobList);
- }
- } catch (RegistryException e) {
- logger.error(e.getMessage(), e);
- }
- });
- });
- experimentModel.setProcesses(processList);
- }
- logger.debug("Airavata retrieved detailed experiment with experiment id : " + airavataExperimentId);
- return experimentModel;
- } catch (Exception e) {
- logger.error("Error while retrieving the experiment", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving the experiment. More info : " + e.getMessage());
- throw exception;
+ return registryService.getDetailedExperimentTree(airavataExperimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving the experiment");
}
}
@@ -708,9 +479,11 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public ExperimentStatus getExperimentStatus(String airavataExperimentId)
throws RegistryServiceException, TException {
- ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
- logger.debug("Airavata retrieved experiment status for experiment id : " + airavataExperimentId);
- return experimentStatus;
+ try {
+ return registryService.getExperimentStatus(airavataExperimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving experiment status");
+ }
}
/**
@@ -725,21 +498,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<OutputDataObjectType> getExperimentOutputs(String airavataExperimentId)
throws RegistryServiceException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- logger.error(
- airavataExperimentId,
- "Get experiment outputs failed, experiment {} doesn't exit.",
- airavataExperimentId);
- throw new ExperimentNotFoundException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- logger.debug("Airavata retrieved experiment outputs for experiment id : " + airavataExperimentId);
- return experimentOutputRepository.getExperimentOutputs(airavataExperimentId);
- } catch (Exception e) {
- logger.error(airavataExperimentId, "Error while retrieving the experiment outputs", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving the experiment outputs. More info : " + e.getMessage());
- throw exception;
+ return registryService.getExperimentOutputs(airavataExperimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving the experiment outputs");
}
}
@@ -754,7 +515,11 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<OutputDataObjectType> getIntermediateOutputs(String airavataExperimentId)
throws RegistryServiceException, TException {
- return null;
+ try {
+ return registryService.getIntermediateOutputs(airavataExperimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving intermediate outputs");
+ }
}
/**
@@ -768,100 +533,38 @@ public class RegistryServerHandler implements RegistryService.Iface {
public Map<String, JobStatus> getJobStatuses(String airavataExperimentId)
throws RegistryServiceException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- logger.error(
- airavataExperimentId,
- "Error while retrieving job details, experiment {} doesn't exist.",
- airavataExperimentId);
- throw new ExperimentNotFoundException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- List<ProcessModel> processModels = processRepository.getProcessList(
- Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
- Map<String, JobStatus> jobStatus = new HashMap<String, JobStatus>();
- if (processModels != null && !processModels.isEmpty()) {
- for (ProcessModel processModel : processModels) {
- List<TaskModel> tasks = processModel.getTasks();
- if (tasks != null && !tasks.isEmpty()) {
- for (TaskModel task : tasks) {
- String taskId = task.getTaskId();
- List<JobModel> jobs =
- jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, taskId);
- if (jobs != null && !jobs.isEmpty()) {
- for (JobModel jobModel : jobs) {
- String jobID = jobModel.getJobId();
- List<JobStatus> status = jobModel.getJobStatuses();
- if (status != null && status.size() > 0) {
- JobStatus latestStatus = status.get(status.size() - 1);
- jobStatus.put(jobID, latestStatus);
- }
- }
- }
- }
- }
- }
- }
- logger.debug("Airavata retrieved job statuses for experiment with experiment id : " + airavataExperimentId);
- return jobStatus;
- } catch (Exception e) {
- logger.error(airavataExperimentId, "Error while retrieving the job statuses", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving the job statuses. More info : " + e.getMessage());
- throw exception;
+ return registryService.getJobStatuses(airavataExperimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving the job statuses");
}
}
@Override
public void addExperimentProcessOutputs(String outputType, List<OutputDataObjectType> outputs, String id)
throws RegistryServiceException, TException {
-
try {
- if (ExpCatChildDataType.PROCESS_OUTPUT.equals(ExpCatChildDataType.valueOf(outputType))) {
- processOutputRepository.addProcessOutputs(outputs, id);
- } else if (ExpCatChildDataType.EXPERIMENT_OUTPUT.equals(ExpCatChildDataType.valueOf(outputType))) {
- experimentOutputRepository.addExperimentOutputs(outputs, id);
- }
- } catch (Exception e) {
- logger.error(id, "Error while adding outputs", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding outputs. More info : " + e.getMessage());
- throw exception;
+ registryService.addExperimentProcessOutputs(outputType, outputs, id);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding outputs");
}
}
@Override
public void addErrors(String errorType, ErrorModel errorModel, String id)
throws RegistryServiceException, TException {
-
try {
- if (ExpCatChildDataType.EXPERIMENT_ERROR.equals(ExpCatChildDataType.valueOf(errorType))) {
- experimentErrorRepository.addExperimentError(errorModel, id);
- } else if (ExpCatChildDataType.TASK_ERROR.equals(ExpCatChildDataType.valueOf(errorType))) {
- taskErrorRepository.addTaskError(errorModel, id);
- } else if (ExpCatChildDataType.PROCESS_ERROR.equals(ExpCatChildDataType.valueOf(errorType))) {
- processErrorRepository.addProcessError(errorModel, id);
- }
- } catch (Exception e) {
- logger.error(id, "Error while adding error", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding error. More info : " + e.getMessage());
- throw exception;
+ registryService.addErrors(errorType, errorModel, id);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding errors");
}
}
@Override
public void addTaskStatus(TaskStatus taskStatus, String taskId) throws RegistryServiceException, TException {
try {
- taskStatusRepository.addTaskStatus(taskStatus, taskId);
- } catch (Exception e) {
- logger.error(taskId, "Error while adding task status", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding task status. More info : " + e.getMessage());
- throw exception;
+ registryService.addTaskStatus(taskStatus, taskId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding task status");
}
}
@@ -869,13 +572,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void addProcessStatus(ProcessStatus processStatus, String processId)
throws RegistryServiceException, TException {
try {
- processStatusRepository.addProcessStatus(processStatus, processId);
- } catch (Exception e) {
- logger.error(processId, "Error while adding process status", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding process status. More info : " + e.getMessage());
- throw exception;
+ registryService.addProcessStatus(processStatus, processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding process status");
}
}
@@ -883,13 +582,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void updateProcessStatus(ProcessStatus processStatus, String processId)
throws RegistryServiceException, TException {
try {
- processStatusRepository.updateProcessStatus(processStatus, processId);
- } catch (Exception e) {
- logger.error(processId, "Error while updating process status", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while updating process status. More info : " + e.getMessage());
- throw exception;
+ registryService.updateProcessStatus(processStatus, processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while updating process status");
}
}
@@ -897,13 +592,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void updateExperimentStatus(ExperimentStatus experimentStatus, String experimentId)
throws RegistryServiceException, TException {
try {
- experimentStatusRepository.updateExperimentStatus(experimentStatus, experimentId);
- } catch (Exception e) {
- logger.error(experimentId, "Error while updating experiment status", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while updating experiment status. More info : " + e.getMessage());
- throw exception;
+ registryService.updateExperimentStatus(experimentStatus, experimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while updating experiment status");
}
}
@@ -911,45 +602,27 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void addJobStatus(JobStatus jobStatus, String taskId, String jobId)
throws RegistryServiceException, TException {
try {
- JobPK jobPK = new JobPK();
- jobPK.setJobId(jobId);
- jobPK.setTaskId(taskId);
- jobStatusRepository.addJobStatus(jobStatus, jobPK);
- } catch (Exception e) {
- logger.error(jobId, "Error while adding job status", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding job status. More info : " + e.getMessage());
- throw exception;
+ registryService.addJobStatus(jobStatus, taskId, jobId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding job status");
}
}
@Override
public void addJob(JobModel jobModel, String processId) throws RegistryServiceException, TException {
try {
- jobRepository.addJob(jobModel, processId);
- } catch (Exception e) {
- logger.error(processId, "Error while adding job ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding job. More info : " + e.getMessage());
- throw exception;
+ registryService.addJob(jobModel, processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding job");
}
}
@Override
public void deleteJobs(String processId) throws RegistryServiceException, TException {
try {
- List<JobModel> jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.PROCESS_ID, processId);
- for (JobModel jobModel : jobs) {
- jobRepository.removeJob(jobModel);
- }
- } catch (Exception e) {
- logger.error(processId, "Error while deleting job ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while deleting job. More info : " + e.getMessage());
- throw exception;
+ registryService.deleteJobs(processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while deleting job");
}
}
@@ -957,52 +630,36 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String addProcess(ProcessModel processModel, String experimentId)
throws RegistryServiceException, TException {
try {
- return processRepository.addProcess(processModel, experimentId);
- } catch (Exception e) {
- logger.error(experimentId, "Error while adding process ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding process. More info : " + e.getMessage());
- throw exception;
+ return registryService.addProcess(processModel, experimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding process");
}
}
@Override
public void updateProcess(ProcessModel processModel, String processId) throws RegistryServiceException, TException {
try {
- processRepository.updateProcess(processModel, processId);
- } catch (Exception e) {
- logger.error(processId, "Error while updating process ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while updating process. More info : " + e.getMessage());
- throw exception;
+ registryService.updateProcess(processModel, processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while updating process");
}
}
@Override
public String addTask(TaskModel taskModel, String processId) throws RegistryServiceException, TException {
try {
- return taskRepository.addTask(taskModel, processId);
- } catch (Exception e) {
- logger.error(processId, "Error while adding task ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding task. More info : " + e.getMessage());
- throw exception;
+ return registryService.addTask(taskModel, processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding task");
}
}
@Override
public void deleteTasks(String processId) throws RegistryServiceException, TException {
try {
- taskRepository.deleteTasks(processId);
- } catch (Exception e) {
- logger.error(processId, "Error while adding task ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding task. More info : " + e.getMessage());
- throw exception;
+ registryService.deleteTasks(processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while deleting tasks");
}
}
@@ -1010,55 +667,36 @@ public class RegistryServerHandler implements RegistryService.Iface {
public UserConfigurationDataModel getUserConfigurationData(String experimentId)
throws RegistryServiceException, TException {
try {
- return experimentRepository.getUserConfigurationData(experimentId);
- } catch (Exception e) {
- logger.error(experimentId, "Error while getting user configuration ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding task. More info : " + e.getMessage());
- throw exception;
+ return registryService.getUserConfigurationData(experimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while getting user configuration");
}
}
@Override
public ProcessModel getProcess(String processId) throws RegistryServiceException, TException {
try {
- return processRepository.getProcess(processId);
- } catch (Exception e) {
- logger.error(processId, "Error while retrieving user configuration ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving user configuration. More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcess(processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process");
}
}
@Override
public List<ProcessModel> getProcessList(String experimentId) throws RegistryServiceException, TException {
try {
- List<ProcessModel> processModels = processRepository.getProcessList(
- Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentId);
- return processModels;
-
- } catch (Exception e) {
- logger.error(experimentId, "Error while retrieving process list ", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving process list. More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcessList(experimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process list");
}
}
@Override
public ProcessStatus getProcessStatus(String processId) throws RegistryServiceException, TException {
try {
- return processStatusRepository.getProcessStatus(processId);
- } catch (Exception e) {
- logger.error(processId, "Error while retrieving process status", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving process status. More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcessStatus(processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process status");
}
}
@@ -1066,43 +704,18 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<ProcessModel> getProcessListInState(ProcessState processState)
throws RegistryServiceException, TException {
try {
-
- List<ProcessModel> finalProcessList = new ArrayList<>();
- int offset = 0;
- int limit = 100;
- int count = 0;
- do {
- List<ProcessStatus> processStatusList =
- processStatusRepository.getProcessStatusList(processState, offset, limit);
- offset += processStatusList.size();
- count = processStatusList.size();
- for (ProcessStatus processStatus : processStatusList) {
- ProcessStatus latestStatus = processStatusRepository.getProcessStatus(processStatus.getProcessId());
- if (latestStatus.getState().name().equals(processState.name())) {
- finalProcessList.add(processRepository.getProcess(latestStatus.getProcessId()));
- }
- }
- } while (count == limit);
- return finalProcessList;
- } catch (Exception e) {
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage(
- "Error while retrieving process list with given status. More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcessListInState(processState);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process list with given status");
}
}
@Override
public List<ProcessStatus> getProcessStatusList(String processId) throws RegistryServiceException, TException {
try {
- return processStatusRepository.getProcessStatusList(processId);
- } catch (Exception e) {
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage(
- "Error while retrieving process status list for given process Id. More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcessStatusList(processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process status list for given process Id");
}
}
@@ -1112,14 +725,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean isJobExist(String queryType, String id) throws RegistryServiceException, TException {
try {
- JobModel jobModel = fetchJobModel(queryType, id);
- return jobModel != null;
- } catch (Exception e) {
- logger.error(id, "Error while retrieving job", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving job. More info : " + e.getMessage());
- throw exception;
+ return registryService.isJobExist(queryType, id);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving job");
}
}
@@ -1129,30 +737,18 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public JobModel getJob(String queryType, String id) throws RegistryServiceException, TException {
try {
- JobModel jobModel = fetchJobModel(queryType, id);
- if (jobModel != null) return jobModel;
- throw new Exception("Job not found for queryType: " + queryType + ", id: " + id);
- } catch (Exception e) {
- logger.error(id, "Error while retrieving job", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving job. More info : " + e.getMessage());
- throw exception;
+ return registryService.getJob(queryType, id);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving job");
}
}
@Override
public List<JobModel> getJobs(String queryType, String id) throws RegistryServiceException, TException {
-
try {
- return fetchJobModels(queryType, id);
- } catch (Exception e) {
- logger.error(id, "Error while retrieving jobs for query " + queryType + " and id " + id, e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving jobs for query " + queryType + " and id " + id
- + ". More info : " + e.getMessage());
- throw exception;
+ return registryService.getJobs(queryType, id);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving jobs for query " + queryType + " and id " + id);
}
}
@@ -1160,109 +756,57 @@ public class RegistryServerHandler implements RegistryService.Iface {
public int getJobCount(
org.apache.airavata.model.status.JobStatus jobStatus, String gatewayId, double searchBackTimeInMinutes)
throws RegistryServiceException, TException {
-
- List<JobStatus> jobStatusList = jobStatusRepository.getDistinctListofJobStatus(
- gatewayId, jobStatus.getJobState().name(), searchBackTimeInMinutes);
- return jobStatusList.size();
+ try {
+ return registryService.getJobCount(jobStatus, gatewayId, searchBackTimeInMinutes);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while getting job count");
+ }
}
@Override
public Map<String, Double> getAVGTimeDistribution(String gatewayId, double searchBackTimeInMinutes)
throws RegistryServiceException, TException {
- return processRepository.getAVGTimeDistribution(gatewayId, searchBackTimeInMinutes);
- }
-
- private JobModel fetchJobModel(String queryType, String id) throws RegistryException {
- if (queryType.equals(Constants.FieldConstants.JobConstants.TASK_ID)) {
- List<JobModel> jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, id);
- if (jobs != null) {
- for (JobModel jobModel : jobs) {
- if (jobModel.getJobId() != null || !jobModel.equals("")) {
- return jobModel;
- }
- }
- }
- } else if (queryType.equals(Constants.FieldConstants.JobConstants.PROCESS_ID)) {
- List<JobModel> jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.PROCESS_ID, id);
- if (jobs != null) {
- for (JobModel jobModel : jobs) {
- if (jobModel.getJobId() != null || !jobModel.equals("")) {
- return jobModel;
- }
- }
- }
+ try {
+ return registryService.getAVGTimeDistribution(gatewayId, searchBackTimeInMinutes);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while getting average time distribution");
}
- return null;
}
- private List<JobModel> fetchJobModels(String queryType, String id) throws RegistryException {
- List<JobModel> jobs = new ArrayList<>();
- switch (queryType) {
- case Constants.FieldConstants.JobConstants.TASK_ID:
- jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, id);
- break;
- case Constants.FieldConstants.JobConstants.PROCESS_ID:
- jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.PROCESS_ID, id);
- break;
- case Constants.FieldConstants.JobConstants.JOB_ID:
- jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.JOB_ID, id);
- break;
- }
- return jobs;
- }
@Override
public List<OutputDataObjectType> getProcessOutputs(String processId) throws RegistryServiceException, TException {
try {
- return processOutputRepository.getProcessOutputs(processId);
- } catch (Exception e) {
- logger.error("Error while retrieving process outputs for process id " + processId, e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving process outputs. More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcessOutputs(processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process outputs");
}
}
@Override
public List<ProcessWorkflow> getProcessWorkflows(String processId) throws RegistryServiceException, TException {
-
try {
- return processWorkflowRepository.getProcessWorkflows(processId);
- } catch (Exception e) {
- logger.error("Error while retrieving process workflows for process id " + processId, e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving process workflows for process id " + processId
- + ". More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcessWorkflows(processId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process workflows for process id " + processId);
}
}
@Override
public void addProcessWorkflow(ProcessWorkflow processWorkflow) throws RegistryServiceException, TException {
try {
- processWorkflowRepository.addProcessWorkflow(processWorkflow, processWorkflow.getProcessId());
- } catch (Exception e) {
- logger.error("Error while adding process workflows for process id " + processWorkflow.getProcessId(), e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding process workflows for process id " + processWorkflow.getProcessId()
- + ". More info : " + e.getMessage());
- throw exception;
+ registryService.addProcessWorkflow(processWorkflow);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding process workflows for process id " + processWorkflow.getProcessId());
}
}
@Override
public List<String> getProcessIds(String experimentId) throws RegistryServiceException, TException {
try {
- return processRepository.getProcessIds(DBConstants.Process.EXPERIMENT_ID, experimentId);
- } catch (Exception e) {
- logger.error(experimentId, "Error while retrieving process ids", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving process ids. More info : " + e.getMessage());
- throw exception;
+ return registryService.getProcessIds(experimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving process ids");
}
}
@@ -1276,37 +820,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<JobModel> getJobDetails(String airavataExperimentId) throws RegistryServiceException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- logger.error(
- airavataExperimentId,
- "Error while retrieving job details, experiment {} doesn't exist.",
- airavataExperimentId);
- throw new ExperimentNotFoundException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- List<ProcessModel> processModels = processRepository.getProcessList(
- Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
- List<JobModel> jobList = new ArrayList<>();
- if (processModels != null && !processModels.isEmpty()) {
- for (ProcessModel processModel : processModels) {
- List<TaskModel> tasks = processModel.getTasks();
- if (tasks != null && !tasks.isEmpty()) {
- for (TaskModel taskModel : tasks) {
- String taskId = taskModel.getTaskId();
- List<JobModel> taskJobs =
- jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, taskId);
- jobList.addAll(taskJobs);
- }
- }
- }
- }
- logger.debug("Airavata retrieved job models for experiment with experiment id : " + airavataExperimentId);
- return jobList;
- } catch (Exception e) {
- logger.error(airavataExperimentId, "Error while retrieving the job details", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving the job details. More info : " + e.getMessage());
- throw exception;
+ return registryService.getJobDetails(airavataExperimentId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving the job details");
}
}
@@ -1320,14 +836,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public ApplicationModule getApplicationModule(String appModuleId) throws RegistryServiceException, TException {
try {
- ApplicationModule module = applicationInterfaceRepository.getApplicationModule(appModuleId);
- logger.debug("Airavata retrieved application module with module id : " + appModuleId);
- return module;
+ return registryService.getApplicationModule(appModuleId);
} catch (AppCatalogException e) {
- logger.error(appModuleId, "Error while retrieving application module...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving the adding application module. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application module");
}
}
@@ -1340,19 +851,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
*/
@Override
public List<ApplicationModule> getAllAppModules(String gatewayId) throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- List<ApplicationModule> moduleList = applicationInterfaceRepository.getAllApplicationModules(gatewayId);
- logger.debug("Airavata retrieved modules for gateway id : " + gatewayId);
- return moduleList;
+ return registryService.getAllAppModules(gatewayId);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving all application modules...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving all application modules. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving all application modules");
}
}
@@ -1368,20 +870,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<ApplicationModule> getAccessibleAppModules(
String gatewayId, List<String> accessibleAppIds, List<String> accessibleComputeResourceIds)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- List<ApplicationModule> moduleList = applicationInterfaceRepository.getAccessibleApplicationModules(
- gatewayId, accessibleAppIds, accessibleComputeResourceIds);
- logger.debug("Airavata retrieved modules for gateway id : " + gatewayId);
- return moduleList;
+ return registryService.getAccessibleAppModules(gatewayId, accessibleAppIds, accessibleComputeResourceIds);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving all application modules...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving all application modules. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving all application modules");
}
}
@@ -1395,13 +887,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteApplicationModule(String appModuleId) throws RegistryServiceException, TException {
try {
- logger.debug("Airavata deleted application module with module id : " + appModuleId);
- return applicationInterfaceRepository.removeApplicationModule(appModuleId);
+ return registryService.deleteApplicationModule(appModuleId);
} catch (AppCatalogException e) {
- logger.error(appModuleId, "Error while deleting application module...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting the application module. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting the application module");
}
}
@@ -1416,15 +904,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ApplicationDeploymentDescription getApplicationDeployment(String appDeploymentId)
throws RegistryServiceException, TException {
try {
- ApplicationDeploymentDescription deployement =
- applicationDeploymentRepository.getApplicationDeployement(appDeploymentId);
- logger.debug("Airavata registered application deployment for deployment id : " + appDeploymentId);
- return deployement;
+ return registryService.getApplicationDeployment(appDeploymentId);
} catch (AppCatalogException e) {
- logger.error(appDeploymentId, "Error while retrieving application deployment...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application deployment. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application deployment");
}
}
@@ -1438,14 +920,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteApplicationDeployment(String appDeploymentId) throws RegistryServiceException, TException {
try {
- applicationDeploymentRepository.removeAppDeployment(appDeploymentId);
- logger.debug("Airavata removed application deployment with deployment id : " + appDeploymentId);
- return true;
+ return registryService.deleteApplicationDeployment(appDeploymentId);
} catch (AppCatalogException e) {
- logger.error(appDeploymentId, "Error while deleting application deployment...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting application deployment. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting application deployment");
}
}
@@ -1460,20 +937,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<ApplicationDeploymentDescription> getAllApplicationDeployments(String gatewayId)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- List<ApplicationDeploymentDescription> deployements =
- applicationDeploymentRepository.getAllApplicationDeployements(gatewayId);
- logger.debug("Airavata retrieved application deployments for gateway id : " + gatewayId);
- return deployements;
+ return registryService.getAllApplicationDeployments(gatewayId);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving application deployments...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application deployments. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application deployments");
}
}
@@ -1489,21 +956,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<ApplicationDeploymentDescription> getAccessibleApplicationDeployments(
String gatewayId, List<String> accessibleAppDeploymentIds, List<String> accessibleComputeResourceIds)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- List<ApplicationDeploymentDescription> deployements =
- applicationDeploymentRepository.getAccessibleApplicationDeployments(
- gatewayId, accessibleAppDeploymentIds, accessibleComputeResourceIds);
- logger.debug("Airavata retrieved application deployments for gateway id : " + gatewayId);
- return deployements;
+ return registryService.getAccessibleApplicationDeployments(gatewayId, accessibleAppDeploymentIds, accessibleComputeResourceIds);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving application deployments...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application deployments. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application deployments");
}
}
@@ -1524,20 +980,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
List<String> accessibleAppDeploymentIds,
List<String> accessibleComputeResourceIds)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- List<ApplicationDeploymentDescription> deployments =
- applicationDeploymentRepository.getAccessibleApplicationDeployments(
- gatewayId, appModuleId, accessibleAppDeploymentIds, accessibleComputeResourceIds);
- return deployments;
+ return registryService.getAccessibleApplicationDeploymentsForAppModule(gatewayId, appModuleId, accessibleAppDeploymentIds, accessibleComputeResourceIds);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving application deployments...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application deployments. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application deployments");
}
}
@@ -1551,21 +997,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<String> getAppModuleDeployedResources(String appModuleId) throws RegistryServiceException, TException {
try {
- List<String> appDeployments = new ArrayList<>();
- Map<String, String> filters = new HashMap<>();
- filters.put(DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID, appModuleId);
- List<ApplicationDeploymentDescription> applicationDeployments =
- applicationDeploymentRepository.getApplicationDeployments(filters);
- for (ApplicationDeploymentDescription description : applicationDeployments) {
- appDeployments.add(description.getAppDeploymentId());
- }
- logger.debug("Airavata retrieved application deployments for module id : " + appModuleId);
- return appDeployments;
+ return registryService.getAppModuleDeployedResources(appModuleId);
} catch (AppCatalogException e) {
- logger.error(appModuleId, "Error while retrieving application deployments...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application deployment. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application deployment");
}
}
@@ -1573,16 +1007,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<ApplicationDeploymentDescription> getApplicationDeployments(String appModuleId)
throws RegistryServiceException, TException {
try {
- Map<String, String> filters = new HashMap<>();
- filters.put(DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID, appModuleId);
- List<ApplicationDeploymentDescription> applicationDeployments =
- applicationDeploymentRepository.getApplicationDeployments(filters);
- return applicationDeployments;
+ return registryService.getApplicationDeployments(appModuleId);
} catch (AppCatalogException e) {
- logger.error(appModuleId, "Error while retrieving application deployments...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application deployment. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application deployment");
}
}
@@ -1597,15 +1024,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ApplicationInterfaceDescription getApplicationInterface(String appInterfaceId)
throws RegistryServiceException, TException {
try {
- ApplicationInterfaceDescription interfaceDescription =
- applicationInterfaceRepository.getApplicationInterface(appInterfaceId);
- logger.debug("Airavata retrieved application interface with interface id : " + appInterfaceId);
- return interfaceDescription;
+ return registryService.getApplicationInterface(appInterfaceId);
} catch (AppCatalogException e) {
- logger.error(appInterfaceId, "Error while retrieving application interface...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application interface. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application interface");
}
}
@@ -1619,15 +1040,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteApplicationInterface(String appInterfaceId) throws RegistryServiceException, TException {
try {
- boolean removeApplicationInterface =
- applicationInterfaceRepository.removeApplicationInterface(appInterfaceId);
- logger.debug("Airavata removed application interface with interface id : " + appInterfaceId);
- return removeApplicationInterface;
+ return registryService.deleteApplicationInterface(appInterfaceId);
} catch (AppCatalogException e) {
- logger.error(appInterfaceId, "Error while deleting application interface...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting application interface. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting application interface");
}
}
@@ -1641,28 +1056,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public Map<String, String> getAllApplicationInterfaceNames(String gatewayId)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- List<ApplicationInterfaceDescription> allApplicationInterfaces =
- applicationInterfaceRepository.getAllApplicationInterfaces(gatewayId);
- Map<String, String> allApplicationInterfacesMap = new HashMap<>();
- if (allApplicationInterfaces != null && !allApplicationInterfaces.isEmpty()) {
- for (ApplicationInterfaceDescription interfaceDescription : allApplicationInterfaces) {
- allApplicationInterfacesMap.put(
- interfaceDescription.getApplicationInterfaceId(),
- interfaceDescription.getApplicationName());
- }
- }
- logger.debug("Airavata retrieved application interfaces for gateway id : " + gatewayId);
- return allApplicationInterfacesMap;
+ return registryService.getAllApplicationInterfaceNames(gatewayId);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving application interfaces...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application interfaces. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application interfaces");
}
}
@@ -1676,20 +1073,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<ApplicationInterfaceDescription> getAllApplicationInterfaces(String gatewayId)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- List<ApplicationInterfaceDescription> interfaces =
- applicationInterfaceRepository.getAllApplicationInterfaces(gatewayId);
- logger.debug("Airavata retrieved application interfaces for gateway id : " + gatewayId);
- return interfaces;
+ return registryService.getAllApplicationInterfaces(gatewayId);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving application interfaces...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application interfaces. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application interfaces");
}
}
@@ -1704,15 +1091,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<InputDataObjectType> getApplicationInputs(String appInterfaceId)
throws RegistryServiceException, TException {
try {
- List<InputDataObjectType> applicationInputs =
- applicationInterfaceRepository.getApplicationInputs(appInterfaceId);
- logger.debug("Airavata retrieved application inputs for application interface id : " + appInterfaceId);
- return applicationInputs;
+ return registryService.getApplicationInputs(appInterfaceId);
} catch (AppCatalogException e) {
- logger.error(appInterfaceId, "Error while retrieving application inputs...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving application inputs. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving application inputs");
}
}
@@ -1726,9 +1107,11 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<OutputDataObjectType> getApplicationOutputs(String appInterfaceId)
throws RegistryServiceException, TException {
- List<OutputDataObjectType> list = getApplicationOutputsInternal(appInterfaceId);
- logger.debug("Airavata retrieved application outputs for app interface id : " + appInterfaceId);
- return list;
+ try {
+ return registryService.getApplicationOutputs(appInterfaceId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving application outputs");
+ }
}
/**
@@ -1743,35 +1126,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public Map<String, String> getAvailableAppInterfaceComputeResources(String appInterfaceId)
throws RegistryServiceException, TException {
try {
- Map<String, String> allComputeResources =
- new ComputeResourceRepository().getAvailableComputeResourceIdList();
- Map<String, String> availableComputeResources = new HashMap<String, String>();
- ApplicationInterfaceDescription applicationInterface =
- applicationInterfaceRepository.getApplicationInterface(appInterfaceId);
- HashMap<String, String> filters = new HashMap<>();
- List<String> applicationModules = applicationInterface.getApplicationModules();
- if (applicationModules != null && !applicationModules.isEmpty()) {
- for (String moduleId : applicationModules) {
- filters.put(DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID, moduleId);
- List<ApplicationDeploymentDescription> applicationDeployments =
- applicationDeploymentRepository.getApplicationDeployments(filters);
- for (ApplicationDeploymentDescription deploymentDescription : applicationDeployments) {
- if (allComputeResources.get(deploymentDescription.getComputeHostId()) != null) {
- availableComputeResources.put(
- deploymentDescription.getComputeHostId(),
- allComputeResources.get(deploymentDescription.getComputeHostId()));
- }
- }
- }
- }
- logger.debug(
- "Airavata retrieved available compute resources for application interface id : " + appInterfaceId);
- return availableComputeResources;
+ return registryService.getAvailableAppInterfaceComputeResources(appInterfaceId);
} catch (AppCatalogException e) {
- logger.error(appInterfaceId, "Error while saving compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while saving compute resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving available compute resources");
}
}
@@ -1786,15 +1143,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ComputeResourceDescription getComputeResource(String computeResourceId)
throws RegistryServiceException, TException {
try {
- ComputeResourceDescription computeResource =
- new ComputeResourceRepository().getComputeResource(computeResourceId);
- logger.debug("Airavata retrieved compute resource with compute resource Id : " + computeResourceId);
- return computeResource;
+ return registryService.getComputeResource(computeResourceId);
} catch (AppCatalogException e) {
- logger.error(computeResourceId, "Error while retrieving compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving compute resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving compute resource");
}
}
@@ -1807,14 +1158,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public Map<String, String> getAllComputeResourceNames() throws RegistryServiceException, TException {
try {
- Map<String, String> computeResourceIdList = new ComputeResourceRepository().getAllComputeResourceIdList();
- logger.debug("Airavata retrieved all the available compute resources...");
- return computeResourceIdList;
+ return registryService.getAllComputeResourceNames();
} catch (AppCatalogException e) {
- logger.error("Error while retrieving compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving compute resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving compute resource");
}
}
@@ -1828,14 +1174,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteComputeResource(String computeResourceId) throws RegistryServiceException, TException {
try {
- new ComputeResourceRepository().removeComputeResource(computeResourceId);
- logger.debug("Airavata deleted compute resource with compute resource Id : " + computeResourceId);
- return true;
+ return registryService.deleteComputeResource(computeResourceId);
} catch (AppCatalogException e) {
- logger.error(computeResourceId, "Error while deleting compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting compute resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting compute resource");
}
}
@@ -1850,15 +1191,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public StorageResourceDescription getStorageResource(String storageResourceId)
throws RegistryServiceException, TException {
try {
- StorageResourceDescription storageResource =
- storageResourceRepository.getStorageResource(storageResourceId);
- logger.debug("Airavata retrieved storage resource with storage resource Id : " + storageResourceId);
- return storageResource;
+ return registryService.getStorageResource(storageResourceId);
} catch (AppCatalogException e) {
- logger.error(storageResourceId, "Error while retrieving storage resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving storage resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving storage resource");
}
}
@@ -1871,14 +1206,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public Map<String, String> getAllStorageResourceNames() throws RegistryServiceException, TException {
try {
- Map<String, String> resourceIdList = storageResourceRepository.getAllStorageResourceIdList();
- logger.debug("Airavata retrieved storage resources list...");
- return resourceIdList;
+ return registryService.getAllStorageResourceNames();
} catch (AppCatalogException e) {
- logger.error("Error while retrieving storage resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving storage resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving storage resource");
}
}
@@ -1892,14 +1222,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteStorageResource(String storageResourceId) throws RegistryServiceException, TException {
try {
- storageResourceRepository.removeStorageResource(storageResourceId);
- logger.debug("Airavata deleted storage resource with storage resource Id : " + storageResourceId);
- return true;
+ return registryService.deleteStorageResource(storageResourceId);
} catch (AppCatalogException e) {
- logger.error(storageResourceId, "Error while deleting storage resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting storage resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting storage resource");
}
}
@@ -1911,15 +1236,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public LOCALSubmission getLocalJobSubmission(String jobSubmissionId) throws RegistryServiceException, TException {
try {
- LOCALSubmission localJobSubmission = new ComputeResourceRepository().getLocalJobSubmission(jobSubmissionId);
- logger.debug("Airavata retrieved local job submission for job submission interface id: " + jobSubmissionId);
- return localJobSubmission;
+ return registryService.getLocalJobSubmission(jobSubmissionId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving local job submission interface to resource compute resource...";
- logger.error(jobSubmissionId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving local job submission interface");
}
}
@@ -1931,15 +1250,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public SSHJobSubmission getSSHJobSubmission(String jobSubmissionId) throws RegistryServiceException, TException {
try {
- SSHJobSubmission sshJobSubmission = new ComputeResourceRepository().getSSHJobSubmission(jobSubmissionId);
- logger.debug("Airavata retrieved SSH job submission for job submission interface id: " + jobSubmissionId);
- return sshJobSubmission;
+ return registryService.getSSHJobSubmission(jobSubmissionId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving SSH job submission interface to resource compute resource...";
- logger.error(jobSubmissionId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving SSH job submission interface");
}
}
@@ -1959,17 +1272,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public UnicoreJobSubmission getUnicoreJobSubmission(String jobSubmissionId)
throws RegistryServiceException, TException {
try {
- UnicoreJobSubmission unicoreJobSubmission =
- new ComputeResourceRepository().getUNICOREJobSubmission(jobSubmissionId);
- logger.debug(
- "Airavata retrieved UNICORE job submission for job submission interface id: " + jobSubmissionId);
- return unicoreJobSubmission;
+ return registryService.getUnicoreJobSubmission(jobSubmissionId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving Unicore job submission interface to resource compute resource...";
- logger.error(jobSubmissionId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving Unicore job submission interface");
}
}
@@ -1987,16 +1292,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public CloudJobSubmission getCloudJobSubmission(String jobSubmissionId)
throws RegistryServiceException, TException {
try {
- CloudJobSubmission cloudJobSubmission =
- new ComputeResourceRepository().getCloudJobSubmission(jobSubmissionId);
- logger.debug("Airavata retrieved cloud job submission for job submission interface id: " + jobSubmissionId);
- return cloudJobSubmission;
+ return registryService.getCloudJobSubmission(jobSubmissionId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving Cloud job submission interface to resource compute resource...";
- logger.error(jobSubmissionId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving Cloud job submission interface");
}
}
@@ -2009,15 +1307,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public LOCALDataMovement getLocalDataMovement(String dataMovementId) throws RegistryServiceException, TException {
try {
- LOCALDataMovement localDataMovement = new ComputeResourceRepository().getLocalDataMovement(dataMovementId);
- logger.debug("Airavata retrieved local data movement with data movement id: " + dataMovementId);
- return localDataMovement;
+ return registryService.getLocalDataMovement(dataMovementId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving local data movement interface to resource compute resource...";
- logger.error(dataMovementId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving local data movement interface");
}
}
@@ -2030,15 +1322,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public SCPDataMovement getSCPDataMovement(String dataMovementId) throws RegistryServiceException, TException {
try {
- SCPDataMovement scpDataMovement = new ComputeResourceRepository().getSCPDataMovement(dataMovementId);
- logger.debug("Airavata retrieved SCP data movement with data movement id: " + dataMovementId);
- return scpDataMovement;
+ return registryService.getSCPDataMovement(dataMovementId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving SCP data movement interface to resource compute resource...";
- logger.error(dataMovementId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving SCP data movement interface");
}
}
@@ -2052,16 +1338,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public UnicoreDataMovement getUnicoreDataMovement(String dataMovementId)
throws RegistryServiceException, TException {
try {
- UnicoreDataMovement unicoreDataMovement =
- new ComputeResourceRepository().getUNICOREDataMovement(dataMovementId);
- logger.debug("Airavata retrieved UNICORE data movement with data movement id: " + dataMovementId);
- return unicoreDataMovement;
+ return registryService.getUnicoreDataMovement(dataMovementId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving UNICORE data movement interface...";
- logger.error(dataMovementId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving UNICORE data movement interface");
}
}
@@ -2075,16 +1354,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public GridFTPDataMovement getGridFTPDataMovement(String dataMovementId)
throws RegistryServiceException, TException {
try {
- GridFTPDataMovement gridFTPDataMovement =
- new ComputeResourceRepository().getGridFTPDataMovement(dataMovementId);
- logger.debug("Airavata retrieved GRIDFTP data movement with data movement id: " + dataMovementId);
- return gridFTPDataMovement;
+ return registryService.getGridFTPDataMovement(dataMovementId);
} catch (AppCatalogException e) {
- String errorMsg = "Error while retrieving GridFTP data movement interface to resource compute resource...";
- logger.error(dataMovementId, errorMsg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(errorMsg + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving GridFTP data movement interface");
}
}
@@ -2154,14 +1426,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteJobSubmissionInterface(String computeResourceId, String jobSubmissionInterfaceId)
throws RegistryServiceException, TException {
try {
- new ComputeResourceRepository().removeJobSubmissionInterface(computeResourceId, jobSubmissionInterfaceId);
- logger.debug("Airavata deleted job submission interface with interface id : " + jobSubmissionInterfaceId);
- return true;
+ return registryService.deleteJobSubmissionInterface(computeResourceId, jobSubmissionInterfaceId);
} catch (AppCatalogException e) {
- logger.error(jobSubmissionInterfaceId, "Error while deleting job submission interface...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting job submission interface. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting job submission interface");
}
}
@@ -2169,25 +1436,18 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ResourceJobManager getResourceJobManager(String resourceJobManagerId)
throws RegistryServiceException, TException {
try {
- return new ComputeResourceRepository().getResourceJobManager(resourceJobManagerId);
+ return registryService.getResourceJobManager(resourceJobManagerId);
} catch (AppCatalogException e) {
- logger.error(resourceJobManagerId, "Error while retrieving resource job manager...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving resource job manager. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving resource job manager");
}
}
@Override
public boolean deleteResourceJobManager(String resourceJobManagerId) throws RegistryServiceException, TException {
try {
- new ComputeResourceRepository().deleteResourceJobManager(resourceJobManagerId);
- return true;
+ return registryService.deleteResourceJobManager(resourceJobManagerId);
} catch (AppCatalogException e) {
- logger.error(resourceJobManagerId, "Error while deleting resource job manager...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting resource job manager. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting resource job manager");
}
}
@@ -2203,13 +1463,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteBatchQueue(String computeResourceId, String queueName)
throws RegistryServiceException, TException {
try {
- new ComputeResourceRepository().removeBatchQueue(computeResourceId, queueName);
- return true;
+ return registryService.deleteBatchQueue(computeResourceId, queueName);
} catch (AppCatalogException e) {
- logger.error(computeResourceId, "Error while deleting batch queue...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting batch queue. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting batch queue");
}
}
@@ -2224,19 +1480,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public GatewayResourceProfile getGatewayResourceProfile(String gatewayID)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- GatewayResourceProfile gatewayResourceProfile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
- logger.debug("Airavata retrieved gateway profile with gateway id : " + gatewayID);
- return gatewayResourceProfile;
- } catch (Exception e) {
- logger.error(gatewayID, "Error while retrieving gateway resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving gateway resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.getGatewayResourceProfile(gatewayID);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving gateway resource profile");
}
}
@@ -2250,19 +1496,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean deleteGatewayResourceProfile(String gatewayID) throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- gwyResourceProfileRepository.delete(gatewayID);
- logger.debug("Airavata deleted gateway profile with gateway id : " + gatewayID);
- return true;
- } catch (Exception e) {
- logger.error(gatewayID, "Error while removing gateway resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while removing gateway resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.deleteGatewayResourceProfile(gatewayID);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while removing gateway resource profile");
}
}
@@ -2278,41 +1514,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ComputeResourcePreference getGatewayComputeResourcePreference(String gatewayID, String computeResourceId)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- if (!gwyResourceProfileRepository.isGatewayResourceProfileExists(gatewayID)) {
- logger.error(
- gatewayID,
- "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
- throw exception;
- }
- if (!computeResourceRepository.isComputeResourceExists(computeResourceId)) {
- logger.error(
- computeResourceId,
- "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
- throw exception;
- }
- ComputeResourcePreference computeResourcePreference =
- gwyResourceProfileRepository.getComputeResourcePreference(gatewayID, computeResourceId);
- logger.debug("Airavata retrieved gateway compute resource preference with gateway id : " + gatewayID
- + " and for compute resoruce id : " + computeResourceId);
- return computeResourcePreference;
+ return registryService.getGatewayComputeResourcePreference(gatewayID, computeResourceId);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while reading gateway compute resource preference. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading gateway compute resource preference");
}
}
@@ -2328,31 +1532,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public StoragePreference getGatewayStoragePreference(String gatewayID, String storageId)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- if (!gwyResourceProfileRepository.isGatewayResourceProfileExists(gatewayID)) {
- logger.error(
- gatewayID,
- "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
- throw exception;
- }
-
- StoragePreference storagePreference =
- gwyResourceProfileRepository.getStoragePreference(gatewayID, storageId);
- logger.debug("Airavata retrieved storage resource preference with gateway id : " + gatewayID
- + " and for storage resource id : " + storageId);
- return storagePreference;
+ return registryService.getGatewayStoragePreference(gatewayID, storageId);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading gateway data storage preference. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading gateway data storage preference");
}
}
@@ -2367,18 +1549,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<ComputeResourcePreference> getAllGatewayComputeResourcePreferences(String gatewayID)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- return gwyResourceProfileRepository.getGatewayProfile(gatewayID).getComputeResourcePreferences();
- } catch (Exception e) {
- logger.error(gatewayID, "Error while reading gateway compute resource preferences...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while reading gateway compute resource preferences. More info : " + e.getMessage());
- throw exception;
+ return registryService.getAllGatewayComputeResourcePreferences(gatewayID);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while reading gateway compute resource preferences");
}
}
@@ -2393,17 +1566,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<StoragePreference> getAllGatewayStoragePreferences(String gatewayID)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- return gwyResourceProfileRepository.getGatewayProfile(gatewayID).getStoragePreferences();
- } catch (Exception e) {
- logger.error(gatewayID, "Error while reading gateway data storage preferences...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading gateway data storage preferences. More info : " + e.getMessage());
- throw exception;
+ return registryService.getAllGatewayStoragePreferences(gatewayID);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while reading gateway data storage preferences");
}
}
@@ -2416,12 +1581,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<GatewayResourceProfile> getAllGatewayResourceProfiles() throws RegistryServiceException, TException {
try {
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- return gwyResourceProfileRepository.getAllGatewayProfiles();
- } catch (Exception e) {
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading retrieving all gateway profiles. More info : " + e.getMessage());
- throw exception;
+ return registryService.getAllGatewayResourceProfiles();
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while reading retrieving all gateway profiles");
}
}
@@ -2437,20 +1599,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteGatewayComputeResourcePreference(String gatewayID, String computeResourceId)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
-
- return gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(
- gatewayID, computeResourceId);
- } catch (Exception e) {
- logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while updating gateway compute resource preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.deleteGatewayComputeResourcePreference(gatewayID, computeResourceId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating gateway compute resource preference");
}
}
@@ -2466,60 +1617,36 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteGatewayStoragePreference(String gatewayID, String storageId)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
-
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- return gwyResourceProfileRepository.removeDataStoragePreferenceFromGateway(gatewayID, storageId);
- } catch (Exception e) {
- logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating gateway data storage preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.deleteGatewayStoragePreference(gatewayID, storageId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating gateway data storage preference");
}
}
@Override
public DataProductModel getDataProduct(String productUri) throws RegistryServiceException, TException {
try {
- DataProductModel dataProductModel = dataProductRepository.getDataProduct(productUri);
- return dataProductModel;
+ return registryService.getDataProduct(productUri);
} catch (RegistryException e) {
- String msg = "Error in retreiving the data product " + productUri + ".";
- logger.error(msg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(msg + " More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error in retreiving the data product " + productUri);
}
}
@Override
public DataProductModel getParentDataProduct(String productUri) throws RegistryServiceException, TException {
try {
- DataProductModel dataProductModel = dataProductRepository.getParentDataProduct(productUri);
- return dataProductModel;
+ return registryService.getParentDataProduct(productUri);
} catch (RegistryException e) {
- String msg = "Error in retreiving the parent data product for " + productUri + ".";
- logger.error(msg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(msg + " More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error in retreiving the parent data product for " + productUri);
}
}
@Override
public List<DataProductModel> getChildDataProducts(String productUri) throws RegistryServiceException, TException {
try {
- List<DataProductModel> dataProductModels = dataProductRepository.getChildDataProducts(productUri);
- return dataProductModels;
+ return registryService.getChildDataProducts(productUri);
} catch (RegistryException e) {
- String msg = "Error in retreiving the child products for " + productUri + ".";
- logger.error(msg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(msg + " More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error in retreiving the child products for " + productUri);
}
}
@@ -2528,15 +1655,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String gatewayId, String userId, String productName, int limit, int offset)
throws RegistryServiceException, TException {
try {
- List<DataProductModel> dataProductModels =
- dataProductRepository.searchDataProductsByName(gatewayId, userId, productName, limit, offset);
- return dataProductModels;
+ return registryService.searchDataProductsByName(gatewayId, userId, productName, limit, offset);
} catch (RegistryException e) {
- String msg = "Error in searching the data products for name " + productName + ".";
- logger.error(msg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(msg + " More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error in searching the data products for name " + productName);
}
}
@@ -2544,20 +1665,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String createGroupResourceProfile(GroupResourceProfile groupResourceProfile)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(groupResourceProfile.getGatewayId())) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- String groupResourceProfileId =
- groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
- logger.debug("New Group Resource Profile Created: " + groupResourceProfileId);
- return groupResourceProfileId;
- } catch (Exception e) {
- logger.error("Error while creating group resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while creating group resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.createGroupResourceProfile(groupResourceProfile);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while creating group resource profile");
}
}
@@ -2565,24 +1675,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void updateGroupResourceProfile(GroupResourceProfile groupResourceProfile)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- if (!groupResourceProfileRepository.isGroupResourceProfileExists(
- groupResourceProfile.getGroupResourceProfileId())) {
- logger.error(
- "Cannot update. No group resource profile found with matching gatewayId and groupResourceProfileId");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Cannot update. No group resource profile found with matching gatewayId and groupResourceProfileId");
- throw exception;
- }
- String groupResourceProfileId =
- groupResourceProfileRepository.updateGroupResourceProfile(groupResourceProfile);
- logger.debug(" Group Resource Profile updated: " + groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while updating group resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating group resource profile. More info : " + e.getMessage());
- throw exception;
+ registryService.updateGroupResourceProfile(groupResourceProfile);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating group resource profile");
}
}
@@ -2590,21 +1685,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public GroupResourceProfile getGroupResourceProfile(String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- if (!groupResourceProfileRepository.isGroupResourceProfileExists(groupResourceProfileId)) {
- logger.error("No group resource profile found with matching gatewayId and groupResourceProfileId");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "No group resource profile found with matching gatewayId and groupResourceProfileId");
- throw exception;
- }
-
- return groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while retrieving group resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving group resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.getGroupResourceProfile(groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving group resource profile");
}
}
@@ -2612,13 +1695,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean isGroupResourceProfileExists(String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- return groupResourceProfileRepository.isGroupResourceProfileExists(groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while retrieving group resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving group resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.isGroupResourceProfileExists(groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving group resource profile");
}
}
@@ -2626,21 +1705,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean removeGroupResourceProfile(String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- if (!groupResourceProfileRepository.isGroupResourceProfileExists(groupResourceProfileId)) {
- logger.error(
- "Cannot Remove. No group resource profile found with matching gatewayId and groupResourceProfileId");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Cannot Remove. No group resource profile found with matching gatewayId and groupResourceProfileId");
- throw exception;
- }
- return groupResourceProfileRepository.removeGroupResourceProfile(groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while removing group resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while removing group resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.removeGroupResourceProfile(groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while removing group resource profile");
}
}
@@ -2648,13 +1715,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<GroupResourceProfile> getGroupResourceList(String gatewayId, List<String> accessibleGroupResProfileIds)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- return groupResourceProfileRepository.getAllGroupResourceProfiles(gatewayId, accessibleGroupResProfileIds);
- } catch (Exception e) {
- logger.error("Error while retrieving group resource list ", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving group resource list. More info : " + e.getMessage());
- throw exception;
+ return registryService.getGroupResourceList(gatewayId, accessibleGroupResProfileIds);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving group resource list");
}
}
@@ -2662,16 +1725,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean removeGroupComputePrefs(String computeResourceId, String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- groupResourceProfileRepository.removeGroupComputeResourcePreference(
- computeResourceId, groupResourceProfileId);
- logger.debug("Removed compute resource preferences with compute resource ID: " + computeResourceId);
- return true;
- } catch (Exception e) {
- logger.error("Error while removing group compute preference", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while removing group compute preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.removeGroupComputePrefs(computeResourceId, groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while removing group compute preference");
}
}
@@ -2679,15 +1735,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean removeGroupComputeResourcePolicy(String resourcePolicyId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- groupResourceProfileRepository.removeComputeResourcePolicy(resourcePolicyId);
- logger.debug("Removed compute resource policy with resource policy ID: " + resourcePolicyId);
- return true;
- } catch (Exception e) {
- logger.error("Error while removing group compute resource policy", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while removing group compute resource policy. More info : " + e.getMessage());
- throw exception;
+ return registryService.removeGroupComputeResourcePolicy(resourcePolicyId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while removing group compute resource policy");
}
}
@@ -2695,16 +1745,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean removeGroupBatchQueueResourcePolicy(String resourcePolicyId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- groupResourceProfileRepository.removeBatchQueueResourcePolicy(resourcePolicyId);
- logger.debug("Removed batch resource policy with resource policy ID: " + resourcePolicyId);
- return true;
- } catch (Exception e) {
- logger.error("Error while removing group batch queue resource policy", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while removing group batch queue resource policy. More info : " + e.getMessage());
- throw exception;
+ return registryService.removeGroupBatchQueueResourcePolicy(resourcePolicyId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while removing group batch queue resource policy");
}
}
@@ -2712,24 +1755,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public GroupComputeResourcePreference getGroupComputeResourcePreference(
String computeResourceId, String groupResourceProfileId) throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- GroupComputeResourcePreference groupComputeResourcePreference =
- groupResourceProfileRepository.getGroupComputeResourcePreference(
- computeResourceId, groupResourceProfileId);
- if (!(groupComputeResourcePreference != null)) {
- logger.error("GroupComputeResourcePreference not found");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("GroupComputeResourcePreference not found ");
- throw exception;
- }
- return groupComputeResourcePreference;
-
- } catch (Exception e) {
- logger.error("Error while retrieving group compute resource preference", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while retrieving group compute resource preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.getGroupComputeResourcePreference(computeResourceId, groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving group compute resource preference");
}
}
@@ -2737,15 +1765,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean isGroupComputeResourcePreferenceExists(String computeResourceId, String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- return groupResourceProfileRepository.isGroupComputeResourcePreferenceExists(
- computeResourceId, groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while retrieving group compute resource preference", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while retrieving group compute resource preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.isGroupComputeResourcePreferenceExists(computeResourceId, groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving group compute resource preference");
}
}
@@ -2753,21 +1775,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ComputeResourcePolicy getGroupComputeResourcePolicy(String resourcePolicyId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- ComputeResourcePolicy computeResourcePolicy =
- groupResourceProfileRepository.getComputeResourcePolicy(resourcePolicyId);
- if (!(computeResourcePolicy != null)) {
- logger.error("Group Compute Resource policy not found");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Group Compute Resource policy not found ");
- throw exception;
- }
- return computeResourcePolicy;
- } catch (Exception e) {
- logger.error("Error while retrieving group compute resource policy", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving group compute resource policy. More info : " + e.getMessage());
- throw exception;
+ return registryService.getGroupComputeResourcePolicy(resourcePolicyId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving group compute resource policy");
}
}
@@ -2775,21 +1785,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public BatchQueueResourcePolicy getBatchQueueResourcePolicy(String resourcePolicyId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- BatchQueueResourcePolicy batchQueueResourcePolicy =
- groupResourceProfileRepository.getBatchQueueResourcePolicy(resourcePolicyId);
- if (!(batchQueueResourcePolicy != null)) {
- logger.error("Group Batch Queue Resource policy not found");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Group Batch Queue Resource policy not found ");
- throw exception;
- }
- return batchQueueResourcePolicy;
- } catch (Exception e) {
- logger.error("Error while retrieving Batch Queue resource policy", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving Batch Queue resource policy. More info : " + e.getMessage());
- throw exception;
+ return registryService.getBatchQueueResourcePolicy(resourcePolicyId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving Batch Queue resource policy");
}
}
@@ -2797,15 +1795,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<GroupComputeResourcePreference> getGroupComputeResourcePrefList(String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- return groupResourceProfileRepository.getAllGroupComputeResourcePreferences(groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while retrieving retrieving Group Compute Resource Preference list", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while retrieving retrieving Group Compute Resource Preference list. More info : "
- + e.getMessage());
- throw exception;
+ return registryService.getGroupComputeResourcePrefList(groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving retrieving Group Compute Resource Preference list");
}
}
@@ -2813,15 +1805,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<BatchQueueResourcePolicy> getGroupBatchQueueResourcePolicyList(String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- return groupResourceProfileRepository.getAllGroupBatchQueueResourcePolicies(groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while retrieving retrieving Group Batch Queue Resource policy list", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while retrieving retrieving Group Batch Queue Resource policy list. More info : "
- + e.getMessage());
- throw exception;
+ return registryService.getGroupBatchQueueResourcePolicyList(groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving retrieving Group Batch Queue Resource policy list");
}
}
@@ -2829,14 +1815,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<ComputeResourcePolicy> getGroupComputeResourcePolicyList(String groupResourceProfileId)
throws RegistryServiceException, TException {
try {
- GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
- return groupResourceProfileRepository.getAllGroupComputeResourcePolicies(groupResourceProfileId);
- } catch (Exception e) {
- logger.error("Error while retrieving retrieving Group Compute Resource policy list", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving retrieving Group Compute Resource policy list. More info : "
- + e.getMessage());
- throw exception;
+ return registryService.getGroupComputeResourcePolicyList(groupResourceProfileId);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving retrieving Group Compute Resource policy list");
}
}
@@ -2844,14 +1825,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String registerReplicaLocation(DataReplicaLocationModel replicaLocationModel)
throws RegistryServiceException, TException {
try {
- String replicaId = dataReplicaLocationRepository.registerReplicaLocation(replicaLocationModel);
- return replicaId;
+ return registryService.registerReplicaLocation(replicaLocationModel);
} catch (RegistryException e) {
- String msg = "Error in retreiving the replica " + replicaLocationModel.getReplicaName() + ".";
- logger.error(msg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(msg + " More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error in retreiving the replica " + replicaLocationModel.getReplicaName());
}
}
@@ -2863,14 +1839,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public String registerDataProduct(DataProductModel dataProductModel) throws RegistryServiceException, TException {
try {
- String productUrl = dataProductRepository.registerDataProduct(dataProductModel);
- return productUrl;
+ return registryService.registerDataProduct(dataProductModel);
} catch (RegistryException e) {
- String msg = "Error in registering the data resource" + dataProductModel.getProductName() + ".";
- logger.error(msg, e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(msg + " More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error in registering the data resource" + dataProductModel.getProductName());
}
}
@@ -2888,33 +1859,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String gatewayID, String storageId, StoragePreference storagePreference)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
- List<StoragePreference> dataStoragePreferences = profile.getStoragePreferences();
- StoragePreference preferenceToRemove = null;
- for (StoragePreference preference : dataStoragePreferences) {
- if (preference.getStorageResourceId().equals(storageId)) {
- preferenceToRemove = preference;
- break;
- }
- }
- if (preferenceToRemove != null) {
- profile.getStoragePreferences().remove(preferenceToRemove);
- }
- profile.getStoragePreferences().add(storagePreference);
- gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
- logger.debug("Airavata updated storage resource preference with gateway id : " + gatewayID
- + " and for storage resource id : " + storageId);
- return true;
- } catch (Exception e) {
- logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating gateway data storage preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.updateGatewayStoragePreference(gatewayID, storageId, storagePreference);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating gateway data storage preference");
}
}
@@ -2932,34 +1879,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
- List<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences();
- ComputeResourcePreference preferenceToRemove = null;
- for (ComputeResourcePreference preference : computeResourcePreferences) {
- if (preference.getComputeResourceId().equals(computeResourceId)) {
- preferenceToRemove = preference;
- break;
- }
- }
- if (preferenceToRemove != null) {
- profile.getComputeResourcePreferences().remove(preferenceToRemove);
- }
- profile.getComputeResourcePreferences().add(computeResourcePreference);
- gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
- logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID
- + " and for compute resource id : " + computeResourceId);
- return true;
- } catch (Exception e) {
- logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while updating gateway compute resource preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.updateGatewayComputeResourcePreference(gatewayID, computeResourceId, computeResourcePreference);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating gateway compute resource preference");
}
}
@@ -2978,29 +1900,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String gatewayID, String storageResourceId, StoragePreference dataStoragePreference)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
-
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- if (!(gwyResourceProfileRepository.isExists(gatewayID))) {
- throw new RegistryServiceException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
- }
- GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
-
- dataStoragePreference.setStorageResourceId(storageResourceId);
- profile.addToStoragePreferences(dataStoragePreference);
- gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
- logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID
- + " and for storage resource id : " + storageResourceId);
- return true;
- } catch (Exception e) {
- logger.error(gatewayID, "Error while registering gateway resource profile preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while registering gateway resource profile preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.addGatewayStoragePreference(gatewayID, storageResourceId, dataStoragePreference);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while registering gateway resource profile preference");
}
}
@@ -3019,26 +1921,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- if (!(gwyResourceProfileRepository.isExists(gatewayID))) {
- throw new RegistryServiceException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
- }
- GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
- profile.addToComputeResourcePreferences(computeResourcePreference);
- gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
- logger.debug("Airavata added gateway compute resource preference with gateway id : " + gatewayID
- + " and for compute resource id : " + computeResourceId);
- return true;
- } catch (Exception e) {
- logger.error(gatewayID, "Error while registering gateway resource profile preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while registering gateway resource profile preference. More info : " + e.getMessage());
- throw exception;
+ return registryService.addGatewayComputeResourcePreference(gatewayID, computeResourceId, computeResourcePreference);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while registering gateway resource profile preference");
}
}
@@ -3054,19 +1939,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateGatewayResourceProfile(String gatewayID, GatewayResourceProfile gatewayResourceProfile)
throws RegistryServiceException, TException {
try {
- if (!isGatewayExistInternal(gatewayID)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- gwyResourceProfileRepository.updateGatewayResourceProfile(gatewayResourceProfile);
- logger.debug("Airavata updated gateway profile with gateway id : " + gatewayID);
- return true;
- } catch (Exception e) {
- logger.error(gatewayID, "Error while updating gateway resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating gateway resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.updateGatewayResourceProfile(gatewayID, gatewayResourceProfile);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating gateway resource profile");
}
}
@@ -3083,26 +1958,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String registerGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile)
throws RegistryServiceException, TException {
try {
- if (!validateString(gatewayResourceProfile.getGatewayID())) {
- logger.error("Cannot create gateway profile with empty gateway id");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Cannot create gateway profile with empty gateway id");
- throw exception;
- }
- if (!isGatewayExistInternal(gatewayResourceProfile.getGatewayID())) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
- String resourceProfile = gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
- logger.debug(
- "Airavata registered gateway profile with gateway id : " + gatewayResourceProfile.getGatewayID());
- return resourceProfile;
- } catch (Exception e) {
- logger.error("Error while registering gateway resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while registering gateway resource profile. More info : " + e.getMessage());
- throw exception;
+ return registryService.registerGatewayResourceProfile(gatewayResourceProfile);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while registering gateway resource profile");
}
}
@@ -3110,13 +1968,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateResourceJobManager(String resourceJobManagerId, ResourceJobManager updatedResourceJobManager)
throws RegistryServiceException, TException {
try {
- new ComputeResourceRepository().updateResourceJobManager(resourceJobManagerId, updatedResourceJobManager);
- return true;
+ return registryService.updateResourceJobManager(resourceJobManagerId, updatedResourceJobManager);
} catch (AppCatalogException e) {
- logger.error(resourceJobManagerId, "Error while updating resource job manager...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating resource job manager. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating resource job manager");
}
}
@@ -3124,12 +1978,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String registerResourceJobManager(ResourceJobManager resourceJobManager)
throws RegistryServiceException, TException {
try {
- return new ComputeResourceRepository().addResourceJobManager(resourceJobManager);
+ return registryService.registerResourceJobManager(resourceJobManager);
} catch (AppCatalogException e) {
- logger.error(resourceJobManager.getResourceJobManagerId(), "Error while adding resource job manager...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding resource job manager. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding resource job manager");
}
}
@@ -3145,27 +1996,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteDataMovementInterface(String resourceId, String dataMovementInterfaceId, DMType dmType)
throws RegistryServiceException, TException {
try {
- switch (dmType) {
- case COMPUTE_RESOURCE:
- new ComputeResourceRepository().removeDataMovementInterface(resourceId, dataMovementInterfaceId);
- logger.debug(
- "Airavata deleted data movement interface with interface id : " + dataMovementInterfaceId);
- return true;
- case STORAGE_RESOURCE:
- storageResourceRepository.removeDataMovementInterface(resourceId, dataMovementInterfaceId);
- logger.debug(
- "Airavata deleted data movement interface with interface id : " + dataMovementInterfaceId);
- return true;
- default:
- logger.error(
- "Unsupported data movement type specifies.. Please provide the correct data movement type... ");
- return false;
- }
+ return registryService.deleteDataMovementInterface(resourceId, dataMovementInterfaceId, dmType);
} catch (AppCatalogException e) {
- logger.error(dataMovementInterfaceId, "Error while deleting data movement interface...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while deleting data movement interface. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting data movement interface");
}
}
@@ -3202,24 +2035,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String computeResourceId, DMType dmType, int priorityOrder, GridFTPDataMovement gridFTPDataMovement)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String addDataMovementInterface = addDataMovementInterface(
- computeResourceRepository,
- computeResourceId,
- dmType,
- computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement),
- DataMovementProtocol.GridFTP,
- priorityOrder);
- logger.debug("Airavata registered GridFTP data movement for resource Id: " + computeResourceId);
- return addDataMovementInterface;
+ return registryService.addGridFTPDataMovementDetails(computeResourceId, dmType, priorityOrder, gridFTPDataMovement);
} catch (AppCatalogException e) {
- logger.error(
- computeResourceId, "Error while adding data movement interface to resource compute resource...", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding data movement interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding data movement interface to resource compute resource");
}
}
@@ -3256,22 +2074,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String resourceId, DMType dmType, int priorityOrder, UnicoreDataMovement unicoreDataMovement)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String movementInterface = addDataMovementInterface(
- computeResourceRepository,
- resourceId,
- dmType,
- computeResourceRepository.addUnicoreDataMovement(unicoreDataMovement),
- DataMovementProtocol.UNICORE_STORAGE_SERVICE,
- priorityOrder);
- logger.debug("Airavata registered UNICORE data movement for resource Id: " + resourceId);
- return movementInterface;
+ return registryService.addUnicoreDataMovementDetails(resourceId, dmType, priorityOrder, unicoreDataMovement);
} catch (AppCatalogException e) {
- logger.error(resourceId, "Error while adding data movement interface to resource compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding data movement interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding data movement interface to resource compute resource");
}
}
@@ -3288,19 +2093,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateSCPDataMovementDetails(String dataMovementInterfaceId, SCPDataMovement scpDataMovement)
throws RegistryServiceException, TException {
try {
- computeResourceRepository.updateScpDataMovement(scpDataMovement);
- logger.debug("Airavata updated SCP data movement with data movement id: " + dataMovementInterfaceId);
- return true;
- } catch (Exception e) {
- logger.error(
- dataMovementInterfaceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ return registryService.updateSCPDataMovementDetails(dataMovementInterfaceId, scpDataMovement);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating SCP data movement");
}
}
@@ -3321,22 +2116,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String resourceId, DMType dmType, int priorityOrder, SCPDataMovement scpDataMovement)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String movementInterface = addDataMovementInterface(
- computeResourceRepository,
- resourceId,
- dmType,
- computeResourceRepository.addScpDataMovement(scpDataMovement),
- DataMovementProtocol.SCP,
- priorityOrder);
- logger.debug("Airavata registered SCP data movement for resource Id: " + resourceId);
- return movementInterface;
+ return registryService.addSCPDataMovementDetails(resourceId, dmType, priorityOrder, scpDataMovement);
} catch (AppCatalogException e) {
- logger.error(resourceId, "Error while adding data movement interface to resource compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding data movement interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding data movement interface to resource compute resource");
}
}
@@ -3352,14 +2134,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateLocalDataMovementDetails(String dataMovementInterfaceId, LOCALDataMovement localDataMovement)
throws RegistryServiceException, TException {
try {
- computeResourceRepository.updateLocalDataMovement(localDataMovement);
- logger.debug("Airavata updated local data movement with data movement id: " + dataMovementInterfaceId);
- return true;
- } catch (Exception e) {
- logger.error(dataMovementInterfaceId, "Error while updating local data movement interface..", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating local data movement interface. More info : " + e.getMessage());
- throw exception;
+ return registryService.updateLocalDataMovementDetails(dataMovementInterfaceId, localDataMovement);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating local data movement interface");
}
}
@@ -3380,22 +2157,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String resourceId, DMType dataMoveType, int priorityOrder, LOCALDataMovement localDataMovement)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String movementInterface = addDataMovementInterface(
- computeResourceRepository,
- resourceId,
- dataMoveType,
- computeResourceRepository.addLocalDataMovement(localDataMovement),
- DataMovementProtocol.LOCAL,
- priorityOrder);
- logger.debug("Airavata registered local data movement for resource Id: " + resourceId);
- return movementInterface;
+ return registryService.addLocalDataMovementDetails(resourceId, dataMoveType, priorityOrder, localDataMovement);
} catch (AppCatalogException e) {
- logger.error(resourceId, "Error while adding data movement interface to resource resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding data movement interface to resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding data movement interface to resource");
}
}
@@ -3426,20 +2190,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateCloudJobSubmissionDetails(String jobSubmissionInterfaceId, CloudJobSubmission sshJobSubmission)
throws RegistryServiceException, TException {
try {
- computeResourceRepository.updateCloudJobSubmission(sshJobSubmission);
- logger.debug("Airavata updated Cloud job submission for job submission interface id: "
- + jobSubmissionInterfaceId);
- return true;
- } catch (Exception e) {
- logger.error(
- jobSubmissionInterfaceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ return registryService.updateCloudJobSubmissionDetails(jobSubmissionInterfaceId, sshJobSubmission);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating Cloud job submission");
}
}
@@ -3455,20 +2208,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateSSHJobSubmissionDetails(String jobSubmissionInterfaceId, SSHJobSubmission sshJobSubmission)
throws RegistryServiceException, TException {
try {
- computeResourceRepository.updateSSHJobSubmission(sshJobSubmission);
- logger.debug(
- "Airavata updated SSH job submission for job submission interface id: " + jobSubmissionInterfaceId);
- return true;
- } catch (Exception e) {
- logger.error(
- jobSubmissionInterfaceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ return registryService.updateSSHJobSubmissionDetails(jobSubmissionInterfaceId, sshJobSubmission);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating SSH job submission");
}
}
@@ -3500,25 +2242,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String computeResourceId, int priorityOrder, CloudJobSubmission cloudSubmission)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String submissionInterface = addJobSubmissionInterface(
- computeResourceRepository,
- computeResourceId,
- computeResourceRepository.addCloudJobSubmission(cloudSubmission),
- JobSubmissionProtocol.CLOUD,
- priorityOrder);
- logger.debug("Airavata registered Cloud job submission for compute resource id: " + computeResourceId);
- return submissionInterface;
+ return registryService.addCloudJobSubmissionDetails(computeResourceId, priorityOrder, cloudSubmission);
} catch (AppCatalogException e) {
- logger.error(
- computeResourceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding job submission interface to resource compute resource");
}
}
@@ -3537,22 +2263,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String computeResourceId, int priorityOrder, UnicoreJobSubmission unicoreJobSubmission)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String submissionInterface = addJobSubmissionInterface(
- computeResourceRepository,
- computeResourceId,
- computeResourceRepository.addUNICOREJobSubmission(unicoreJobSubmission),
- JobSubmissionProtocol.UNICORE,
- priorityOrder);
- logger.debug("Airavata registered UNICORE job submission for compute resource id: " + computeResourceId);
- return submissionInterface;
+ return registryService.addUNICOREJobSubmissionDetails(computeResourceId, priorityOrder, unicoreJobSubmission);
} catch (AppCatalogException e) {
- logger.error("Error while adding job submission interface to resource compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding job submission interface to resource compute resource");
}
}
@@ -3571,25 +2284,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String computeResourceId, int priorityOrder, SSHJobSubmission sshJobSubmission)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String submissionDetails = addJobSubmissionInterface(
- computeResourceRepository,
- computeResourceId,
- computeResourceRepository.addSSHJobSubmission(sshJobSubmission),
- JobSubmissionProtocol.SSH_FORK,
- priorityOrder);
- logger.debug("Airavata registered Fork job submission for compute resource id: " + computeResourceId);
- return submissionDetails;
+ return registryService.addSSHForkJobSubmissionDetails(computeResourceId, priorityOrder, sshJobSubmission);
} catch (AppCatalogException e) {
- logger.error(
- computeResourceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding job submission interface to resource compute resource");
}
}
@@ -3608,25 +2305,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String computeResourceId, int priorityOrder, SSHJobSubmission sshJobSubmission)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String submissionInterface = addJobSubmissionInterface(
- computeResourceRepository,
- computeResourceId,
- computeResourceRepository.addSSHJobSubmission(sshJobSubmission),
- JobSubmissionProtocol.SSH,
- priorityOrder);
- logger.debug("Airavata registered SSH job submission for compute resource id: " + computeResourceId);
- return submissionInterface;
+ return registryService.addSSHJobSubmissionDetails(computeResourceId, priorityOrder, sshJobSubmission);
} catch (AppCatalogException e) {
- logger.error(
- computeResourceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding job submission interface to resource compute resource");
}
}
@@ -3642,20 +2323,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateLocalSubmissionDetails(String jobSubmissionInterfaceId, LOCALSubmission localSubmission)
throws RegistryServiceException, TException {
try {
- computeResourceRepository.updateLocalJobSubmission(localSubmission);
- logger.debug("Airavata updated local job submission for job submission interface id: "
- + jobSubmissionInterfaceId);
- return true;
- } catch (Exception e) {
- logger.error(
- jobSubmissionInterfaceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ return registryService.updateLocalSubmissionDetails(jobSubmissionInterfaceId, localSubmission);
+ } catch (AppCatalogException e) {
+ throw convertToRegistryServiceException(e, "Error while updating local job submission");
}
}
@@ -3674,25 +2344,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String computeResourceId, int priorityOrder, LOCALSubmission localSubmission)
throws RegistryServiceException, TException {
try {
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- String submissionInterface = addJobSubmissionInterface(
- computeResourceRepository,
- computeResourceId,
- computeResourceRepository.addLocalJobSubmission(localSubmission),
- JobSubmissionProtocol.LOCAL,
- priorityOrder);
- logger.debug("Airavata added local job submission for compute resource id: " + computeResourceId);
- return submissionInterface;
+ return registryService.addLocalSubmissionDetails(computeResourceId, priorityOrder, localSubmission);
} catch (AppCatalogException e) {
- logger.error(
- computeResourceId,
- "Error while adding job submission interface to resource compute resource...",
- e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while adding job submission interface to resource compute resource. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding job submission interface to resource compute resource");
}
}
@@ -3709,14 +2363,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String storageResourceId, StorageResourceDescription storageResourceDescription)
throws RegistryServiceException, TException {
try {
- storageResourceRepository.updateStorageResource(storageResourceId, storageResourceDescription);
- logger.debug("Airavata updated storage resource with storage resource Id : " + storageResourceId);
- return true;
+ return registryService.updateStorageResource(storageResourceId, storageResourceDescription);
} catch (AppCatalogException e) {
- logger.error(storageResourceId, "Error while updating storage resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updaing storage resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating storage resource");
}
}
@@ -3731,14 +2380,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String registerStorageResource(StorageResourceDescription storageResourceDescription)
throws RegistryServiceException, TException {
try {
- String storageResource = storageResourceRepository.addStorageResource(storageResourceDescription);
- logger.debug("Airavata registered storage resource with storage resource Id : " + storageResource);
- return storageResource;
+ return registryService.registerStorageResource(storageResourceDescription);
} catch (AppCatalogException e) {
- logger.error("Error while saving storage resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while saving storage resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while saving storage resource");
}
}
@@ -3755,14 +2399,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String computeResourceId, ComputeResourceDescription computeResourceDescription)
throws RegistryServiceException, TException {
try {
- new ComputeResourceRepository().updateComputeResource(computeResourceId, computeResourceDescription);
- logger.debug("Airavata updated compute resource with compute resource Id : " + computeResourceId);
- return true;
+ return registryService.updateComputeResource(computeResourceId, computeResourceDescription);
} catch (AppCatalogException e) {
- logger.error(computeResourceId, "Error while updating compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updaing compute resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating compute resource");
}
}
@@ -3777,14 +2416,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String registerComputeResource(ComputeResourceDescription computeResourceDescription)
throws RegistryServiceException, TException {
try {
- String computeResource = new ComputeResourceRepository().addComputeResource(computeResourceDescription);
- logger.debug("Airavata registered compute resource with compute resource Id : " + computeResource);
- return computeResource;
+ return registryService.registerComputeResource(computeResourceDescription);
} catch (AppCatalogException e) {
- logger.error("Error while saving compute resource...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while saving compute resource. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while saving compute resource");
}
}
@@ -3801,14 +2435,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String appInterfaceId, ApplicationInterfaceDescription applicationInterface)
throws RegistryServiceException, TException {
try {
- applicationInterfaceRepository.updateApplicationInterface(appInterfaceId, applicationInterface);
- logger.debug("Airavata updated application interface with interface id : " + appInterfaceId);
- return true;
+ return registryService.updateApplicationInterface(appInterfaceId, applicationInterface);
} catch (AppCatalogException e) {
- logger.error(appInterfaceId, "Error while updating application interface...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating application interface. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating application interface");
}
}
@@ -3823,20 +2452,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public String registerApplicationInterface(String gatewayId, ApplicationInterfaceDescription applicationInterface)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- String interfaceId =
- applicationInterfaceRepository.addApplicationInterface(applicationInterface, gatewayId);
- logger.debug("Airavata registered application interface for gateway id : " + gatewayId);
- return interfaceId;
+ return registryService.registerApplicationInterface(gatewayId, applicationInterface);
} catch (AppCatalogException e) {
- logger.error("Error while adding application interface...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding application interface. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding application interface");
}
}
@@ -3853,14 +2472,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String appDeploymentId, ApplicationDeploymentDescription applicationDeployment)
throws RegistryServiceException, TException {
try {
- applicationDeploymentRepository.updateApplicationDeployment(appDeploymentId, applicationDeployment);
- logger.debug("Airavata updated application deployment for deployment id : " + appDeploymentId);
- return true;
+ return registryService.updateApplicationDeployment(appDeploymentId, applicationDeployment);
} catch (AppCatalogException e) {
- logger.error(appDeploymentId, "Error while updating application deployment...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating application deployment. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating application deployment");
}
}
@@ -3876,20 +2490,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String registerApplicationDeployment(
String gatewayId, ApplicationDeploymentDescription applicationDeployment)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- String deployment =
- applicationDeploymentRepository.addApplicationDeployment(applicationDeployment, gatewayId);
- logger.debug("Airavata registered application deployment for gateway id : " + gatewayId);
- return deployment;
+ return registryService.registerApplicationDeployment(gatewayId, applicationDeployment);
} catch (AppCatalogException e) {
- logger.error("Error while adding application deployment...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding application deployment. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding application deployment");
}
}
@@ -3905,14 +2509,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateApplicationModule(String appModuleId, ApplicationModule applicationModule)
throws RegistryServiceException, TException {
try {
- applicationInterfaceRepository.updateApplicationModule(appModuleId, applicationModule);
- logger.debug("Airavata updated application module with module id: " + appModuleId);
- return true;
+ return registryService.updateApplicationModule(appModuleId, applicationModule);
} catch (AppCatalogException e) {
- logger.error(appModuleId, "Error while updating application module...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating application module. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating application module");
}
}
@@ -3928,19 +2527,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public String registerApplicationModule(String gatewayId, ApplicationModule applicationModule)
throws RegistryServiceException, TException {
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
try {
- String module = applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
- logger.debug("Airavata registered application module for gateway id : " + gatewayId);
- return module;
+ return registryService.registerApplicationModule(gatewayId, applicationModule);
} catch (AppCatalogException e) {
- logger.error("Error while adding application module...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding application module. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding application module");
}
}
@@ -3949,52 +2539,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String airavataExperimentId, ComputationalResourceSchedulingModel resourceScheduling)
throws RegistryServiceException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- logger.debug(
- airavataExperimentId,
- "Update resource scheduling failed, experiment {} doesn't exist.",
- airavataExperimentId);
- throw new ExperimentNotFoundException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
- if (experimentStatus != null) {
- ExperimentState experimentState = experimentStatus.getState();
- switch (experimentState) {
- case CREATED:
- case VALIDATED:
- case CANCELED:
- case FAILED:
- processRepository.addProcessResourceSchedule(resourceScheduling, airavataExperimentId);
- logger.debug(
- airavataExperimentId,
- "Successfully updated resource scheduling for the experiment {}.",
- airavataExperimentId);
- break;
- default:
- logger.error(
- airavataExperimentId,
- "Error while updating scheduling info. Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... ");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage(
- "Error while updating experiment. Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... ");
- throw exception;
- }
- }
- } catch (Exception e) {
- logger.error(airavataExperimentId, "Error while updating scheduling info", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while updating scheduling info. " + "Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... "
- + e.getMessage());
- throw exception;
+ registryService.updateResourceScheduleing(airavataExperimentId, resourceScheduling);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while updating scheduling info");
}
}
@@ -4002,53 +2549,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void updateExperimentConfiguration(String airavataExperimentId, UserConfigurationDataModel userConfiguration)
throws RegistryServiceException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- logger.error(
- airavataExperimentId,
- "Update experiment configuration failed, experiment {} doesn't exist.",
- airavataExperimentId);
- throw new ExperimentNotFoundException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
- if (experimentStatus != null) {
- ExperimentState experimentState = experimentStatus.getState();
- switch (experimentState) {
- case CREATED:
- case VALIDATED:
- case CANCELED:
- case FAILED:
- experimentRepository.addUserConfigurationData(userConfiguration, airavataExperimentId);
- logger.debug(
- airavataExperimentId,
- "Successfully updated experiment configuration for experiment {}.",
- airavataExperimentId);
- break;
- default:
- logger.error(
- airavataExperimentId,
- "Error while updating experiment {}. Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... ",
- airavataExperimentId);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage(
- "Error while updating experiment. Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... ");
- throw exception;
- }
- }
- } catch (Exception e) {
- logger.error(airavataExperimentId, "Error while updating user configuration", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while updating user configuration. " + "Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... "
- + e.getMessage());
- throw exception;
+ registryService.updateExperimentConfiguration(airavataExperimentId, userConfiguration);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while updating user configuration");
}
}
@@ -4080,74 +2583,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void updateExperiment(String airavataExperimentId, ExperimentModel experiment)
throws RegistryServiceException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- logger.error(
- airavataExperimentId,
- "Update request failed, Experiment {} doesn't exist.",
- airavataExperimentId);
- throw new RegistryServiceException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
-
- ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
- if (experimentStatus != null) {
- ExperimentState experimentState = experimentStatus.getState();
- switch (experimentState) {
- case CREATED:
- case SCHEDULED:
- case VALIDATED:
- if (experiment.getUserConfigurationData() != null
- && experiment.getUserConfigurationData().getComputationalResourceScheduling() != null
- && experiment
- .getUserConfigurationData()
- .getComputationalResourceScheduling()
- .getResourceHostId()
- != null) {
- String compResourceId = experiment
- .getUserConfigurationData()
- .getComputationalResourceScheduling()
- .getResourceHostId();
- ComputeResourceDescription computeResourceDescription =
- new ComputeResourceRepository().getComputeResource(compResourceId);
- if (!computeResourceDescription.isEnabled()) {
- logger.error("Compute Resource is not enabled by the Admin!");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Compute Resource is not enabled by the Admin!");
- throw exception;
- }
- }
- experimentRepository.updateExperiment(experiment, airavataExperimentId);
- logger.debug(
- airavataExperimentId,
- "Successfully updated experiment {} ",
- experiment.getExperimentName());
- break;
- default:
- logger.error(
- airavataExperimentId,
- "Error while updating experiment. Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... ");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage(
- "Error while updating experiment. Update experiment is only valid for experiments "
- + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
- + "experiment is in one of above statuses... ");
- throw exception;
- }
- }
+ registryService.updateExperiment(airavataExperimentId, experiment);
} catch (RegistryException e) {
- logger.error(airavataExperimentId, "Error while updating experiment", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating experiment. More info : " + e.getMessage());
- throw exception;
- } catch (AppCatalogException e) {
- logger.error(airavataExperimentId, "Error while updating experiment", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating experiment. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating experiment");
}
}
@@ -4199,74 +2637,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String createExperiment(String gatewayId, ExperimentModel experiment)
throws RegistryServiceException, TException {
try {
- if (!validateString(experiment.getExperimentName())) {
- logger.error("Cannot create experiments with empty experiment name");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Cannot create experiments with empty experiment name");
- throw exception;
- }
- logger.info("Creating experiment with name " + experiment.getExperimentName());
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
-
- if (experiment.getUserConfigurationData() != null
- && experiment.getUserConfigurationData().getComputationalResourceScheduling() != null
- && experiment
- .getUserConfigurationData()
- .getComputationalResourceScheduling()
- .getResourceHostId()
- != null) {
-
- String compResourceId = experiment
- .getUserConfigurationData()
- .getComputationalResourceScheduling()
- .getResourceHostId();
- ComputeResourceDescription computeResourceDescription =
- new ComputeResourceRepository().getComputeResource(compResourceId);
- if (!computeResourceDescription.isEnabled()) {
- logger.error("Compute Resource is not enabled by the Admin!");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Compute Resource is not enabled by the Admin!");
- throw exception;
- }
- } else if (!experiment
- .getUserConfigurationData()
- .getAutoScheduledCompResourceSchedulingList()
- .isEmpty()) {
- for (ComputationalResourceSchedulingModel computationalResourceScheduling :
- experiment.getUserConfigurationData().getAutoScheduledCompResourceSchedulingList()) {
- ComputeResourceDescription computeResourceDescription = new ComputeResourceRepository()
- .getComputeResource(computationalResourceScheduling.getResourceHostId());
- if (!computeResourceDescription.isEnabled()) {
- logger.error("Compute Resource with id" + computationalResourceScheduling.getResourceHostId()
- + "" + " is not enabled by the Admin!");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage(
- "Compute Resource with id" + computationalResourceScheduling.getResourceHostId() + ""
- + " is not enabled by the Admin!");
- throw exception;
- }
- }
- }
-
- experiment.setGatewayId(gatewayId);
- String experimentId = experimentRepository.addExperiment(experiment);
- if (experiment.getExperimentType() == ExperimentType.WORKFLOW) {
- workflowRepository.registerWorkflow(experiment.getWorkflow(), experimentId);
- }
- logger.debug(
- experimentId, "Created new experiment with experiment name {}", experiment.getExperimentName());
- return experimentId;
- } catch (Exception e) {
- logger.error("Error while creating the experiment with experiment name {}", experiment.getExperimentName());
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while creating the experiment. More info : " + e.getMessage());
- throw exception;
+ return registryService.createExperiment(gatewayId, experiment);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while creating the experiment");
}
}
@@ -4291,69 +2664,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
int limit,
int offset)
throws RegistryServiceException, TException {
- if (!validateString(userName)) {
- logger.error("Username cannot be empty. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Username cannot be empty. Please provide a valid user..");
- throw exception;
- }
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
try {
- if (!userRepository.isUserExists(gatewayId, userName)) {
- logger.error("User does not exist in the system. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("User does not exist in the system. Please provide a valid user..");
- throw exception;
- }
- List<ExperimentSummaryModel> summaries = new ArrayList<ExperimentSummaryModel>();
- Map<String, String> regFilters = new HashMap();
- regFilters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);
- for (Map.Entry<ExperimentSearchFields, String> entry : filters.entrySet()) {
- if (entry.getKey().equals(ExperimentSearchFields.EXPERIMENT_NAME)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.EXPERIMENT_DESC)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.DESCRIPTION, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.APPLICATION_ID)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.STATUS)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.FROM_DATE)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.TO_DATE)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.PROJECT_ID)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.PROJECT_ID, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.USER_NAME)) {
- regFilters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, entry.getValue());
- } else if (entry.getKey().equals(ExperimentSearchFields.JOB_ID)) {
- regFilters.put(Constants.FieldConstants.JobConstants.JOB_ID, entry.getValue());
- }
- }
-
- if (accessibleExpIds.size() == 0 && !ServerSettings.isEnableSharing()) {
- if (!regFilters.containsKey(DBConstants.Experiment.USER_NAME)) {
- regFilters.put(DBConstants.Experiment.USER_NAME, userName);
- }
- }
- summaries = experimentSummaryRepository.searchAllAccessibleExperiments(
- accessibleExpIds,
- regFilters,
- limit,
- offset,
- Constants.FieldConstants.ExperimentConstants.CREATION_TIME,
- ResultOrderType.DESC);
- logger.debug("Airavata retrieved experiments for user : " + userName + " and gateway id : " + gatewayId);
- return summaries;
- } catch (Exception e) {
- logger.error("Error while retrieving experiments", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving experiments. More info : " + e.getMessage());
- throw exception;
+ return registryService.searchExperiments(gatewayId, userName, accessibleExpIds, filters, limit, offset);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving experiments");
}
}
@@ -4377,56 +2691,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
int limit,
int offset)
throws RegistryServiceException, TException {
- if (!validateString(userName)) {
- logger.error("Username cannot be empty. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Username cannot be empty. Please provide a valid user..");
- throw exception;
- }
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
try {
- if (!userRepository.isUserExists(gatewayId, userName)) {
- logger.error("User does not exist in the system. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("User does not exist in the system. Please provide a valid user..");
- throw exception;
- }
- List<Project> projects = new ArrayList<>();
- Map<String, String> regFilters = new HashMap<>();
- regFilters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
- for (Map.Entry<ProjectSearchFields, String> entry : filters.entrySet()) {
- if (entry.getKey().equals(ProjectSearchFields.PROJECT_NAME)) {
- regFilters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, entry.getValue());
- } else if (entry.getKey().equals(ProjectSearchFields.PROJECT_DESCRIPTION)) {
- regFilters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, entry.getValue());
- }
- }
-
- if (accessibleProjIds.size() == 0 && !ServerSettings.isEnableSharing()) {
- if (!regFilters.containsKey(DBConstants.Project.OWNER)) {
- regFilters.put(DBConstants.Project.OWNER, userName);
- }
- }
-
- projects = projectRepository.searchAllAccessibleProjects(
- accessibleProjIds,
- regFilters,
- limit,
- offset,
- Constants.FieldConstants.ProjectConstants.CREATION_TIME,
- ResultOrderType.DESC);
- logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId);
- return projects;
- } catch (Exception e) {
- logger.error("Error while retrieving projects", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving projects. More info : " + e.getMessage());
- throw exception;
+ return registryService.searchProjects(gatewayId, userName, accessibleProjIds, filters, limit, offset);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving projects");
}
}
@@ -4440,28 +2708,10 @@ public class RegistryServerHandler implements RegistryService.Iface {
*/
@Override
public void updateProject(String projectId, Project updatedProject) throws RegistryServiceException, TException {
- if (!validateString(projectId) || !validateString(projectId)) {
- logger.error("Project id cannot be empty...");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Project id cannot be empty...");
- throw exception;
- }
try {
- if (!projectRepository.isProjectExist(projectId)) {
- logger.error("Project does not exist in the system. Please provide a valid project ID...");
- ProjectNotFoundException exception = new ProjectNotFoundException();
- exception.setMessage("Project does not exist in the system. Please provide a valid project ID...");
- throw exception;
- }
-
- projectRepository.updateProject(updatedProject, projectId);
- logger.debug("Airavata updated project with project Id : " + projectId);
+ registryService.updateProject(projectId, updatedProject);
} catch (RegistryException e) {
- logger.error("Error while updating the project", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating the project. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating the project");
}
}
@@ -4475,38 +2725,18 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public String createProject(String gatewayId, Project project) throws RegistryServiceException, TException {
try {
- if (!validateString(project.getName()) || !validateString(project.getOwner())) {
- logger.error("Project name and owner cannot be empty...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- if (!validateString(gatewayId)) {
- logger.error("Gateway ID cannot be empty...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- if (!isGatewayExistInternal(gatewayId)) {
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- String projectId = projectRepository.addProject(project, gatewayId);
- return projectId;
- } catch (Exception e) {
- logger.error("Error while creating the project", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while creating the project. More info : " + e.getMessage());
- throw exception;
+ return registryService.createProject(gatewayId, project);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while creating the project");
}
}
@Override
public boolean updateNotification(Notification notification) throws RegistryServiceException, TException {
try {
- notificationRepository.updateNotification(notification);
- return true;
+ return registryService.updateNotification(notification);
} catch (RegistryException e) {
- logger.error("Error while updating notification", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while getting gateway. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating notification");
}
}
@@ -4519,12 +2749,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public String createNotification(Notification notification) throws RegistryServiceException, TException {
try {
- return notificationRepository.createNotification(notification);
+ return registryService.createNotification(notification);
} catch (RegistryException e) {
- logger.error("Error while creating notification", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while creating notification. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while creating notification");
}
}
@@ -4540,38 +2767,11 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public boolean updateGateway(String gatewayId, Gateway updatedGateway) throws RegistryServiceException, TException {
try {
- if (!gatewayRepository.isGatewayExist(gatewayId)) {
- logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
- throw exception;
- }
- gatewayRepository.updateGateway(gatewayId, updatedGateway);
-
- // check if gatewayprofile exists and check if the identity server password token equals the admin password
- // token, if not update
- GatewayResourceProfile existingGwyResourceProfile =
- new GwyResourceProfileRepository().getGatewayProfile(gatewayId);
- if (existingGwyResourceProfile.getIdentityServerPwdCredToken() == null
- || !existingGwyResourceProfile
- .getIdentityServerPwdCredToken()
- .equals(updatedGateway.getIdentityServerPasswordToken())) {
- existingGwyResourceProfile.setIdentityServerPwdCredToken(
- updatedGateway.getIdentityServerPasswordToken());
- new GwyResourceProfileRepository().updateGatewayResourceProfile(gatewayId, existingGwyResourceProfile);
- }
- logger.debug("Airavata update gateway with gateway id : " + gatewayId);
- return true;
+ return registryService.updateGateway(gatewayId, updatedGateway);
} catch (RegistryException e) {
- logger.error("Error while updating the gateway", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating the gateway. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating the gateway");
} catch (AppCatalogException e) {
- logger.error("Error while updating gateway profile", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating gateway profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating gateway profile");
}
}
@@ -4585,42 +2785,11 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public String addGateway(Gateway gateway) throws RegistryServiceException, DuplicateEntryException, TException {
try {
- if (!validateString(gateway.getGatewayId())) {
- logger.error("Gateway id cannot be empty...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- // check if gateway exists
- if (isGatewayExist(gateway.getGatewayId())) {
- throw new DuplicateEntryException(
- "Gateway with gatewayId: " + gateway.getGatewayId() + ", already exists in ExperimentCatalog.");
- }
- // check if gatewayresourceprofile exists
- if (new GwyResourceProfileRepository().isGatewayResourceProfileExists(gateway.getGatewayId())) {
- throw new DuplicateEntryException("GatewayResourceProfile with gatewayId: " + gateway.getGatewayId()
- + ", already exists in AppCatalog.");
- }
-
- // add gateway in experiment catalog
- String gatewayId = gatewayRepository.addGateway(gateway);
-
- // add gatewayresourceprofile in appCatalog
- GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
- gatewayResourceProfile.setGatewayID(gatewayId);
- gatewayResourceProfile.setIdentityServerTenant(gatewayId);
- gatewayResourceProfile.setIdentityServerPwdCredToken(gateway.getIdentityServerPasswordToken());
- new GwyResourceProfileRepository().addGatewayResourceProfile(gatewayResourceProfile);
- logger.debug("Airavata added gateway with gateway id : " + gateway.getGatewayId());
- return gatewayId;
+ return registryService.addGateway(gateway);
} catch (RegistryException e) {
- logger.error("Error while adding gateway", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding gateway. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding gateway");
} catch (AppCatalogException e) {
- logger.error("Error while adding gateway profile", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while adding gateway profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while adding gateway profile");
}
}
@@ -4637,7 +2806,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException,
TException {
try {
- return gatewayRepository.isGatewayExist(gatewayId);
+ return registryService.isGatewayExist(gatewayId);
} catch (RegistryException e) {
logger.error("Error while getting gateway", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -4652,11 +2821,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException,
AiravataSystemException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- throw new ExperimentNotFoundException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- return experimentRepository.getExperiment(airavataExperimentId);
+ return registryService.getExperiment(airavataExperimentId);
} catch (RegistryException e) {
logger.error("Error while retrieving the experiment", e);
RegistryServiceException exception = new RegistryServiceException();
@@ -4670,16 +2835,8 @@ public class RegistryServerHandler implements RegistryService.Iface {
throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException,
AiravataSystemException, TException {
try {
- if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
- logger.error(
- airavataExperimentId,
- "Error while retrieving experiment status, experiment {} doesn't exist.",
- airavataExperimentId);
- throw new ExperimentNotFoundException(
- "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- return experimentStatusRepository.getExperimentStatus(airavataExperimentId);
- } catch (Exception e) {
+ return registryService.getExperimentStatus(airavataExperimentId);
+ } catch (RegistryException e) {
logger.error(airavataExperimentId, "Error while retrieving the experiment status", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -4692,10 +2849,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
private List<OutputDataObjectType> getApplicationOutputsInternal(String appInterfaceId)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
try {
- List<OutputDataObjectType> applicationOutputs =
- applicationInterfaceRepository.getApplicationOutputs(appInterfaceId);
- logger.debug("Airavata retrieved application outputs for application interface id : " + appInterfaceId);
- return applicationOutputs;
+ return registryService.getApplicationOutputs(appInterfaceId);
} catch (AppCatalogException e) {
logger.error(appInterfaceId, "Error while retrieving application outputs...", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -4705,40 +2859,6 @@ public class RegistryServerHandler implements RegistryService.Iface {
}
}
- private String addJobSubmissionInterface(
- ComputeResourceRepository computeResourceRepository,
- String computeResourceId,
- String jobSubmissionInterfaceId,
- JobSubmissionProtocol protocolType,
- int priorityOrder)
- throws AppCatalogException {
- JobSubmissionInterface jobSubmissionInterface = new JobSubmissionInterface();
- jobSubmissionInterface.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
- jobSubmissionInterface.setPriorityOrder(priorityOrder);
- jobSubmissionInterface.setJobSubmissionProtocol(protocolType);
- return computeResourceRepository.addJobSubmissionProtocol(computeResourceId, jobSubmissionInterface);
- }
-
- private String addDataMovementInterface(
- ComputeResource computeResource,
- String computeResourceId,
- DMType dmType,
- String dataMovementInterfaceId,
- DataMovementProtocol protocolType,
- int priorityOrder)
- throws AppCatalogException {
- DataMovementInterface dataMovementInterface = new DataMovementInterface();
- dataMovementInterface.setDataMovementInterfaceId(dataMovementInterfaceId);
- dataMovementInterface.setPriorityOrder(priorityOrder);
- dataMovementInterface.setDataMovementProtocol(protocolType);
- 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;
- }
/**
* Register a User Resource Profile.
@@ -4753,37 +2873,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String registerUserResourceProfile(UserResourceProfile userResourceProfile)
throws RegistryServiceException, TException {
try {
- if (!validateString(userResourceProfile.getUserId())) {
- logger.error("Cannot create user resource profile with empty user id");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Cannot create user resource profile with empty gateway id");
- throw exception;
- }
- if (!validateString(userResourceProfile.getGatewayID())) {
- logger.error("Cannot create user resource profile with empty gateway id");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Cannot create user resource profile with empty gateway id");
- throw exception;
- }
-
- if (!userRepository.isUserExists(userResourceProfile.getGatewayID(), userResourceProfile.getUserId())) {
- logger.error("User does not exist.Please provide a valid user ID...");
- throw new RegistryServiceException("User does not exist.Please provide a valid user ID...");
- }
- String resourceProfile = userResourceProfileRepository.addUserResourceProfile(userResourceProfile);
- logger.debug("Airavata registered user resource profile with gateway id : "
- + userResourceProfile.getGatewayID() + "and user id : " + userResourceProfile.getUserId());
- return resourceProfile;
+ return registryService.registerUserResourceProfile(userResourceProfile);
} catch (AppCatalogException e) {
- logger.error("Error while registering user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while registering user resource profile. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error("Error while registering user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while registering user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while registering user resource profile");
}
}
@@ -4791,23 +2883,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean isUserResourceProfileExists(String userId, String gatewayId)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayId, userId)) {
- logger.error("user does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- return userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayId);
+ return registryService.isUserResourceProfileExists(userId, gatewayId);
} catch (AppCatalogException e) {
- logger.error("Error while checking existence of user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while checking existence of user resource profile. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error("Error while checking existence of user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while checking existence of user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while checking existence of user resource profile");
}
}
@@ -4821,24 +2899,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public UserResourceProfile getUserResourceProfile(String userId, String gatewayId)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayId, userId)) {
- logger.error("user does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- UserResourceProfile userResourceProfile =
- userResourceProfileRepository.getUserResourceProfile(userId, gatewayId);
- logger.debug("Airavata retrieved User resource profile with user id : " + userId);
- return userResourceProfile;
+ return registryService.getUserResourceProfile(userId, gatewayId);
} catch (AppCatalogException e) {
- logger.error("Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error("Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving user resource profile");
}
}
@@ -4854,23 +2917,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean updateUserResourceProfile(String userId, String gatewayID, UserResourceProfile userResourceProfile)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("User does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, userResourceProfile);
- logger.debug("Airavata updated gateway profile with gateway id : " + userId);
- return true;
+ return registryService.updateUserResourceProfile(userId, gatewayID, userResourceProfile);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while updating gateway resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating gateway resource profile. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating gateway resource profile");
}
}
@@ -4886,23 +2935,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteUserResourceProfile(String userId, String gatewayID)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- userResourceProfileRepository.removeUserResourceProfile(userId, gatewayID);
- logger.debug("Airavata deleted User profile with gateway id : " + gatewayID + " and user id : " + userId);
- return true;
+ return registryService.deleteUserResourceProfile(userId, gatewayID);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while removing User resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while removing User resource profile. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while removing User resource profile");
}
}
@@ -4910,18 +2945,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public String addUser(UserProfile userProfile)
throws RegistryServiceException, DuplicateEntryException, TException {
try {
- logger.info("Adding User in Registry: " + userProfile);
- if (isUserExists(userProfile.getGatewayId(), userProfile.getUserId())) {
- throw new DuplicateEntryException("User already exists, with userId: " + userProfile.getUserId()
- + ", and gatewayId: " + userProfile.getGatewayId());
- }
- UserProfile savedUser = userRepository.addUser(userProfile);
- return savedUser.getUserId();
+ return registryService.addUser(userProfile);
} catch (RegistryException ex) {
- logger.error("Error while adding user in registry: " + ex, ex);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage("Error while adding user in registry: " + ex.getMessage());
- throw rse;
+ throw convertToRegistryServiceException(ex, "Error while adding user in registry");
}
}
@@ -4944,32 +2970,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
UserComputeResourcePreference userComputeResourcePreference)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
- throw new RegistryServiceException("User resource profile with user id'" + userId + " & gateway Id"
- + gatewayID + "' does not exist!!!");
- }
- UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
- // gatewayProfile.removeGatewayResourceProfile(gatewayID);
- profile.addToUserComputeResourcePreferences(userComputeResourcePreference);
- userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
- logger.debug("Airavata added User compute resource preference with gateway id : " + gatewayID
- + " and for compute resource id : " + computeResourceId);
- return true;
+ return registryService.addUserComputeResourcePreference(userId, gatewayID, computeResourceId, userComputeResourcePreference);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while registering User resource profile preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while registering user resource profile preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while registering user resource profile preference");
}
}
@@ -4986,22 +2989,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean isUserComputeResourcePreferenceExists(String userId, String gatewayID, String computeResourceId)
throws RegistryServiceException, TException {
try {
- if (userRepository.isUserExists(gatewayID, userId)
- && userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
- return userResourceProfileRepository.isUserComputeResourcePreferenceExists(
- userId, gatewayID, computeResourceId);
- }
- return false;
+ return registryService.isUserComputeResourcePreferenceExists(userId, gatewayID, computeResourceId);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while fetching compute resource preference", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while fetching compute resource preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while fetching compute resource preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while fetching compute resource preference. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while fetching compute resource preference");
}
}
@@ -5020,33 +3010,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String userId, String gatewayID, String storageResourceId, UserStoragePreference dataStoragePreference)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
- throw new RegistryServiceException("User resource profile with user id'" + userId + " & gateway Id"
- + gatewayID + "' does not exist!!!");
- }
- UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
- // gatewayProfile.removeGatewayResourceProfile(gatewayID);
- dataStoragePreference.setStorageResourceId(storageResourceId);
- profile.addToUserStoragePreferences(dataStoragePreference);
- userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
- logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID
- + " and for storage resource id : " + storageResourceId);
- return true;
+ return registryService.addUserStoragePreference(userId, gatewayID, storageResourceId, dataStoragePreference);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while registering user resource profile preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while registering user resource profile preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while registering user resource profile preference");
}
}
@@ -5063,40 +3029,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public UserComputeResourcePreference getUserComputeResourcePreference(
String userId, String gatewayID, String userComputeResourceId) throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
- throw new RegistryServiceException("User resource profile with user id'" + userId + " & gateway Id"
- + gatewayID + "' does not exist!!!");
- }
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
- if (!computeResourceRepository.isComputeResourceExists(userComputeResourceId)) {
- logger.error(
- userComputeResourceId,
- "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
- throw exception;
- }
- UserComputeResourcePreference userComputeResourcePreference =
- userResourceProfileRepository.getUserComputeResourcePreference(
- userId, gatewayID, userComputeResourceId);
- logger.debug("Airavata retrieved user compute resource preference with gateway id : " + gatewayID
- + " and for compute resoruce id : " + userComputeResourceId);
- return userComputeResourcePreference;
+ return registryService.getUserComputeResourcePreference(userId, gatewayID, userComputeResourceId);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while reading user compute resource preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading user compute resource preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading user compute resource preference");
}
}
@@ -5113,30 +3048,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public UserStoragePreference getUserStoragePreference(String userId, String gatewayID, String storageId)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
- throw new RegistryServiceException("User resource profile with user id'" + userId + " & gateway Id"
- + gatewayID + "' does not exist!!!");
- }
-
- UserStoragePreference storagePreference =
- userResourceProfileRepository.getUserStoragePreference(userId, gatewayID, storageId);
- logger.debug("Airavata retrieved user storage resource preference with gateway id : " + gatewayID
- + " and for storage resource id : " + storageId);
- return storagePreference;
+ return registryService.getUserStoragePreference(userId, gatewayID, storageId);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading gateway data storage preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading gateway data storage preference");
}
}
@@ -5149,11 +3063,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<UserResourceProfile> getAllUserResourceProfiles() throws RegistryServiceException, TException {
try {
- return userResourceProfileRepository.getAllUserResourceProfiles();
+ return registryService.getAllUserResourceProfiles();
} catch (AppCatalogException e) {
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading retrieving all gateway profiles. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading retrieving all gateway profiles");
}
}
@@ -5175,39 +3087,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
UserComputeResourcePreference userComputeResourcePreference)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
- List<UserComputeResourcePreference> userComputeResourcePreferences =
- profile.getUserComputeResourcePreferences();
- UserComputeResourcePreference preferenceToRemove = null;
- for (UserComputeResourcePreference preference : userComputeResourcePreferences) {
- if (preference.getComputeResourceId().equals(computeResourceId)) {
- preferenceToRemove = preference;
- break;
- }
- }
- if (preferenceToRemove != null) {
- profile.getUserComputeResourcePreferences().remove(preferenceToRemove);
- }
- profile.getUserComputeResourcePreferences().add(userComputeResourcePreference);
- userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
- logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID
- + " and for compute resource id : " + computeResourceId);
- return true;
+ return registryService.updateUserComputeResourcePreference(userId, gatewayID, computeResourceId, userComputeResourcePreference);
} catch (AppCatalogException e) {
- logger.error(userId, "Error while reading user compute resource preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while updating user compute resource preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating user compute resource preference");
}
}
@@ -5226,37 +3108,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
String userId, String gatewayID, String storageId, UserStoragePreference userStoragePreference)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
- List<UserStoragePreference> dataStoragePreferences = profile.getUserStoragePreferences();
- UserStoragePreference preferenceToRemove = null;
- for (UserStoragePreference preference : dataStoragePreferences) {
- if (preference.getStorageResourceId().equals(storageId)) {
- preferenceToRemove = preference;
- break;
- }
- }
- if (preferenceToRemove != null) {
- profile.getUserStoragePreferences().remove(preferenceToRemove);
- }
- profile.getUserStoragePreferences().add(userStoragePreference);
- userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
- logger.debug("Airavata updated user storage resource preference with gateway id : " + gatewayID
- + " and for storage resource id : " + storageId);
- return true;
+ return registryService.updateUserStoragePreference(userId, gatewayID, storageId, userStoragePreference);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while reading user data storage preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating user data storage preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while updating user data storage preference");
}
}
@@ -5273,23 +3127,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteUserComputeResourcePreference(String userId, String gatewayID, String computeResourceId)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- return userResourceProfileRepository.removeUserComputeResourcePreferenceFromGateway(
- userId, gatewayID, computeResourceId);
+ return registryService.deleteUserComputeResourcePreference(userId, gatewayID, computeResourceId);
} catch (AppCatalogException e) {
- logger.error(userId, "Error while reading user compute resource preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage(
- "Error while updating user compute resource preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting user compute resource preference");
}
}
@@ -5306,22 +3146,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean deleteUserStoragePreference(String userId, String gatewayID, String storageId)
throws RegistryServiceException, TException {
try {
- if (!userRepository.isUserExists(gatewayID, userId)) {
- logger.error("user does not exist.Please provide a valid user id...");
- throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
- }
- return userResourceProfileRepository.removeUserDataStoragePreferenceFromGateway(
- userId, gatewayID, storageId);
+ return registryService.deleteUserStoragePreference(userId, gatewayID, storageId);
} catch (AppCatalogException e) {
- logger.error(gatewayID, "Error while reading user data storage preference...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while updating user data storage preference. More info : " + e.getMessage());
- throw exception;
- } catch (RegistryException e) {
- logger.error(userId, "Error while retrieving user resource profile...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while deleting user storage preference");
}
}
@@ -5332,13 +3159,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
@Override
public List<QueueStatusModel> getLatestQueueStatuses() throws RegistryServiceException, TException {
try {
- List<QueueStatusModel> queueStatusModels = queueStatusRepository.getLatestQueueStatuses();
- return queueStatusModels;
+ return registryService.getLatestQueueStatuses();
} catch (RegistryException e) {
- logger.error("Error while reading queue status models....", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading queue status models.... : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading queue status models");
}
}
@@ -5346,12 +3169,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void registerQueueStatuses(List<QueueStatusModel> queueStatuses)
throws RegistryServiceException, TException {
try {
- queueStatusRepository.createQueueStatuses(queueStatuses);
+ registryService.registerQueueStatuses(queueStatuses);
} catch (RegistryException e) {
- logger.error("Error while storing queue status models....", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while storing queue status models.... : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while storing queue status models");
}
}
@@ -5359,26 +3179,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public QueueStatusModel getQueueStatus(String hostName, String queueName)
throws RegistryServiceException, TException {
try {
- Optional<QueueStatusModel> optionalQueueStatusModel =
- queueStatusRepository.getQueueStatus(hostName, queueName);
- logger.info("Executed and present " + optionalQueueStatusModel.isPresent());
- if (optionalQueueStatusModel.isPresent()) {
- return optionalQueueStatusModel.get();
- } else {
- QueueStatusModel queueStatusModel = new QueueStatusModel();
- queueStatusModel.setHostName(hostName);
- queueStatusModel.setQueueName(queueName);
- queueStatusModel.setQueueUp(false);
- queueStatusModel.setRunningJobs(0);
- queueStatusModel.setQueuedJobs(0);
- queueStatusModel.setTime(0);
- return queueStatusModel;
- }
+ return registryService.getQueueStatus(hostName, queueName);
} catch (RegistryException e) {
- logger.error("Error while storing queue status models....", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while storing queue status models.... : " + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while retrieving queue status");
}
}
@@ -5394,20 +3197,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<UserComputeResourcePreference> getAllUserComputeResourcePreferences(String userId, String gatewayID)
throws RegistryServiceException, TException {
try {
- if (!isUserExists(gatewayID, userId)) {
- logger.error("User Resource Profile does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException(
- "User Resource Profile does not exist.Please provide a valid gateway id...");
- }
- return userResourceProfileRepository
- .getUserResourceProfile(userId, gatewayID)
- .getUserComputeResourcePreferences();
+ return registryService.getAllUserComputeResourcePreferences(userId, gatewayID);
} catch (AppCatalogException e) {
- logger.error(userId, "Error while reading User Resource Profile compute resource preferences...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading User Resource Profile compute resource preferences. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading User Resource Profile compute resource preferences");
}
}
@@ -5423,19 +3215,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public List<UserStoragePreference> getAllUserStoragePreferences(String userId, String gatewayID)
throws RegistryServiceException, TException {
try {
- if (!isUserExists(gatewayID, userId)) {
- logger.error("User does not exist.Please provide a valid gateway id...");
- throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
- }
- return userResourceProfileRepository
- .getUserResourceProfile(userId, gatewayID)
- .getUserStoragePreferences();
+ return registryService.getAllUserStoragePreferences(userId, gatewayID);
} catch (AppCatalogException e) {
- logger.error(userId, "Error while reading user resource Profile data storage preferences...", e);
- RegistryServiceException exception = new RegistryServiceException();
- exception.setMessage("Error while reading user resource Profile data storage preferences. More info : "
- + e.getMessage());
- throw exception;
+ throw convertToRegistryServiceException(e, "Error while reading user resource Profile data storage preferences");
}
}
@@ -5443,155 +3225,75 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void createGatewayGroups(GatewayGroups gatewayGroups)
throws RegistryServiceException, DuplicateEntryException, TException {
try {
- if (gatewayGroupsRepository.isExists(gatewayGroups.getGatewayId())) {
- logger.error("GatewayGroups already exists for " + gatewayGroups.getGatewayId());
- throw new DuplicateEntryException(
- "GatewayGroups for gatewayId: " + gatewayGroups.getGatewayId() + " already exists.");
+ registryService.createGatewayGroups(gatewayGroups);
+ } catch (RegistryException e) {
+ if (e.getMessage() != null && e.getMessage().contains("already exists")) {
+ throw new DuplicateEntryException(e.getMessage());
}
- gatewayGroupsRepository.create(gatewayGroups);
- } catch (DuplicateEntryException e) {
- throw e; // re-throw
- } catch (Exception e) {
-
- final String message =
- "Error while creating a GatewayGroups entry for gateway " + gatewayGroups.getGatewayId() + ".";
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ throw convertToRegistryServiceException(e, "Error while creating GatewayGroups");
}
}
@Override
public void updateGatewayGroups(GatewayGroups gatewayGroups) throws RegistryServiceException, TException {
try {
- if (!gatewayGroupsRepository.isExists(gatewayGroups.getGatewayId())) {
- final String message = "No GatewayGroups entry exists for " + gatewayGroups.getGatewayId();
- logger.error(message);
- throw new RegistryServiceException(message);
- }
- gatewayGroupsRepository.update(gatewayGroups);
- } catch (RegistryServiceException e) {
- throw e; // re-throw
- } catch (Exception e) {
-
- final String message =
- "Error while updating the GatewayGroups entry for gateway " + gatewayGroups.getGatewayId() + ".";
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ registryService.updateGatewayGroups(gatewayGroups);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while updating GatewayGroups");
}
}
@Override
public boolean isGatewayGroupsExists(String gatewayId) throws RegistryServiceException, TException {
try {
- return gatewayGroupsRepository.isExists(gatewayId);
- } catch (Exception e) {
- final String message = "Error checking existence of the GatewayGroups entry for gateway " + gatewayId + ".";
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.isGatewayGroupsExists(gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error checking existence of GatewayGroups");
}
}
@Override
public GatewayGroups getGatewayGroups(String gatewayId) throws RegistryServiceException, TException {
try {
- if (!gatewayGroupsRepository.isExists(gatewayId)) {
- final String message = "No GatewayGroups entry exists for " + gatewayId;
- logger.error(message);
- throw new RegistryServiceException(message);
- }
- return gatewayGroupsRepository.get(gatewayId);
- } catch (RegistryServiceException e) {
- throw e; // re-throw
- } catch (Exception e) {
-
- final String message = "Error while retrieving the GatewayGroups entry for gateway " + gatewayId + ".";
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.getGatewayGroups(gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving GatewayGroups");
}
}
@Override
public Parser getParser(String parserId, String gatewayId) throws RegistryServiceException, TException {
-
try {
- if (!parserRepository.isExists(parserId)) {
- final String message = "No Parser Info entry exists for " + parserId;
- logger.error(message);
- throw new RegistryServiceException(message);
- }
- return parserRepository.get(parserId);
-
- } catch (RegistryServiceException e) {
- throw e; // re-throw
-
- } catch (Exception e) {
- final String message = "Error while retrieving parser with id " + parserId + ".";
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.getParser(parserId, gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving parser");
}
}
@Override
public String saveParser(Parser parser) throws RegistryServiceException, TException {
-
try {
- Parser created = parserRepository.saveParser(parser);
- return created.getId();
-
- } catch (Exception e) {
- final String message = "Error while saving parser with id " + parser.getId();
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.saveParser(parser);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while saving parser");
}
}
@Override
public List<Parser> listAllParsers(String gatewayId) throws RegistryServiceException, TException {
-
try {
- return parserRepository.getAllParsers(gatewayId);
-
- } catch (Exception e) {
- final String message = "Error while listing parsers for gateway " + gatewayId;
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.listAllParsers(gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while listing parsers");
}
}
@Override
public void removeParser(String parserId, String gatewayId) throws RegistryServiceException, TException {
-
try {
- boolean exists = parserRepository.isExists(parserId);
-
- if (exists && !gatewayId.equals(parserRepository.get(parserId).getGatewayId())) {
- parserRepository.delete(parserId);
- } else {
- throw new RegistryServiceException("Parser " + parserId + " does not exist");
- }
- } catch (RegistryServiceException e) {
- throw e; // re-throw
-
- } catch (Exception e) {
- final String message = "Error while removing parser with id " + parserId + ".";
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ registryService.removeParser(parserId, gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while removing parser");
}
}
@@ -5599,14 +3301,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ParserInput getParserInput(String parserInputId, String gatewayId)
throws RegistryServiceException, TException {
try {
- ParserInput parserInput = parserInputRepository.getParserInput(parserInputId);
- // TODO check the gateway
-
- return parserInput;
- } catch (Exception e) {
- logger.error("Failed to fetch parser input " + parserInputId + " for gateway " + gatewayId, e);
- throw new RegistryServiceException("Failed to fetch parser input " + parserInputId + " for gateway "
- + gatewayId + " More info: " + e.getMessage());
+ return registryService.getParserInput(parserInputId, gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving parser input");
}
}
@@ -5614,116 +3311,56 @@ public class RegistryServerHandler implements RegistryService.Iface {
public ParserOutput getParserOutput(String parserOutputId, String gatewayId)
throws RegistryServiceException, TException {
try {
- ParserOutput parserOutput = parserOutputRepository.getParserOutput(parserOutputId);
- // TODO check the gateway
-
- return parserOutput;
- } catch (Exception e) {
- logger.error("Failed to fetch parser output " + parserOutputId + " for gateway " + gatewayId, e);
- throw new RegistryServiceException("Failed to fetch parser output " + parserOutputId + " for gateway "
- + gatewayId + " More info: " + e.getMessage());
+ return registryService.getParserOutput(parserOutputId, gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving parser output");
}
}
@Override
public ParsingTemplate getParsingTemplate(String templateId, String gatewayId)
throws RegistryServiceException, TException {
-
try {
- if (!parsingTemplateRepository.isExists(templateId)) {
- final String message = "No Parsing Template entry exists for " + templateId;
- logger.error(message);
- throw new RegistryServiceException(message);
- }
- return parsingTemplateRepository.get(templateId);
-
- } catch (RegistryServiceException e) {
- throw e; // re-throw
-
- } catch (Exception e) {
- final String message = "Error while retrieving Parsing Template for id " + templateId + ".";
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.getParsingTemplate(templateId, gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving parsing template");
}
}
@Override
public List<ParsingTemplate> getParsingTemplatesForExperiment(String experimentId, String gatewayId)
throws RegistryServiceException, TException {
-
try {
- List<ProcessModel> processes = getExperiment(experimentId).getProcesses();
- if (processes.size() > 0) {
- return parsingTemplateRepository.getParsingTemplatesForApplication(
- processes.get(processes.size() - 1).getApplicationInterfaceId());
- }
- return Collections.emptyList();
-
- } catch (Exception e) {
- final String message = "Error while retrieving parsing templates for experiment id " + experimentId;
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.getParsingTemplatesForExperiment(experimentId, gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving parsing templates for experiment");
}
}
@Override
public String saveParsingTemplate(ParsingTemplate parsingTemplate) throws RegistryServiceException, TException {
-
try {
- ParsingTemplate saved = parsingTemplateRepository.create(parsingTemplate);
- return saved.getId();
-
- } catch (Exception e) {
- final String message = "Error while saving parsing template with id " + parsingTemplate.getId();
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.saveParsingTemplate(parsingTemplate);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while saving parsing template");
}
}
@Override
public List<ParsingTemplate> listAllParsingTemplates(String gatewayId) throws RegistryServiceException, TException {
-
try {
- return parsingTemplateRepository.getAllParsingTemplates(gatewayId);
-
- } catch (Exception e) {
- final String message = "Error while listing parsing templates for gateway " + gatewayId;
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ return registryService.listAllParsingTemplates(gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while listing parsing templates");
}
}
@Override
public void removeParsingTemplate(String templateId, String gatewayId) throws RegistryServiceException, TException {
-
try {
- boolean exists = parsingTemplateRepository.isExists(templateId);
-
- if (exists
- && !gatewayId.equals(
- parsingTemplateRepository.get(templateId).getGatewayId())) {
- parsingTemplateRepository.delete(templateId);
- } else {
- throw new RegistryServiceException("Parsing tempolate " + templateId + " does not exist");
- }
- } catch (RegistryServiceException e) {
- throw e; // re-throw
-
- } catch (Exception e) {
-
- final String message = "Error while removing parsing template with id " + templateId;
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + " More info: " + e.getMessage());
- throw rse;
+ registryService.removeParsingTemplate(templateId, gatewayId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while removing parsing template");
}
}
@@ -5731,14 +3368,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public boolean isGatewayUsageReportingAvailable(String gatewayId, String computeResourceId)
throws RegistryServiceException, TException {
try {
- return usageReportingCommandRepository.isGatewayUsageReportingCommandExists(gatewayId, computeResourceId);
- } catch (Exception e) {
- String message = "Failed to check the availability to find the reporting information for the gateway "
- + gatewayId + " and compute resource " + computeResourceId;
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + ". More info " + e.getMessage());
- throw rse;
+ return registryService.isGatewayUsageReportingAvailable(gatewayId, computeResourceId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while checking gateway usage reporting availability");
}
}
@@ -5746,24 +3378,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public GatewayUsageReportingCommand getGatewayReportingCommand(String gatewayId, String computeResourceId)
throws RegistryServiceException, TException {
try {
- if (usageReportingCommandRepository.isGatewayUsageReportingCommandExists(gatewayId, computeResourceId)) {
- return usageReportingCommandRepository.getGatewayUsageReportingCommand(gatewayId, computeResourceId);
- } else {
- String message = "No usage reporting information for the gateway " + gatewayId
- + " and compute resource " + computeResourceId;
- logger.error(message);
- throw new RegistryServiceException(message);
- }
- } catch (RegistryServiceException e) {
- throw e; // re-throw
-
- } catch (Exception e) {
- String message = "Failed to check the availability to find the reporting information for the gateway "
- + gatewayId + " and compute resource " + computeResourceId;
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + ". More info " + e.getMessage());
- throw rse;
+ return registryService.getGatewayReportingCommand(gatewayId, computeResourceId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while retrieving gateway reporting command");
}
}
@@ -5771,14 +3388,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void addGatewayUsageReportingCommand(GatewayUsageReportingCommand command)
throws RegistryServiceException, TException {
try {
- usageReportingCommandRepository.addGatewayUsageReportingCommand(command);
- } catch (Exception e) {
- String message = "Failed to add the reporting information for the gateway " + command.getGatewayId()
- + " and compute resource " + command.getComputeResourceId();
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + ". More info " + e.getMessage());
- throw rse;
+ registryService.addGatewayUsageReportingCommand(command);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while adding gateway usage reporting command");
}
}
@@ -5786,14 +3398,9 @@ public class RegistryServerHandler implements RegistryService.Iface {
public void removeGatewayUsageReportingCommand(String gatewayId, String computeResourceId)
throws RegistryServiceException, TException {
try {
- usageReportingCommandRepository.removeGatewayUsageReportingCommand(gatewayId, computeResourceId);
- } catch (Exception e) {
- String message = "Failed to add the reporting information for the gateway " + gatewayId
- + " and compute resource " + computeResourceId;
- logger.error(message, e);
- RegistryServiceException rse = new RegistryServiceException();
- rse.setMessage(message + ". More info " + e.getMessage());
- throw rse;
+ registryService.removeGatewayUsageReportingCommand(gatewayId, computeResourceId);
+ } catch (RegistryException e) {
+ throw convertToRegistryServiceException(e, "Error while removing gateway usage reporting command");
}
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/service/RegistryService.java b/airavata-api/src/main/java/org/apache/airavata/service/RegistryService.java
new file mode 100644
index 0000000000..2c9284fa7a
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/service/RegistryService.java
@@ -0,0 +1,2756 @@
+/**
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.airavata.service;
+
+import java.util.*;
+import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
+import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
+import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
+import org.apache.airavata.model.appcatalog.computeresource.*;
+import org.apache.airavata.model.appcatalog.gatewaygroups.GatewayGroups;
+import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
+import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.BatchQueueResourcePolicy;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.ComputeResourcePolicy;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupResourceProfile;
+import org.apache.airavata.model.appcatalog.parser.Parser;
+import org.apache.airavata.model.appcatalog.parser.ParserInput;
+import org.apache.airavata.model.appcatalog.parser.ParserOutput;
+import org.apache.airavata.model.appcatalog.parser.ParsingTemplate;
+import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
+import org.apache.airavata.model.application.io.InputDataObjectType;
+import org.apache.airavata.model.application.io.OutputDataObjectType;
+import org.apache.airavata.model.commons.ErrorModel;
+import org.apache.airavata.model.data.movement.*;
+import org.apache.airavata.model.data.movement.DMType;
+import org.apache.airavata.model.data.replica.DataProductModel;
+import org.apache.airavata.model.data.replica.DataReplicaLocationModel;
+import org.apache.airavata.model.error.*;
+import org.apache.airavata.model.experiment.*;
+import org.apache.airavata.model.job.JobModel;
+import org.apache.airavata.registry.cpi.ExpCatChildDataType;
+import org.apache.airavata.model.process.ProcessModel;
+import org.apache.airavata.model.process.ProcessWorkflow;
+import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
+import org.apache.airavata.model.status.*;
+import org.apache.airavata.model.task.TaskModel;
+import org.apache.airavata.model.user.UserProfile;
+import org.apache.airavata.model.workspace.Gateway;
+import org.apache.airavata.model.workspace.GatewayUsageReportingCommand;
+import org.apache.airavata.model.workspace.Notification;
+import org.apache.airavata.model.workspace.Project;
+import org.apache.airavata.registry.core.repositories.appcatalog.*;
+import org.apache.airavata.registry.core.repositories.expcatalog.*;
+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.*;
+import org.apache.airavata.registry.cpi.utils.Constants;
+import org.apache.airavata.registry.api.exception.RegistryServiceException;
+import org.apache.airavata.model.error.AiravataSystemException;
+import org.apache.airavata.model.error.AiravataErrorType;
+import org.apache.airavata.registry.core.entities.expcatalog.JobPK;
+import org.apache.airavata.registry.core.repositories.appcatalog.GwyResourceProfileRepository;
+import org.apache.airavata.registry.core.repositories.appcatalog.GroupResourceProfileRepository;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.registry.cpi.WorkflowCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RegistryService {
+ private static final Logger logger = LoggerFactory.getLogger(RegistryService.class);
+
+ private ApplicationDeploymentRepository applicationDeploymentRepository = new ApplicationDeploymentRepository();
+ private ApplicationInterfaceRepository applicationInterfaceRepository = new ApplicationInterfaceRepository();
+ private StorageResourceRepository storageResourceRepository = new StorageResourceRepository();
+ private UserResourceProfileRepository userResourceProfileRepository = new UserResourceProfileRepository();
+ private GatewayRepository gatewayRepository = new GatewayRepository();
+ private ProjectRepository projectRepository = new ProjectRepository();
+ private NotificationRepository notificationRepository = new NotificationRepository();
+ private ExperimentSummaryRepository experimentSummaryRepository = new ExperimentSummaryRepository();
+ private ExperimentRepository experimentRepository = new ExperimentRepository();
+ private ExperimentOutputRepository experimentOutputRepository = new ExperimentOutputRepository();
+ private ExperimentStatusRepository experimentStatusRepository = new ExperimentStatusRepository();
+ private ExperimentErrorRepository experimentErrorRepository = new ExperimentErrorRepository();
+ private ProcessRepository processRepository = new ProcessRepository();
+ private ProcessOutputRepository processOutputRepository = new ProcessOutputRepository();
+ private ProcessWorkflowRepository processWorkflowRepository = new ProcessWorkflowRepository();
+ private ProcessStatusRepository processStatusRepository = new ProcessStatusRepository();
+ private ProcessErrorRepository processErrorRepository = new ProcessErrorRepository();
+ private TaskRepository taskRepository = new TaskRepository();
+ private TaskStatusRepository taskStatusRepository = new TaskStatusRepository();
+ private TaskErrorRepository taskErrorRepository = new TaskErrorRepository();
+ private JobRepository jobRepository = new JobRepository();
+ private JobStatusRepository jobStatusRepository = new JobStatusRepository();
+ private QueueStatusRepository queueStatusRepository = new QueueStatusRepository();
+ private DataProductRepository dataProductRepository = new DataProductRepository();
+ private DataReplicaLocationRepository dataReplicaLocationRepository = new DataReplicaLocationRepository();
+ private WorkflowRepository workflowRepository = new WorkflowRepository();
+ private GatewayGroupsRepository gatewayGroupsRepository = new GatewayGroupsRepository();
+ private ParserRepository parserRepository = new ParserRepository();
+ private ParserInputRepository parserInputRepository = new ParserInputRepository();
+ private ParserOutputRepository parserOutputRepository = new ParserOutputRepository();
+ private ParsingTemplateRepository parsingTemplateRepository = new ParsingTemplateRepository();
+ private UserRepository userRepository = new UserRepository();
+ private ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ private GatewayUsageReportingCommandRepository usageReportingCommandRepository =
+ new GatewayUsageReportingCommandRepository();
+
+ public String getAPIVersion() {
+ return org.apache.airavata.registry.api.registry_apiConstants.REGISTRY_API_VERSION;
+ }
+
+ public boolean isUserExists(String gatewayId, String userName) throws RegistryException {
+ return userRepository.isUserExists(gatewayId, userName);
+ }
+
+ public List<String> getAllUsersInGateway(String gatewayId) throws RegistryException {
+ return userRepository.getAllUsernamesInGateway(gatewayId);
+ }
+
+ public Gateway getGateway(String gatewayId) throws RegistryException {
+ if (!gatewayRepository.isGatewayExist(gatewayId)) {
+ logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
+ throw new RegistryException("Gateway does not exist in the system. Please provide a valid gateway ID...");
+ }
+ Gateway gateway = gatewayRepository.getGateway(gatewayId);
+ logger.debug("Airavata retrieved gateway with gateway id : " + gateway.getGatewayId());
+ return gateway;
+ }
+
+ public boolean deleteGateway(String gatewayId) throws RegistryException {
+ if (!gatewayRepository.isGatewayExist(gatewayId)) {
+ logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
+ throw new RegistryException("Gateway does not exist in the system. Please provide a valid gateway ID...");
+ }
+ gatewayRepository.removeGateway(gatewayId);
+ logger.debug("Airavata deleted gateway with gateway id : " + gatewayId);
+ return true;
+ }
+
+ public List<Gateway> getAllGateways() throws RegistryException {
+ List<Gateway> gateways = gatewayRepository.getAllGateways();
+ logger.debug("Airavata retrieved all available gateways...");
+ return gateways;
+ }
+
+ public boolean isGatewayExist(String gatewayId) throws RegistryException {
+ return gatewayRepository.isGatewayExist(gatewayId);
+ }
+
+ public boolean deleteNotification(String gatewayId, String notificationId) throws RegistryException {
+ notificationRepository.deleteNotification(notificationId);
+ return true;
+ }
+
+ public Notification getNotification(String gatewayId, String notificationId) throws RegistryException {
+ return notificationRepository.getNotification(notificationId);
+ }
+
+ public List<Notification> getAllNotifications(String gatewayId) throws RegistryException {
+ List<Notification> notifications = notificationRepository.getAllGatewayNotifications(gatewayId);
+ return notifications;
+ }
+
+ public Project getProject(String projectId) throws RegistryException {
+ if (!projectRepository.isProjectExist(projectId)) {
+ logger.error("Project does not exist in the system. Please provide a valid project ID...");
+ throw new RegistryException("Project does not exist in the system. Please provide a valid project ID...");
+ }
+ logger.debug("Airavata retrieved project with project Id : " + projectId);
+ Project project = projectRepository.getProject(projectId);
+ return project;
+ }
+
+ public boolean deleteProject(String projectId) throws RegistryException {
+ if (!projectRepository.isProjectExist(projectId)) {
+ logger.error("Project does not exist in the system. Please provide a valid project ID...");
+ throw new RegistryException("Project does not exist in the system. Please provide a valid project ID...");
+ }
+ projectRepository.removeProject(projectId);
+ logger.debug("Airavata deleted project with project Id : " + projectId);
+ return true;
+ }
+
+ public List<Project> getUserProjects(String gatewayId, String userName, int limit, int offset) throws RegistryException {
+ if (!validateString(userName)) {
+ logger.error("Username cannot be empty. Please provide a valid user..");
+ throw new RegistryException("Username cannot be empty. Please provide a valid user..");
+ }
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ List<Project> projects = new ArrayList<>();
+ if (!userRepository.isUserExists(gatewayId, userName)) {
+ logger.warn("User does not exist in the system. Please provide a valid user..");
+ return projects;
+ }
+ Map<String, String> filters = new HashMap<>();
+ filters.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
+ filters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
+ projects = projectRepository.searchProjects(
+ filters,
+ limit,
+ offset,
+ Constants.FieldConstants.ProjectConstants.CREATION_TIME,
+ ResultOrderType.DESC);
+ logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId);
+ return projects;
+ }
+
+ public ExperimentStatistics getExperimentStatistics(
+ String gatewayId,
+ long fromTime,
+ long toTime,
+ String userName,
+ String applicationName,
+ String resourceHostName,
+ List<String> accessibleExpIds,
+ int limit,
+ int offset) throws RegistryException {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ Map<String, String> filters = new HashMap<>();
+ filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);
+ filters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, fromTime + "");
+ filters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, toTime + "");
+ if (userName != null) {
+ filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
+ }
+ if (applicationName != null) {
+ filters.put(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID, applicationName);
+ }
+ if (resourceHostName != null) {
+ filters.put(Constants.FieldConstants.ExperimentConstants.RESOURCE_HOST_ID, resourceHostName);
+ }
+ limit = Math.min(limit, 1000);
+ ExperimentStatistics result = experimentSummaryRepository.getAccessibleExperimentStatistics(
+ accessibleExpIds, filters, limit, offset);
+ logger.debug("Airavata retrieved experiments for gateway id : " + gatewayId + " between : "
+ + org.apache.airavata.common.utils.AiravataUtils.getTime(fromTime) + " and " + org.apache.airavata.common.utils.AiravataUtils.getTime(toTime));
+ return result;
+ }
+
+ public List<ExperimentModel> getExperimentsInProject(String gatewayId, String projectId, int limit, int offset) throws RegistryException {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ if (!validateString(projectId)) {
+ logger.error("Project id cannot be empty. Please provide a valid project ID...");
+ throw new RegistryException("Project id cannot be empty. Please provide a valid project ID...");
+ }
+ if (!projectRepository.isProjectExist(projectId)) {
+ logger.error("Project does not exist in the system. Please provide a valid project ID...");
+ throw new RegistryException("Project does not exist in the system. Please provide a valid project ID...");
+ }
+ List<ExperimentModel> experiments = experimentRepository.getExperimentList(
+ gatewayId,
+ Constants.FieldConstants.ExperimentConstants.PROJECT_ID,
+ projectId,
+ limit,
+ offset,
+ Constants.FieldConstants.ExperimentConstants.CREATION_TIME,
+ ResultOrderType.DESC);
+ logger.debug("Airavata retrieved experiments for project : " + projectId);
+ return experiments;
+ }
+
+ public List<ExperimentModel> getUserExperiments(String gatewayId, String userName, int limit, int offset) throws RegistryException {
+ if (!validateString(userName)) {
+ logger.error("Username cannot be empty. Please provide a valid user..");
+ throw new RegistryException("Username cannot be empty. Please provide a valid user..");
+ }
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ List<ExperimentModel> experiments = new ArrayList<ExperimentModel>();
+ if (!userRepository.isUserExists(gatewayId, userName)) {
+ logger.warn("User does not exist in the system. Please provide a valid user..");
+ return experiments;
+ }
+ experiments = experimentRepository.getExperimentList(
+ gatewayId,
+ Constants.FieldConstants.ExperimentConstants.USER_NAME,
+ userName,
+ limit,
+ offset,
+ Constants.FieldConstants.ExperimentConstants.CREATION_TIME,
+ ResultOrderType.DESC);
+ logger.debug("Airavata retrieved experiments for user : " + userName);
+ return experiments;
+ }
+
+ public boolean deleteExperiment(String experimentId) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(experimentId)) {
+ throw new RegistryException(
+ "Requested experiment id " + experimentId + " does not exist in the system..");
+ }
+ ExperimentModel experimentModel = experimentRepository.getExperiment(experimentId);
+ if (!(experimentModel.getExperimentStatus().get(0).getState() == ExperimentState.CREATED)) {
+ logger.error("Error while deleting the experiment");
+ throw new RegistryException(
+ "Experiment is not in CREATED state. Hence cannot deleted. ID:" + experimentId);
+ }
+ experimentRepository.removeExperiment(experimentId);
+ logger.debug("Airavata removed experiment with experiment id : " + experimentId);
+ return true;
+ }
+
+ private ExperimentModel getExperimentInternal(String airavataExperimentId) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ return experimentRepository.getExperiment(airavataExperimentId);
+ }
+
+ public ExperimentModel getExperiment(String airavataExperimentId) throws RegistryException {
+ return getExperimentInternal(airavataExperimentId);
+ }
+
+ public ExperimentModel getDetailedExperimentTree(String airavataExperimentId) throws RegistryException {
+ ExperimentModel experimentModel = getExperimentInternal(airavataExperimentId);
+ List<ProcessModel> processList = processRepository.getProcessList(
+ Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentModel.getExperimentId());
+ if (processList != null) {
+ processList.stream().forEach(p -> {
+ (p).getTasks().stream().forEach(t -> {
+ try {
+ List<JobModel> jobList = jobRepository.getJobList(
+ Constants.FieldConstants.JobConstants.TASK_ID, ((TaskModel) t).getTaskId());
+ if (jobList != null) {
+ Collections.sort(jobList, new Comparator<JobModel>() {
+ @Override
+ public int compare(JobModel o1, JobModel o2) {
+ return (int) (o1.getCreationTime() - o2.getCreationTime());
+ }
+ });
+ t.setJobs(jobList);
+ }
+ } catch (RegistryException e) {
+ logger.error(e.getMessage(), e);
+ }
+ });
+ });
+ experimentModel.setProcesses(processList);
+ }
+ logger.debug("Airavata retrieved detailed experiment with experiment id : " + airavataExperimentId);
+ return experimentModel;
+ }
+
+ private ExperimentStatus getExperimentStatusInternal(String airavataExperimentId) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.error(
+ airavataExperimentId,
+ "Error while retrieving experiment status, experiment {} doesn't exist.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ return experimentStatusRepository.getExperimentStatus(airavataExperimentId);
+ }
+
+ public ExperimentStatus getExperimentStatus(String airavataExperimentId) throws RegistryException {
+ ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
+ logger.debug("Airavata retrieved experiment status for experiment id : " + airavataExperimentId);
+ return experimentStatus;
+ }
+
+ public List<OutputDataObjectType> getExperimentOutputs(String airavataExperimentId) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.error(
+ airavataExperimentId,
+ "Get experiment outputs failed, experiment {} doesn't exit.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ logger.debug("Airavata retrieved experiment outputs for experiment id : " + airavataExperimentId);
+ return experimentOutputRepository.getExperimentOutputs(airavataExperimentId);
+ }
+
+
+ public void updateJobStatus(JobStatus jobStatus, String taskId, String jobId) throws RegistryException {
+ org.apache.airavata.registry.core.entities.expcatalog.JobPK jobPK = new org.apache.airavata.registry.core.entities.expcatalog.JobPK();
+ jobPK.setTaskId(taskId);
+ jobPK.setJobId(jobId);
+ jobStatusRepository.updateJobStatus(jobStatus, jobPK);
+ }
+
+ public void addJob(JobModel jobModel, String processId) throws RegistryException {
+ jobRepository.addJob(jobModel, processId);
+ }
+
+ // Note: deleteJobs method removed - JobRepository doesn't have this method
+ // Jobs should be deleted individually using removeJob(jobPK) or removeJob(jobModel)
+
+ public String addProcess(ProcessModel processModel, String experimentId) throws RegistryException {
+ return processRepository.addProcess(processModel, experimentId);
+ }
+
+ public void updateProcess(ProcessModel processModel, String processId) throws RegistryException {
+ processRepository.updateProcess(processModel, processId);
+ }
+
+ public String addTask(TaskModel taskModel, String processId) throws RegistryException {
+ return taskRepository.addTask(taskModel, processId);
+ }
+
+ public void deleteTasks(String processId) throws RegistryException {
+ taskRepository.deleteTasks(processId);
+ }
+
+ public UserConfigurationDataModel getUserConfigurationData(String experimentId) throws RegistryException {
+ return experimentRepository.getUserConfigurationData(experimentId);
+ }
+
+ public ProcessModel getProcess(String processId) throws RegistryException {
+ return processRepository.getProcess(processId);
+ }
+
+ public List<ProcessModel> getProcessList(String experimentId) throws RegistryException {
+ List<ProcessModel> processModels = processRepository.getProcessList(
+ Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentId);
+ return processModels;
+ }
+
+ public ProcessStatus getProcessStatus(String processId) throws RegistryException {
+ return processStatusRepository.getProcessStatus(processId);
+ }
+
+ public List<ProcessModel> getProcessListInState(ProcessState processState) throws RegistryException {
+ List<ProcessModel> finalProcessList = new ArrayList<>();
+ int offset = 0;
+ int limit = 100;
+ int count = 0;
+ do {
+ List<ProcessStatus> processStatusList =
+ processStatusRepository.getProcessStatusList(processState, offset, limit);
+ offset += processStatusList.size();
+ count = processStatusList.size();
+ for (ProcessStatus processStatus : processStatusList) {
+ ProcessStatus latestStatus = processStatusRepository.getProcessStatus(processStatus.getProcessId());
+ if (latestStatus.getState().name().equals(processState.name())) {
+ finalProcessList.add(processRepository.getProcess(latestStatus.getProcessId()));
+ }
+ }
+ } while (count == limit);
+ return finalProcessList;
+ }
+
+ public List<ProcessStatus> getProcessStatusList(String processId) throws RegistryException {
+ return processStatusRepository.getProcessStatusList(processId);
+ }
+
+ private JobModel fetchJobModel(String queryType, String id) throws RegistryException {
+ if (queryType.equals(Constants.FieldConstants.JobConstants.TASK_ID)) {
+ List<JobModel> jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, id);
+ if (jobs != null) {
+ for (JobModel jobModel : jobs) {
+ if (jobModel.getJobId() != null || !jobModel.equals("")) {
+ return jobModel;
+ }
+ }
+ }
+ } else if (queryType.equals(Constants.FieldConstants.JobConstants.PROCESS_ID)) {
+ List<JobModel> jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.PROCESS_ID, id);
+ if (jobs != null) {
+ for (JobModel jobModel : jobs) {
+ if (jobModel.getJobId() != null || !jobModel.equals("")) {
+ return jobModel;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private List<JobModel> fetchJobModels(String queryType, String id) throws RegistryException {
+ List<JobModel> jobs = new ArrayList<>();
+ switch (queryType) {
+ case Constants.FieldConstants.JobConstants.TASK_ID:
+ jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, id);
+ break;
+ case Constants.FieldConstants.JobConstants.PROCESS_ID:
+ jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.PROCESS_ID, id);
+ break;
+ case Constants.FieldConstants.JobConstants.JOB_ID:
+ jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.JOB_ID, id);
+ break;
+ }
+ return jobs;
+ }
+
+ public boolean isJobExist(String queryType, String id) throws RegistryException {
+ JobModel jobModel = fetchJobModel(queryType, id);
+ return jobModel != null;
+ }
+
+ public JobModel getJob(String queryType, String id) throws RegistryException {
+ JobModel jobModel = fetchJobModel(queryType, id);
+ if (jobModel != null) return jobModel;
+ throw new RegistryException("Job not found for queryType: " + queryType + ", id: " + id);
+ }
+
+ public List<JobModel> getJobs(String queryType, String id) throws RegistryException {
+ return fetchJobModels(queryType, id);
+ }
+
+ public int getJobCount(
+ org.apache.airavata.model.status.JobStatus jobStatus, String gatewayId, double searchBackTimeInMinutes) throws RegistryException {
+ List<JobStatus> jobStatusList = jobStatusRepository.getDistinctListofJobStatus(
+ gatewayId, jobStatus.getJobState().name(), searchBackTimeInMinutes);
+ return jobStatusList.size();
+ }
+
+ public Map<String, Double> getAVGTimeDistribution(String gatewayId, double searchBackTimeInMinutes) throws RegistryException {
+ return processRepository.getAVGTimeDistribution(gatewayId, searchBackTimeInMinutes);
+ }
+
+ public List<OutputDataObjectType> getProcessOutputs(String processId) throws RegistryException {
+ return processOutputRepository.getProcessOutputs(processId);
+ }
+
+ public List<ProcessWorkflow> getProcessWorkflows(String processId) throws RegistryException {
+ return processWorkflowRepository.getProcessWorkflows(processId);
+ }
+
+ public void addProcessWorkflow(ProcessWorkflow processWorkflow) throws RegistryException {
+ processWorkflowRepository.addProcessWorkflow(processWorkflow, processWorkflow.getProcessId());
+ }
+
+ public List<String> getProcessIds(String experimentId) throws RegistryException {
+ return processRepository.getProcessIds(DBConstants.Process.EXPERIMENT_ID, experimentId);
+ }
+
+ public List<JobModel> getJobDetails(String airavataExperimentId) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.error(
+ airavataExperimentId,
+ "Error while retrieving job details, experiment {} doesn't exist.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ List<ProcessModel> processModels = processRepository.getProcessList(
+ Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
+ List<JobModel> jobList = new ArrayList<>();
+ if (processModels != null && !processModels.isEmpty()) {
+ for (ProcessModel processModel : processModels) {
+ List<TaskModel> tasks = processModel.getTasks();
+ if (tasks != null && !tasks.isEmpty()) {
+ for (TaskModel taskModel : tasks) {
+ String taskId = taskModel.getTaskId();
+ List<JobModel> taskJobs =
+ jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, taskId);
+ jobList.addAll(taskJobs);
+ }
+ }
+ }
+ }
+ logger.debug("Airavata retrieved job models for experiment with experiment id : " + airavataExperimentId);
+ return jobList;
+ }
+
+ private boolean validateString(String name) {
+ boolean valid = true;
+ if (name == null || name.equals("") || name.trim().length() == 0) {
+ valid = false;
+ }
+ return valid;
+ }
+
+ public boolean isGatewayExistInternal(String gatewayId) throws RegistryException {
+ return gatewayRepository.isGatewayExist(gatewayId);
+ }
+
+ public ApplicationModule getApplicationModule(String appModuleId) throws AppCatalogException {
+ ApplicationModule module = applicationInterfaceRepository.getApplicationModule(appModuleId);
+ logger.debug("Airavata retrieved application module with module id : " + appModuleId);
+ return module;
+ }
+
+ public List<ApplicationModule> getAllAppModules(String gatewayId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ List<ApplicationModule> moduleList = applicationInterfaceRepository.getAllApplicationModules(gatewayId);
+ logger.debug("Airavata retrieved modules for gateway id : " + gatewayId);
+ return moduleList;
+ }
+
+ public List<ApplicationModule> getAccessibleAppModules(
+ String gatewayId, List<String> accessibleAppIds, List<String> accessibleComputeResourceIds) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ List<ApplicationModule> moduleList = applicationInterfaceRepository.getAccessibleApplicationModules(
+ gatewayId, accessibleAppIds, accessibleComputeResourceIds);
+ logger.debug("Airavata retrieved modules for gateway id : " + gatewayId);
+ return moduleList;
+ }
+
+ public boolean deleteApplicationModule(String appModuleId) throws AppCatalogException {
+ logger.debug("Airavata deleted application module with module id : " + appModuleId);
+ return applicationInterfaceRepository.removeApplicationModule(appModuleId);
+ }
+
+ public ApplicationDeploymentDescription getApplicationDeployment(String appDeploymentId) throws AppCatalogException {
+ ApplicationDeploymentDescription deployement =
+ applicationDeploymentRepository.getApplicationDeployement(appDeploymentId);
+ logger.debug("Airavata registered application deployment for deployment id : " + appDeploymentId);
+ return deployement;
+ }
+
+ public boolean deleteApplicationDeployment(String appDeploymentId) throws AppCatalogException {
+ applicationDeploymentRepository.removeAppDeployment(appDeploymentId);
+ logger.debug("Airavata removed application deployment with deployment id : " + appDeploymentId);
+ return true;
+ }
+
+ public List<ApplicationDeploymentDescription> getAllApplicationDeployments(String gatewayId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ List<ApplicationDeploymentDescription> deployements =
+ applicationDeploymentRepository.getAllApplicationDeployements(gatewayId);
+ logger.debug("Airavata retrieved application deployments for gateway id : " + gatewayId);
+ return deployements;
+ }
+
+ public List<ApplicationDeploymentDescription> getAccessibleApplicationDeployments(
+ String gatewayId, List<String> accessibleAppDeploymentIds, List<String> accessibleComputeResourceIds) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ List<ApplicationDeploymentDescription> deployements =
+ applicationDeploymentRepository.getAccessibleApplicationDeployments(
+ gatewayId, accessibleAppDeploymentIds, accessibleComputeResourceIds);
+ logger.debug("Airavata retrieved application deployments for gateway id : " + gatewayId);
+ return deployements;
+ }
+
+ public List<ApplicationDeploymentDescription> getAccessibleApplicationDeploymentsForAppModule(
+ String gatewayId,
+ String appModuleId,
+ List<String> accessibleAppDeploymentIds,
+ List<String> accessibleComputeResourceIds) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ List<ApplicationDeploymentDescription> deployments =
+ applicationDeploymentRepository.getAccessibleApplicationDeployments(
+ gatewayId, appModuleId, accessibleAppDeploymentIds, accessibleComputeResourceIds);
+ return deployments;
+ }
+
+ public List<String> getAppModuleDeployedResources(String appModuleId) throws AppCatalogException {
+ List<String> appDeployments = new ArrayList<>();
+ Map<String, String> filters = new HashMap<>();
+ filters.put(DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID, appModuleId);
+ List<ApplicationDeploymentDescription> applicationDeployments =
+ applicationDeploymentRepository.getApplicationDeployments(filters);
+ for (ApplicationDeploymentDescription description : applicationDeployments) {
+ appDeployments.add(description.getAppDeploymentId());
+ }
+ logger.debug("Airavata retrieved application deployments for module id : " + appModuleId);
+ return appDeployments;
+ }
+
+ public List<ApplicationDeploymentDescription> getApplicationDeployments(String appModuleId) throws AppCatalogException {
+ Map<String, String> filters = new HashMap<>();
+ filters.put(DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID, appModuleId);
+ List<ApplicationDeploymentDescription> applicationDeployments =
+ applicationDeploymentRepository.getApplicationDeployments(filters);
+ return applicationDeployments;
+ }
+
+ public ApplicationInterfaceDescription getApplicationInterface(String appInterfaceId) throws AppCatalogException {
+ ApplicationInterfaceDescription interfaceDescription =
+ applicationInterfaceRepository.getApplicationInterface(appInterfaceId);
+ logger.debug("Airavata retrieved application interface with interface id : " + appInterfaceId);
+ return interfaceDescription;
+ }
+
+ public boolean deleteApplicationInterface(String appInterfaceId) throws AppCatalogException {
+ boolean removeApplicationInterface =
+ applicationInterfaceRepository.removeApplicationInterface(appInterfaceId);
+ logger.debug("Airavata removed application interface with interface id : " + appInterfaceId);
+ return removeApplicationInterface;
+ }
+
+ public Map<String, String> getAllApplicationInterfaceNames(String gatewayId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ List<ApplicationInterfaceDescription> allApplicationInterfaces =
+ applicationInterfaceRepository.getAllApplicationInterfaces(gatewayId);
+ Map<String, String> allApplicationInterfacesMap = new HashMap<>();
+ if (allApplicationInterfaces != null && !allApplicationInterfaces.isEmpty()) {
+ for (ApplicationInterfaceDescription interfaceDescription : allApplicationInterfaces) {
+ allApplicationInterfacesMap.put(
+ interfaceDescription.getApplicationInterfaceId(),
+ interfaceDescription.getApplicationName());
+ }
+ }
+ logger.debug("Airavata retrieved application interfaces for gateway id : " + gatewayId);
+ return allApplicationInterfacesMap;
+ }
+
+ public List<ApplicationInterfaceDescription> getAllApplicationInterfaces(String gatewayId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ List<ApplicationInterfaceDescription> interfaces =
+ applicationInterfaceRepository.getAllApplicationInterfaces(gatewayId);
+ logger.debug("Airavata retrieved application interfaces for gateway id : " + gatewayId);
+ return interfaces;
+ }
+
+ public List<InputDataObjectType> getApplicationInputs(String appInterfaceId) throws AppCatalogException {
+ List<InputDataObjectType> applicationInputs =
+ applicationInterfaceRepository.getApplicationInputs(appInterfaceId);
+ logger.debug("Airavata retrieved application inputs for application interface id : " + appInterfaceId);
+ return applicationInputs;
+ }
+
+ private List<OutputDataObjectType> getApplicationOutputsInternal(String appInterfaceId) throws AppCatalogException {
+ List<OutputDataObjectType> applicationOutputs =
+ applicationInterfaceRepository.getApplicationOutputs(appInterfaceId);
+ logger.debug("Airavata retrieved application outputs for application interface id : " + appInterfaceId);
+ return applicationOutputs;
+ }
+
+ public List<OutputDataObjectType> getApplicationOutputs(String appInterfaceId) throws AppCatalogException {
+ List<OutputDataObjectType> list = getApplicationOutputsInternal(appInterfaceId);
+ logger.debug("Airavata retrieved application outputs for app interface id : " + appInterfaceId);
+ return list;
+ }
+
+ public Map<String, String> getAvailableAppInterfaceComputeResources(String appInterfaceId) throws AppCatalogException {
+ Map<String, String> allComputeResources =
+ new ComputeResourceRepository().getAvailableComputeResourceIdList();
+ Map<String, String> availableComputeResources = new HashMap<String, String>();
+ ApplicationInterfaceDescription applicationInterface =
+ applicationInterfaceRepository.getApplicationInterface(appInterfaceId);
+ HashMap<String, String> filters = new HashMap<>();
+ List<String> applicationModules = applicationInterface.getApplicationModules();
+ if (applicationModules != null && !applicationModules.isEmpty()) {
+ for (String moduleId : applicationModules) {
+ filters.put(DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID, moduleId);
+ List<ApplicationDeploymentDescription> applicationDeployments =
+ applicationDeploymentRepository.getApplicationDeployments(filters);
+ for (ApplicationDeploymentDescription deploymentDescription : applicationDeployments) {
+ if (allComputeResources.get(deploymentDescription.getComputeHostId()) != null) {
+ availableComputeResources.put(
+ deploymentDescription.getComputeHostId(),
+ allComputeResources.get(deploymentDescription.getComputeHostId()));
+ }
+ }
+ }
+ }
+ logger.debug(
+ "Airavata retrieved available compute resources for application interface id : " + appInterfaceId);
+ return availableComputeResources;
+ }
+
+ public ComputeResourceDescription getComputeResource(String computeResourceId) throws AppCatalogException {
+ ComputeResourceDescription computeResource =
+ new ComputeResourceRepository().getComputeResource(computeResourceId);
+ logger.debug("Airavata retrieved compute resource with compute resource Id : " + computeResourceId);
+ return computeResource;
+ }
+
+ public Map<String, String> getAllComputeResourceNames() throws AppCatalogException {
+ Map<String, String> computeResourceIdList = new ComputeResourceRepository().getAllComputeResourceIdList();
+ logger.debug("Airavata retrieved all the available compute resources...");
+ return computeResourceIdList;
+ }
+
+ public boolean deleteComputeResource(String computeResourceId) throws AppCatalogException {
+ new ComputeResourceRepository().removeComputeResource(computeResourceId);
+ logger.debug("Airavata deleted compute resource with compute resource Id : " + computeResourceId);
+ return true;
+ }
+
+ public StorageResourceDescription getStorageResource(String storageResourceId) throws AppCatalogException {
+ StorageResourceDescription storageResource =
+ storageResourceRepository.getStorageResource(storageResourceId);
+ logger.debug("Airavata retrieved storage resource with storage resource Id : " + storageResourceId);
+ return storageResource;
+ }
+
+ public Map<String, String> getAllStorageResourceNames() throws AppCatalogException {
+ Map<String, String> resourceIdList = storageResourceRepository.getAllStorageResourceIdList();
+ logger.debug("Airavata retrieved storage resources list...");
+ return resourceIdList;
+ }
+
+ public boolean deleteStorageResource(String storageResourceId) throws AppCatalogException {
+ storageResourceRepository.removeStorageResource(storageResourceId);
+ logger.debug("Airavata deleted storage resource with storage resource Id : " + storageResourceId);
+ return true;
+ }
+
+ public LOCALSubmission getLocalJobSubmission(String jobSubmissionId) throws AppCatalogException {
+ LOCALSubmission localJobSubmission = new ComputeResourceRepository().getLocalJobSubmission(jobSubmissionId);
+ logger.debug("Airavata retrieved local job submission for job submission interface id: " + jobSubmissionId);
+ return localJobSubmission;
+ }
+
+ public SSHJobSubmission getSSHJobSubmission(String jobSubmissionId) throws AppCatalogException {
+ SSHJobSubmission sshJobSubmission = new ComputeResourceRepository().getSSHJobSubmission(jobSubmissionId);
+ logger.debug("Airavata retrieved SSH job submission for job submission interface id: " + jobSubmissionId);
+ return sshJobSubmission;
+ }
+
+ public UnicoreJobSubmission getUnicoreJobSubmission(String jobSubmissionId) throws AppCatalogException {
+ UnicoreJobSubmission unicoreJobSubmission =
+ new ComputeResourceRepository().getUNICOREJobSubmission(jobSubmissionId);
+ logger.debug(
+ "Airavata retrieved UNICORE job submission for job submission interface id: " + jobSubmissionId);
+ return unicoreJobSubmission;
+ }
+
+ public CloudJobSubmission getCloudJobSubmission(String jobSubmissionId) throws AppCatalogException {
+ CloudJobSubmission cloudJobSubmission =
+ new ComputeResourceRepository().getCloudJobSubmission(jobSubmissionId);
+ logger.debug("Airavata retrieved cloud job submission for job submission interface id: " + jobSubmissionId);
+ return cloudJobSubmission;
+ }
+
+ public boolean changeJobSubmissionPriority(String jobSubmissionInterfaceId, int newPriorityOrder) throws RegistryException {
+ return false;
+ }
+
+ public boolean changeDataMovementPriority(String dataMovementInterfaceId, int newPriorityOrder) throws RegistryException {
+ return false;
+ }
+
+ public boolean changeJobSubmissionPriorities(Map<String, Integer> jobSubmissionPriorityMap) throws RegistryException {
+ return false;
+ }
+
+ public boolean changeDataMovementPriorities(Map<String, Integer> dataMovementPriorityMap) throws RegistryException {
+ return false;
+ }
+
+ public boolean deleteJobSubmissionInterface(String computeResourceId, String jobSubmissionInterfaceId) throws AppCatalogException {
+ new ComputeResourceRepository().removeJobSubmissionInterface(computeResourceId, jobSubmissionInterfaceId);
+ logger.debug("Airavata deleted job submission interface with interface id : " + jobSubmissionInterfaceId);
+ return true;
+ }
+
+ public ResourceJobManager getResourceJobManager(String resourceJobManagerId) throws AppCatalogException {
+ return new ComputeResourceRepository().getResourceJobManager(resourceJobManagerId);
+ }
+
+ public boolean deleteResourceJobManager(String resourceJobManagerId) throws AppCatalogException {
+ new ComputeResourceRepository().deleteResourceJobManager(resourceJobManagerId);
+ return true;
+ }
+
+ public boolean deleteBatchQueue(String computeResourceId, String queueName) throws AppCatalogException {
+ new ComputeResourceRepository().removeBatchQueue(computeResourceId, queueName);
+ return true;
+ }
+
+ public GatewayResourceProfile getGatewayResourceProfile(String gatewayID) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ GatewayResourceProfile gatewayResourceProfile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
+ logger.debug("Airavata retrieved gateway profile with gateway id : " + gatewayID);
+ return gatewayResourceProfile;
+ }
+
+ public boolean deleteGatewayResourceProfile(String gatewayID) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ gwyResourceProfileRepository.delete(gatewayID);
+ logger.debug("Airavata deleted gateway profile with gateway id : " + gatewayID);
+ return true;
+ }
+
+ public ComputeResourcePreference getGatewayComputeResourcePreference(String gatewayID, String computeResourceId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ if (!gwyResourceProfileRepository.isGatewayResourceProfileExists(gatewayID)) {
+ logger.error(
+ gatewayID,
+ "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
+ throw new AppCatalogException(
+ "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
+ }
+ if (!computeResourceRepository.isComputeResourceExists(computeResourceId)) {
+ logger.error(
+ computeResourceId,
+ "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
+ throw new AppCatalogException(
+ "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
+ }
+ ComputeResourcePreference computeResourcePreference =
+ gwyResourceProfileRepository.getComputeResourcePreference(gatewayID, computeResourceId);
+ logger.debug("Airavata retrieved gateway compute resource preference with gateway id : " + gatewayID
+ + " and for compute resoruce id : " + computeResourceId);
+ return computeResourcePreference;
+ }
+
+ public StoragePreference getGatewayStoragePreference(String gatewayID, String storageId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ if (!gwyResourceProfileRepository.isGatewayResourceProfileExists(gatewayID)) {
+ logger.error(
+ gatewayID,
+ "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
+ throw new AppCatalogException(
+ "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
+ }
+ StoragePreference storagePreference =
+ gwyResourceProfileRepository.getStoragePreference(gatewayID, storageId);
+ logger.debug("Airavata retrieved storage resource preference with gateway id : " + gatewayID
+ + " and for storage resource id : " + storageId);
+ return storagePreference;
+ }
+
+ public List<ComputeResourcePreference> getAllGatewayComputeResourcePreferences(String gatewayID) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ return gwyResourceProfileRepository.getGatewayProfile(gatewayID).getComputeResourcePreferences();
+ }
+
+ public List<StoragePreference> getAllGatewayStoragePreferences(String gatewayID) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ return gwyResourceProfileRepository.getGatewayProfile(gatewayID).getStoragePreferences();
+ }
+
+ public List<GatewayResourceProfile> getAllGatewayResourceProfiles() throws AppCatalogException {
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ return gwyResourceProfileRepository.getAllGatewayProfiles();
+ }
+
+ public boolean deleteGatewayComputeResourcePreference(String gatewayID, String computeResourceId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ return gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(
+ gatewayID, computeResourceId);
+ }
+
+ public boolean deleteGatewayStoragePreference(String gatewayID, String storageId) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ return gwyResourceProfileRepository.removeDataStoragePreferenceFromGateway(gatewayID, storageId);
+ }
+
+ public DataProductModel getDataProduct(String productUri) throws RegistryException {
+ DataProductModel dataProductModel = dataProductRepository.getDataProduct(productUri);
+ return dataProductModel;
+ }
+
+ public DataProductModel getParentDataProduct(String productUri) throws RegistryException {
+ DataProductModel dataProductModel = dataProductRepository.getParentDataProduct(productUri);
+ return dataProductModel;
+ }
+
+ public List<DataProductModel> getChildDataProducts(String productUri) throws RegistryException {
+ List<DataProductModel> dataProductModels = dataProductRepository.getChildDataProducts(productUri);
+ return dataProductModels;
+ }
+
+ public List<DataProductModel> searchDataProductsByName(
+ String gatewayId, String userId, String productName, int limit, int offset) throws RegistryException {
+ List<DataProductModel> dataProductModels =
+ dataProductRepository.searchDataProductsByName(gatewayId, userId, productName, limit, offset);
+ return dataProductModels;
+ }
+
+ public String createGroupResourceProfile(GroupResourceProfile groupResourceProfile) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(groupResourceProfile.getGatewayId())) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ String groupResourceProfileId =
+ groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
+ logger.debug("New Group Resource Profile Created: " + groupResourceProfileId);
+ return groupResourceProfileId;
+ }
+
+ public void updateGroupResourceProfile(GroupResourceProfile groupResourceProfile) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ if (!groupResourceProfileRepository.isGroupResourceProfileExists(
+ groupResourceProfile.getGroupResourceProfileId())) {
+ logger.error(
+ "Cannot update. No group resource profile found with matching gatewayId and groupResourceProfileId");
+ throw new AppCatalogException(
+ "Cannot update. No group resource profile found with matching gatewayId and groupResourceProfileId");
+ }
+ String groupResourceProfileId =
+ groupResourceProfileRepository.updateGroupResourceProfile(groupResourceProfile);
+ logger.debug(" Group Resource Profile updated: " + groupResourceProfileId);
+ }
+
+ public GroupResourceProfile getGroupResourceProfile(String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ if (!groupResourceProfileRepository.isGroupResourceProfileExists(groupResourceProfileId)) {
+ logger.error("No group resource profile found with matching gatewayId and groupResourceProfileId");
+ throw new AppCatalogException(
+ "No group resource profile found with matching gatewayId and groupResourceProfileId");
+ }
+ return groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ }
+
+ public boolean isGroupResourceProfileExists(String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ return groupResourceProfileRepository.isGroupResourceProfileExists(groupResourceProfileId);
+ }
+
+ public boolean removeGroupResourceProfile(String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ if (!groupResourceProfileRepository.isGroupResourceProfileExists(groupResourceProfileId)) {
+ logger.error(
+ "Cannot Remove. No group resource profile found with matching gatewayId and groupResourceProfileId");
+ throw new AppCatalogException(
+ "Cannot Remove. No group resource profile found with matching gatewayId and groupResourceProfileId");
+ }
+ return groupResourceProfileRepository.removeGroupResourceProfile(groupResourceProfileId);
+ }
+
+ public List<GroupResourceProfile> getGroupResourceList(String gatewayId, List<String> accessibleGroupResProfileIds) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ return groupResourceProfileRepository.getAllGroupResourceProfiles(gatewayId, accessibleGroupResProfileIds);
+ }
+
+ public boolean removeGroupComputePrefs(String computeResourceId, String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ groupResourceProfileRepository.removeGroupComputeResourcePreference(
+ computeResourceId, groupResourceProfileId);
+ logger.debug("Removed compute resource preferences with compute resource ID: " + computeResourceId);
+ return true;
+ }
+
+ public boolean removeGroupComputeResourcePolicy(String resourcePolicyId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ groupResourceProfileRepository.removeComputeResourcePolicy(resourcePolicyId);
+ logger.debug("Removed compute resource policy with resource policy ID: " + resourcePolicyId);
+ return true;
+ }
+
+ public boolean removeGroupBatchQueueResourcePolicy(String resourcePolicyId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ groupResourceProfileRepository.removeBatchQueueResourcePolicy(resourcePolicyId);
+ logger.debug("Removed batch resource policy with resource policy ID: " + resourcePolicyId);
+ return true;
+ }
+
+ public GroupComputeResourcePreference getGroupComputeResourcePreference(
+ String computeResourceId, String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ GroupComputeResourcePreference groupComputeResourcePreference =
+ groupResourceProfileRepository.getGroupComputeResourcePreference(
+ computeResourceId, groupResourceProfileId);
+ if (!(groupComputeResourcePreference != null)) {
+ logger.error("GroupComputeResourcePreference not found");
+ throw new AppCatalogException("GroupComputeResourcePreference not found ");
+ }
+ return groupComputeResourcePreference;
+ }
+
+ public boolean isGroupComputeResourcePreferenceExists(String computeResourceId, String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ return groupResourceProfileRepository.isGroupComputeResourcePreferenceExists(
+ computeResourceId, groupResourceProfileId);
+ }
+
+ public ComputeResourcePolicy getGroupComputeResourcePolicy(String resourcePolicyId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ ComputeResourcePolicy computeResourcePolicy =
+ groupResourceProfileRepository.getComputeResourcePolicy(resourcePolicyId);
+ if (!(computeResourcePolicy != null)) {
+ logger.error("Group Compute Resource policy not found");
+ throw new AppCatalogException("Group Compute Resource policy not found ");
+ }
+ return computeResourcePolicy;
+ }
+
+ public BatchQueueResourcePolicy getBatchQueueResourcePolicy(String resourcePolicyId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ BatchQueueResourcePolicy batchQueueResourcePolicy =
+ groupResourceProfileRepository.getBatchQueueResourcePolicy(resourcePolicyId);
+ if (!(batchQueueResourcePolicy != null)) {
+ logger.error("Group Batch Queue Resource policy not found");
+ throw new AppCatalogException("Group Batch Queue Resource policy not found ");
+ }
+ return batchQueueResourcePolicy;
+ }
+
+ public List<GroupComputeResourcePreference> getGroupComputeResourcePrefList(String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ return groupResourceProfileRepository.getAllGroupComputeResourcePreferences(groupResourceProfileId);
+ }
+
+ public List<BatchQueueResourcePolicy> getGroupBatchQueueResourcePolicyList(String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ return groupResourceProfileRepository.getAllGroupBatchQueueResourcePolicies(groupResourceProfileId);
+ }
+
+ public List<ComputeResourcePolicy> getGroupComputeResourcePolicyList(String groupResourceProfileId) throws AppCatalogException {
+ GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
+ return groupResourceProfileRepository.getAllGroupComputeResourcePolicies(groupResourceProfileId);
+ }
+
+ public String registerReplicaLocation(DataReplicaLocationModel replicaLocationModel) throws RegistryException {
+ String replicaId = dataReplicaLocationRepository.registerReplicaLocation(replicaLocationModel);
+ return replicaId;
+ }
+
+ public String registerDataProduct(DataProductModel dataProductModel) throws RegistryException {
+ String productUrl = dataProductRepository.registerDataProduct(dataProductModel);
+ return productUrl;
+ }
+
+ public LOCALDataMovement getLocalDataMovement(String dataMovementId) throws AppCatalogException {
+ LOCALDataMovement localDataMovement = new ComputeResourceRepository().getLocalDataMovement(dataMovementId);
+ logger.debug("Airavata retrieved local data movement with data movement id: " + dataMovementId);
+ return localDataMovement;
+ }
+
+ public SCPDataMovement getSCPDataMovement(String dataMovementId) throws AppCatalogException {
+ SCPDataMovement scpDataMovement = new ComputeResourceRepository().getSCPDataMovement(dataMovementId);
+ logger.debug("Airavata retrieved SCP data movement with data movement id: " + dataMovementId);
+ return scpDataMovement;
+ }
+
+ public UnicoreDataMovement getUnicoreDataMovement(String dataMovementId) throws AppCatalogException {
+ UnicoreDataMovement unicoreDataMovement =
+ new ComputeResourceRepository().getUNICOREDataMovement(dataMovementId);
+ logger.debug("Airavata retrieved UNICORE data movement with data movement id: " + dataMovementId);
+ return unicoreDataMovement;
+ }
+
+ public GridFTPDataMovement getGridFTPDataMovement(String dataMovementId) throws AppCatalogException {
+ GridFTPDataMovement gridFTPDataMovement =
+ new ComputeResourceRepository().getGridFTPDataMovement(dataMovementId);
+ logger.debug("Airavata retrieved GRIDFTP data movement with data movement id: " + dataMovementId);
+ return gridFTPDataMovement;
+ }
+
+ // Experiment operations
+ public String createExperiment(String gatewayId, ExperimentModel experiment) throws RegistryException {
+ if (!validateString(experiment.getExperimentName())) {
+ logger.error("Cannot create experiments with empty experiment name");
+ throw new RegistryException("Cannot create experiments with empty experiment name");
+ }
+ logger.info("Creating experiment with name " + experiment.getExperimentName());
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+
+ if (experiment.getUserConfigurationData() != null
+ && experiment.getUserConfigurationData().getComputationalResourceScheduling() != null
+ && experiment
+ .getUserConfigurationData()
+ .getComputationalResourceScheduling()
+ .getResourceHostId()
+ != null) {
+
+ String compResourceId = experiment
+ .getUserConfigurationData()
+ .getComputationalResourceScheduling()
+ .getResourceHostId();
+ try {
+ ComputeResourceDescription computeResourceDescription =
+ new ComputeResourceRepository().getComputeResource(compResourceId);
+ if (!computeResourceDescription.isEnabled()) {
+ logger.error("Compute Resource is not enabled by the Admin!");
+ throw new RegistryException("Compute Resource is not enabled by the Admin!");
+ }
+ } catch (AppCatalogException e) {
+ throw new RegistryException("Error checking compute resource: " + e.getMessage(), e);
+ }
+ } else if (experiment.getUserConfigurationData() != null
+ && !experiment
+ .getUserConfigurationData()
+ .getAutoScheduledCompResourceSchedulingList()
+ .isEmpty()) {
+ for (ComputationalResourceSchedulingModel computationalResourceScheduling :
+ experiment.getUserConfigurationData().getAutoScheduledCompResourceSchedulingList()) {
+ try {
+ ComputeResourceDescription computeResourceDescription = new ComputeResourceRepository()
+ .getComputeResource(computationalResourceScheduling.getResourceHostId());
+ if (!computeResourceDescription.isEnabled()) {
+ logger.error("Compute Resource with id" + computationalResourceScheduling.getResourceHostId()
+ + "" + " is not enabled by the Admin!");
+ throw new RegistryException(
+ "Compute Resource with id" + computationalResourceScheduling.getResourceHostId() + ""
+ + " is not enabled by the Admin!");
+ }
+ } catch (AppCatalogException e) {
+ throw new RegistryException("Error checking compute resource: " + e.getMessage(), e);
+ }
+ }
+ }
+
+ experiment.setGatewayId(gatewayId);
+ String experimentId = experimentRepository.addExperiment(experiment);
+ if (experiment.getExperimentType() == ExperimentType.WORKFLOW) {
+ try {
+ workflowRepository.registerWorkflow(experiment.getWorkflow(), experimentId);
+ } catch (WorkflowCatalogException e) {
+ throw new RegistryException("Error registering workflow: " + e.getMessage(), e);
+ }
+ }
+ logger.debug(
+ experimentId, "Created new experiment with experiment name {}", experiment.getExperimentName());
+ return experimentId;
+ }
+
+ public List<ExperimentSummaryModel> searchExperiments(
+ String gatewayId,
+ String userName,
+ List<String> accessibleExpIds,
+ Map<ExperimentSearchFields, String> filters,
+ int limit,
+ int offset) throws RegistryException {
+ if (!validateString(userName)) {
+ logger.error("Username cannot be empty. Please provide a valid user..");
+ throw new RegistryException("Username cannot be empty. Please provide a valid user..");
+ }
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ if (!userRepository.isUserExists(gatewayId, userName)) {
+ logger.error("User does not exist in the system. Please provide a valid user..");
+ throw new RegistryException("User does not exist in the system. Please provide a valid user..");
+ }
+ List<ExperimentSummaryModel> summaries = new ArrayList<ExperimentSummaryModel>();
+ Map<String, String> regFilters = new HashMap<String, String>();
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);
+ for (Map.Entry<ExperimentSearchFields, String> entry : filters.entrySet()) {
+ if (entry.getKey().equals(ExperimentSearchFields.EXPERIMENT_NAME)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.EXPERIMENT_DESC)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.DESCRIPTION, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.APPLICATION_ID)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.STATUS)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.FROM_DATE)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.TO_DATE)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.PROJECT_ID)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.PROJECT_ID, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.USER_NAME)) {
+ regFilters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, entry.getValue());
+ } else if (entry.getKey().equals(ExperimentSearchFields.JOB_ID)) {
+ regFilters.put(Constants.FieldConstants.JobConstants.JOB_ID, entry.getValue());
+ }
+ }
+
+ try {
+ if (accessibleExpIds.size() == 0 && !ServerSettings.isEnableSharing()) {
+ if (!regFilters.containsKey(DBConstants.Experiment.USER_NAME)) {
+ regFilters.put(DBConstants.Experiment.USER_NAME, userName);
+ }
+ }
+ } catch (Exception e) {
+ logger.warn("Error checking sharing settings, continuing without filter", e);
+ }
+ summaries = experimentSummaryRepository.searchAllAccessibleExperiments(
+ accessibleExpIds,
+ regFilters,
+ limit,
+ offset,
+ Constants.FieldConstants.ExperimentConstants.CREATION_TIME,
+ ResultOrderType.DESC);
+ logger.debug("Airavata retrieved experiments for user : " + userName + " and gateway id : " + gatewayId);
+ return summaries;
+ }
+
+ public void updateExperiment(String airavataExperimentId, ExperimentModel experiment) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.error(
+ airavataExperimentId,
+ "Update request failed, Experiment {} doesn't exist.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+
+ ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
+ if (experimentStatus != null) {
+ ExperimentState experimentState = experimentStatus.getState();
+ switch (experimentState) {
+ case CREATED:
+ case SCHEDULED:
+ case VALIDATED:
+ if (experiment.getUserConfigurationData() != null
+ && experiment.getUserConfigurationData().getComputationalResourceScheduling() != null
+ && experiment
+ .getUserConfigurationData()
+ .getComputationalResourceScheduling()
+ .getResourceHostId()
+ != null) {
+ String compResourceId = experiment
+ .getUserConfigurationData()
+ .getComputationalResourceScheduling()
+ .getResourceHostId();
+ try {
+ ComputeResourceDescription computeResourceDescription =
+ new ComputeResourceRepository().getComputeResource(compResourceId);
+ if (!computeResourceDescription.isEnabled()) {
+ logger.error("Compute Resource is not enabled by the Admin!");
+ throw new RegistryException("Compute Resource is not enabled by the Admin!");
+ }
+ } catch (AppCatalogException e) {
+ throw new RegistryException("Error checking compute resource: " + e.getMessage(), e);
+ }
+ }
+ experimentRepository.updateExperiment(experiment, airavataExperimentId);
+ logger.debug(
+ airavataExperimentId,
+ "Successfully updated experiment {} ",
+ experiment.getExperimentName());
+ break;
+ default:
+ logger.error(
+ airavataExperimentId,
+ "Error while updating experiment. Update experiment is only valid for experiments "
+ + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
+ + "experiment is in one of above statuses... ");
+ throw new RegistryException(
+ "Error while updating experiment. Update experiment is only valid for experiments "
+ + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
+ + "experiment is in one of above statuses... ");
+ }
+ }
+ }
+
+ public void updateExperimentConfiguration(String airavataExperimentId, UserConfigurationDataModel userConfiguration) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.error(
+ airavataExperimentId,
+ "Update experiment configuration failed, experiment {} doesn't exist.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
+ if (experimentStatus != null) {
+ ExperimentState experimentState = experimentStatus.getState();
+ switch (experimentState) {
+ case CREATED:
+ case VALIDATED:
+ case CANCELED:
+ case FAILED:
+ experimentRepository.addUserConfigurationData(userConfiguration, airavataExperimentId);
+ logger.debug(
+ airavataExperimentId,
+ "Successfully updated experiment configuration for experiment {}.",
+ airavataExperimentId);
+ break;
+ default:
+ logger.error(
+ airavataExperimentId,
+ "Error while updating experiment {}. Update experiment is only valid for experiments "
+ + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
+ + "experiment is in one of above statuses... ",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Error while updating experiment. Update experiment is only valid for experiments "
+ + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
+ + "experiment is in one of above statuses... ");
+ }
+ }
+ }
+
+ public List<OutputDataObjectType> getIntermediateOutputs(String airavataExperimentId) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.error(
+ airavataExperimentId,
+ "Error while retrieving intermediate outputs, experiment {} doesn't exist.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ List<ProcessModel> processModels = processRepository.getProcessList(
+ Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, airavataExperimentId);
+ List<OutputDataObjectType> intermediateOutputs = new ArrayList<>();
+ if (processModels != null && !processModels.isEmpty()) {
+ for (ProcessModel processModel : processModels) {
+ List<OutputDataObjectType> processOutputs = processOutputRepository.getProcessOutputs(processModel.getProcessId());
+ if (processOutputs != null && !processOutputs.isEmpty()) {
+ intermediateOutputs.addAll(processOutputs);
+ }
+ }
+ }
+ logger.debug("Airavata retrieved intermediate outputs for experiment with experiment id : " + airavataExperimentId);
+ return intermediateOutputs;
+ }
+
+ public Map<String, JobStatus> getJobStatuses(String airavataExperimentId) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.error(
+ airavataExperimentId,
+ "Error while retrieving job statuses, experiment {} doesn't exist.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ Map<String, JobStatus> jobStatus = new HashMap<>();
+ List<ProcessModel> processModels = processRepository.getProcessList(
+ Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, airavataExperimentId);
+ if (processModels != null && !processModels.isEmpty()) {
+ for (ProcessModel processModel : processModels) {
+ List<TaskModel> tasks = processModel.getTasks();
+ if (tasks != null && !tasks.isEmpty()) {
+ for (TaskModel taskModel : tasks) {
+ String taskId = taskModel.getTaskId();
+ List<JobModel> taskJobs =
+ jobRepository.getJobList(Constants.FieldConstants.JobConstants.TASK_ID, taskId);
+ if (taskJobs != null && !taskJobs.isEmpty()) {
+ for (JobModel jobModel : taskJobs) {
+ JobPK jobPK = new JobPK();
+ jobPK.setJobId(jobModel.getJobId());
+ jobPK.setTaskId(taskId);
+ JobStatus status = jobStatusRepository.getJobStatus(jobPK);
+ if (status != null) {
+ jobStatus.put(jobModel.getJobId(), status);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ logger.debug("Airavata retrieved job statuses for experiment with experiment id : " + airavataExperimentId);
+ return jobStatus;
+ }
+
+ public void addExperimentProcessOutputs(String outputType, List<OutputDataObjectType> outputs, String id) throws RegistryException {
+ if (ExpCatChildDataType.PROCESS_OUTPUT.equals(ExpCatChildDataType.valueOf(outputType))) {
+ processOutputRepository.addProcessOutputs(outputs, id);
+ } else if (ExpCatChildDataType.EXPERIMENT_OUTPUT.equals(ExpCatChildDataType.valueOf(outputType))) {
+ experimentOutputRepository.addExperimentOutputs(outputs, id);
+ }
+ }
+
+ public void addErrors(String errorType, ErrorModel errorModel, String id) throws RegistryException {
+ if (ExpCatChildDataType.EXPERIMENT_ERROR.equals(ExpCatChildDataType.valueOf(errorType))) {
+ experimentErrorRepository.addExperimentError(errorModel, id);
+ } else if (ExpCatChildDataType.TASK_ERROR.equals(ExpCatChildDataType.valueOf(errorType))) {
+ taskErrorRepository.addTaskError(errorModel, id);
+ } else if (ExpCatChildDataType.PROCESS_ERROR.equals(ExpCatChildDataType.valueOf(errorType))) {
+ processErrorRepository.addProcessError(errorModel, id);
+ }
+ }
+
+ public void addTaskStatus(TaskStatus taskStatus, String taskId) throws RegistryException {
+ taskStatusRepository.addTaskStatus(taskStatus, taskId);
+ }
+
+ public void addProcessStatus(ProcessStatus processStatus, String processId) throws RegistryException {
+ processStatusRepository.addProcessStatus(processStatus, processId);
+ }
+
+ public void updateProcessStatus(ProcessStatus processStatus, String processId) throws RegistryException {
+ processStatusRepository.updateProcessStatus(processStatus, processId);
+ }
+
+ public void updateExperimentStatus(ExperimentStatus experimentStatus, String experimentId) throws RegistryException {
+ experimentStatusRepository.updateExperimentStatus(experimentStatus, experimentId);
+ }
+
+ public void addJobStatus(JobStatus jobStatus, String taskId, String jobId) throws RegistryException {
+ JobPK jobPK = new JobPK();
+ jobPK.setJobId(jobId);
+ jobPK.setTaskId(taskId);
+ jobStatusRepository.addJobStatus(jobStatus, jobPK);
+ }
+
+ public void deleteJobs(String processId) throws RegistryException {
+ List<JobModel> jobs = jobRepository.getJobList(Constants.FieldConstants.JobConstants.PROCESS_ID, processId);
+ for (JobModel jobModel : jobs) {
+ jobRepository.removeJob(jobModel);
+ }
+ }
+
+ // Project operations
+ public String createProject(String gatewayId, Project project) throws RegistryException {
+ if (!validateString(project.getName()) || !validateString(project.getOwner())) {
+ logger.error("Project name and owner cannot be empty...");
+ throw new RegistryException("Project name and owner cannot be empty...");
+ }
+ if (!validateString(gatewayId)) {
+ logger.error("Gateway ID cannot be empty...");
+ throw new RegistryException("Gateway ID cannot be empty...");
+ }
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ String projectId = projectRepository.addProject(project, gatewayId);
+ return projectId;
+ }
+
+ public void updateProject(String projectId, Project updatedProject) throws RegistryException {
+ if (!validateString(projectId)) {
+ logger.error("Project id cannot be empty...");
+ throw new RegistryException("Project id cannot be empty...");
+ }
+ if (!projectRepository.isProjectExist(projectId)) {
+ logger.error("Project does not exist in the system. Please provide a valid project ID...");
+ throw new RegistryException("Project does not exist in the system. Please provide a valid project ID...");
+ }
+ projectRepository.updateProject(updatedProject, projectId);
+ logger.debug("Airavata updated project with project Id : " + projectId);
+ }
+
+ public List<Project> searchProjects(
+ String gatewayId,
+ String userName,
+ List<String> accessibleProjIds,
+ Map<ProjectSearchFields, String> filters,
+ int limit,
+ int offset) throws RegistryException {
+ if (!validateString(userName)) {
+ logger.error("Username cannot be empty. Please provide a valid user..");
+ throw new RegistryException("Username cannot be empty. Please provide a valid user..");
+ }
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new RegistryException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ if (!userRepository.isUserExists(gatewayId, userName)) {
+ logger.error("User does not exist in the system. Please provide a valid user..");
+ throw new RegistryException("User does not exist in the system. Please provide a valid user..");
+ }
+ List<Project> projects = new ArrayList<>();
+ Map<String, String> regFilters = new HashMap<>();
+ regFilters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
+ for (Map.Entry<ProjectSearchFields, String> entry : filters.entrySet()) {
+ if (entry.getKey().equals(ProjectSearchFields.PROJECT_NAME)) {
+ regFilters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, entry.getValue());
+ } else if (entry.getKey().equals(ProjectSearchFields.PROJECT_DESCRIPTION)) {
+ regFilters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, entry.getValue());
+ }
+ }
+
+ try {
+ if (accessibleProjIds.size() == 0 && !ServerSettings.isEnableSharing()) {
+ if (!regFilters.containsKey(DBConstants.Project.OWNER)) {
+ regFilters.put(DBConstants.Project.OWNER, userName);
+ }
+ }
+ } catch (Exception e) {
+ logger.warn("Error checking sharing settings, continuing without filter", e);
+ }
+
+ projects = projectRepository.searchAllAccessibleProjects(
+ accessibleProjIds,
+ regFilters,
+ limit,
+ offset,
+ Constants.FieldConstants.ProjectConstants.CREATION_TIME,
+ ResultOrderType.DESC);
+ logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId);
+ return projects;
+ }
+
+ // Gateway Resource Profile operations
+ public String registerGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) throws AppCatalogException {
+ if (!validateString(gatewayResourceProfile.getGatewayID())) {
+ logger.error("Cannot create gateway profile with empty gateway id");
+ throw new AppCatalogException("Cannot create gateway profile with empty gateway id");
+ }
+ try {
+ if (!isGatewayExistInternal(gatewayResourceProfile.getGatewayID())) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ String resourceProfile = gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
+ logger.debug(
+ "Airavata registered gateway profile with gateway id : " + gatewayResourceProfile.getGatewayID());
+ return resourceProfile;
+ }
+
+ public boolean updateGatewayResourceProfile(String gatewayID, GatewayResourceProfile gatewayResourceProfile) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ gwyResourceProfileRepository.updateGatewayResourceProfile(gatewayResourceProfile);
+ logger.debug("Airavata updated gateway profile with gateway id : " + gatewayID);
+ return true;
+ }
+
+ public boolean addGatewayComputeResourcePreference(
+ String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ if (!(gwyResourceProfileRepository.isExists(gatewayID))) {
+ throw new AppCatalogException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
+ }
+ GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
+ profile.addToComputeResourcePreferences(computeResourcePreference);
+ gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
+ logger.debug("Airavata added gateway compute resource preference with gateway id : " + gatewayID
+ + " and for compute resource id : " + computeResourceId);
+ return true;
+ }
+
+ public boolean updateGatewayComputeResourcePreference(
+ String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
+ List<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences();
+ ComputeResourcePreference preferenceToRemove = null;
+ for (ComputeResourcePreference preference : computeResourcePreferences) {
+ if (preference.getComputeResourceId().equals(computeResourceId)) {
+ preferenceToRemove = preference;
+ break;
+ }
+ }
+ if (preferenceToRemove != null) {
+ profile.getComputeResourcePreferences().remove(preferenceToRemove);
+ }
+ profile.getComputeResourcePreferences().add(computeResourcePreference);
+ gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
+ logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID
+ + " and for compute resource id : " + computeResourceId);
+ return true;
+ }
+
+ public boolean addGatewayStoragePreference(
+ String gatewayID, String storageResourceId, StoragePreference dataStoragePreference) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ if (!(gwyResourceProfileRepository.isExists(gatewayID))) {
+ throw new AppCatalogException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
+ }
+ GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
+ dataStoragePreference.setStorageResourceId(storageResourceId);
+ profile.addToStoragePreferences(dataStoragePreference);
+ gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
+ logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID
+ + " and for storage resource id : " + storageResourceId);
+ return true;
+ }
+
+ public boolean updateGatewayStoragePreference(
+ String gatewayID, String storageId, StoragePreference storagePreference) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayID)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
+ GatewayResourceProfile profile = gwyResourceProfileRepository.getGatewayProfile(gatewayID);
+ List<StoragePreference> dataStoragePreferences = profile.getStoragePreferences();
+ StoragePreference preferenceToRemove = null;
+ for (StoragePreference preference : dataStoragePreferences) {
+ if (preference.getStorageResourceId().equals(storageId)) {
+ preferenceToRemove = preference;
+ break;
+ }
+ }
+ if (preferenceToRemove != null) {
+ profile.getStoragePreferences().remove(preferenceToRemove);
+ }
+ profile.getStoragePreferences().add(storagePreference);
+ gwyResourceProfileRepository.updateGatewayResourceProfile(profile);
+ logger.debug("Airavata updated storage resource preference with gateway id : " + gatewayID
+ + " and for storage resource id : " + storageId);
+ return true;
+ }
+
+ // Compute Resource operations
+ public String registerComputeResource(ComputeResourceDescription computeResourceDescription) throws AppCatalogException {
+ String computeResource = new ComputeResourceRepository().addComputeResource(computeResourceDescription);
+ logger.debug("Airavata registered compute resource with compute resource Id : " + computeResource);
+ return computeResource;
+ }
+
+ public boolean updateComputeResource(
+ String computeResourceId, ComputeResourceDescription computeResourceDescription) throws AppCatalogException {
+ new ComputeResourceRepository().updateComputeResource(computeResourceId, computeResourceDescription);
+ logger.debug("Airavata updated compute resource with compute resource Id : " + computeResourceId);
+ return true;
+ }
+
+ public String registerResourceJobManager(ResourceJobManager resourceJobManager) throws AppCatalogException {
+ return new ComputeResourceRepository().addResourceJobManager(resourceJobManager);
+ }
+
+ public boolean updateResourceJobManager(String resourceJobManagerId, ResourceJobManager updatedResourceJobManager) throws AppCatalogException {
+ new ComputeResourceRepository().updateResourceJobManager(resourceJobManagerId, updatedResourceJobManager);
+ return true;
+ }
+
+ public boolean deleteDataMovementInterface(String resourceId, String dataMovementInterfaceId, DMType dmType) throws AppCatalogException {
+ switch (dmType) {
+ case COMPUTE_RESOURCE:
+ new ComputeResourceRepository().removeDataMovementInterface(resourceId, dataMovementInterfaceId);
+ logger.debug(
+ "Airavata deleted data movement interface with interface id : " + dataMovementInterfaceId);
+ return true;
+ case STORAGE_RESOURCE:
+ storageResourceRepository.removeDataMovementInterface(resourceId, dataMovementInterfaceId);
+ logger.debug(
+ "Airavata deleted data movement interface with interface id : " + dataMovementInterfaceId);
+ return true;
+ default:
+ logger.error(
+ "Unsupported data movement type specifies.. Please provide the correct data movement type... ");
+ return false;
+ }
+ }
+
+ public boolean updateGridFTPDataMovementDetails(
+ String dataMovementInterfaceId, GridFTPDataMovement gridFTPDataMovement) throws AppCatalogException {
+ throw new AppCatalogException("updateGridFTPDataMovementDetails is not yet implemented");
+ }
+
+ public String addGridFTPDataMovementDetails(
+ String computeResourceId, DMType dmType, int priorityOrder, GridFTPDataMovement gridFTPDataMovement) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String addDataMovementInterface = addDataMovementInterface(
+ computeResourceRepository,
+ computeResourceId,
+ dmType,
+ computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement),
+ DataMovementProtocol.GridFTP,
+ priorityOrder);
+ logger.debug("Airavata registered GridFTP data movement for resource Id: " + computeResourceId);
+ return addDataMovementInterface;
+ }
+
+ public boolean updateUnicoreDataMovementDetails(
+ String dataMovementInterfaceId, UnicoreDataMovement unicoreDataMovement) throws AppCatalogException {
+ throw new AppCatalogException("updateUnicoreDataMovementDetails is not yet implemented");
+ }
+
+ public String addUnicoreDataMovementDetails(
+ String resourceId, DMType dmType, int priorityOrder, UnicoreDataMovement unicoreDataMovement) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String movementInterface = addDataMovementInterface(
+ computeResourceRepository,
+ resourceId,
+ dmType,
+ computeResourceRepository.addUnicoreDataMovement(unicoreDataMovement),
+ DataMovementProtocol.UNICORE_STORAGE_SERVICE,
+ priorityOrder);
+ logger.debug("Airavata registered UNICORE data movement for resource Id: " + resourceId);
+ return movementInterface;
+ }
+
+ public boolean updateSCPDataMovementDetails(String dataMovementInterfaceId, SCPDataMovement scpDataMovement) throws AppCatalogException {
+ new ComputeResourceRepository().updateScpDataMovement(scpDataMovement);
+ logger.debug("Airavata updated SCP data movement with data movement id: " + dataMovementInterfaceId);
+ return true;
+ }
+
+ public String addSCPDataMovementDetails(
+ String resourceId, DMType dmType, int priorityOrder, SCPDataMovement scpDataMovement) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String movementInterface = addDataMovementInterface(
+ computeResourceRepository,
+ resourceId,
+ dmType,
+ computeResourceRepository.addScpDataMovement(scpDataMovement),
+ DataMovementProtocol.SCP,
+ priorityOrder);
+ logger.debug("Airavata registered SCP data movement for resource Id: " + resourceId);
+ return movementInterface;
+ }
+
+ public boolean updateLocalDataMovementDetails(String dataMovementInterfaceId, LOCALDataMovement localDataMovement) throws AppCatalogException {
+ new ComputeResourceRepository().updateLocalDataMovement(localDataMovement);
+ logger.debug("Airavata updated local data movement with data movement id: " + dataMovementInterfaceId);
+ return true;
+ }
+
+ public String addLocalDataMovementDetails(
+ String resourceId, DMType dataMoveType, int priorityOrder, LOCALDataMovement localDataMovement) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String movementInterface = addDataMovementInterface(
+ computeResourceRepository,
+ resourceId,
+ dataMoveType,
+ computeResourceRepository.addLocalDataMovement(localDataMovement),
+ DataMovementProtocol.LOCAL,
+ priorityOrder);
+ logger.debug("Airavata registered local data movement for resource Id: " + resourceId);
+ return movementInterface;
+ }
+
+ // Storage Resource operations
+ public String registerStorageResource(StorageResourceDescription storageResourceDescription) throws AppCatalogException {
+ String storageResource = storageResourceRepository.addStorageResource(storageResourceDescription);
+ logger.debug("Airavata registered storage resource with storage resource Id : " + storageResource);
+ return storageResource;
+ }
+
+ public boolean updateStorageResource(
+ String storageResourceId, StorageResourceDescription storageResourceDescription) throws AppCatalogException {
+ storageResourceRepository.updateStorageResource(storageResourceId, storageResourceDescription);
+ logger.debug("Airavata updated storage resource with storage resource Id : " + storageResourceId);
+ return true;
+ }
+
+ // Helper methods for job submission and data movement interfaces
+ private String addJobSubmissionInterface(
+ ComputeResourceRepository computeResourceRepository,
+ String computeResourceId,
+ String jobSubmissionInterfaceId,
+ JobSubmissionProtocol protocolType,
+ int priorityOrder) throws AppCatalogException {
+ JobSubmissionInterface jobSubmissionInterface = new JobSubmissionInterface();
+ jobSubmissionInterface.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
+ jobSubmissionInterface.setPriorityOrder(priorityOrder);
+ jobSubmissionInterface.setJobSubmissionProtocol(protocolType);
+ return computeResourceRepository.addJobSubmissionProtocol(computeResourceId, jobSubmissionInterface);
+ }
+
+ private String addDataMovementInterface(
+ ComputeResourceRepository computeResourceRepository,
+ String computeResourceId,
+ DMType dmType,
+ String dataMovementInterfaceId,
+ DataMovementProtocol protocolType,
+ int priorityOrder) throws AppCatalogException {
+ DataMovementInterface dataMovementInterface = new DataMovementInterface();
+ dataMovementInterface.setDataMovementInterfaceId(dataMovementInterfaceId);
+ dataMovementInterface.setPriorityOrder(priorityOrder);
+ dataMovementInterface.setDataMovementProtocol(protocolType);
+ if (dmType.equals(DMType.COMPUTE_RESOURCE)) {
+ return computeResourceRepository.addDataMovementProtocol(computeResourceId, dmType, dataMovementInterface);
+ } else if (dmType.equals(DMType.STORAGE_RESOURCE)) {
+ dataMovementInterface.setStorageResourceId(computeResourceId);
+ return storageResourceRepository.addDataMovementInterface(dataMovementInterface);
+ }
+ return null;
+ }
+
+ // Job Submission Interface operations
+ public String addSSHJobSubmissionDetails(
+ String computeResourceId, int priorityOrder, SSHJobSubmission sshJobSubmission) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String submissionInterface = addJobSubmissionInterface(
+ computeResourceRepository,
+ computeResourceId,
+ computeResourceRepository.addSSHJobSubmission(sshJobSubmission),
+ JobSubmissionProtocol.SSH,
+ priorityOrder);
+ logger.debug("Airavata registered SSH job submission for compute resource id: " + computeResourceId);
+ return submissionInterface;
+ }
+
+ public String addSSHForkJobSubmissionDetails(
+ String computeResourceId, int priorityOrder, SSHJobSubmission sshJobSubmission) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String submissionDetails = addJobSubmissionInterface(
+ computeResourceRepository,
+ computeResourceId,
+ computeResourceRepository.addSSHJobSubmission(sshJobSubmission),
+ JobSubmissionProtocol.SSH_FORK,
+ priorityOrder);
+ logger.debug("Airavata registered Fork job submission for compute resource id: " + computeResourceId);
+ return submissionDetails;
+ }
+
+ public String addLocalSubmissionDetails(
+ String computeResourceId, int priorityOrder, LOCALSubmission localSubmission) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String submissionInterface = addJobSubmissionInterface(
+ computeResourceRepository,
+ computeResourceId,
+ computeResourceRepository.addLocalJobSubmission(localSubmission),
+ JobSubmissionProtocol.LOCAL,
+ priorityOrder);
+ logger.debug("Airavata added local job submission for compute resource id: " + computeResourceId);
+ return submissionInterface;
+ }
+
+ public boolean updateLocalSubmissionDetails(String jobSubmissionInterfaceId, LOCALSubmission localSubmission) throws AppCatalogException {
+ new ComputeResourceRepository().updateLocalJobSubmission(localSubmission);
+ logger.debug("Airavata updated local job submission for job submission interface id: " + jobSubmissionInterfaceId);
+ return true;
+ }
+
+ public String addCloudJobSubmissionDetails(
+ String computeResourceId, int priorityOrder, CloudJobSubmission cloudSubmission) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String submissionInterface = addJobSubmissionInterface(
+ computeResourceRepository,
+ computeResourceId,
+ computeResourceRepository.addCloudJobSubmission(cloudSubmission),
+ JobSubmissionProtocol.CLOUD,
+ priorityOrder);
+ logger.debug("Airavata registered Cloud job submission for compute resource id: " + computeResourceId);
+ return submissionInterface;
+ }
+
+ public String addUNICOREJobSubmissionDetails(
+ String computeResourceId, int priorityOrder, UnicoreJobSubmission unicoreJobSubmission) throws AppCatalogException {
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ String submissionInterface = addJobSubmissionInterface(
+ computeResourceRepository,
+ computeResourceId,
+ computeResourceRepository.addUNICOREJobSubmission(unicoreJobSubmission),
+ JobSubmissionProtocol.UNICORE,
+ priorityOrder);
+ logger.debug("Airavata registered UNICORE job submission for compute resource id: " + computeResourceId);
+ return submissionInterface;
+ }
+
+ // Application Interface/Module/Deployment operations
+ public String registerApplicationInterface(String gatewayId, ApplicationInterfaceDescription applicationInterface) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ String interfaceId = applicationInterfaceRepository.addApplicationInterface(applicationInterface, gatewayId);
+ logger.debug("Airavata registered application interface for gateway id : " + gatewayId);
+ return interfaceId;
+ }
+
+ public boolean updateApplicationInterface(
+ String appInterfaceId, ApplicationInterfaceDescription applicationInterface) throws AppCatalogException {
+ applicationInterfaceRepository.updateApplicationInterface(appInterfaceId, applicationInterface);
+ logger.debug("Airavata updated application interface with interface id : " + appInterfaceId);
+ return true;
+ }
+
+ public String registerApplicationModule(String gatewayId, ApplicationModule applicationModule) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ String module = applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
+ logger.debug("Airavata registered application module for gateway id : " + gatewayId);
+ return module;
+ }
+
+ public boolean updateApplicationModule(String appModuleId, ApplicationModule applicationModule) throws AppCatalogException {
+ applicationInterfaceRepository.updateApplicationModule(appModuleId, applicationModule);
+ logger.debug("Airavata updated application module with module id: " + appModuleId);
+ return true;
+ }
+
+ public String registerApplicationDeployment(
+ String gatewayId, ApplicationDeploymentDescription applicationDeployment) throws AppCatalogException {
+ try {
+ if (!isGatewayExistInternal(gatewayId)) {
+ logger.error("Gateway does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ String deployment = applicationDeploymentRepository.addApplicationDeployment(applicationDeployment, gatewayId);
+ logger.debug("Airavata registered application deployment for gateway id : " + gatewayId);
+ return deployment;
+ }
+
+ public boolean updateApplicationDeployment(
+ String appDeploymentId, ApplicationDeploymentDescription applicationDeployment) throws AppCatalogException {
+ applicationDeploymentRepository.updateApplicationDeployment(appDeploymentId, applicationDeployment);
+ logger.debug("Airavata updated application deployment for deployment id : " + appDeploymentId);
+ return true;
+ }
+
+ // User Resource Profile operations
+ public String registerUserResourceProfile(UserResourceProfile userResourceProfile) throws AppCatalogException {
+ if (!validateString(userResourceProfile.getUserId())) {
+ logger.error("Cannot create user resource profile with empty user id");
+ throw new AppCatalogException("Cannot create user resource profile with empty user id");
+ }
+ if (!validateString(userResourceProfile.getGatewayID())) {
+ logger.error("Cannot create user resource profile with empty gateway id");
+ throw new AppCatalogException("Cannot create user resource profile with empty gateway id");
+ }
+ try {
+ if (!userRepository.isUserExists(userResourceProfile.getGatewayID(), userResourceProfile.getUserId())) {
+ logger.error("User does not exist.Please provide a valid user ID...");
+ throw new AppCatalogException("User does not exist.Please provide a valid user ID...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ String resourceProfile = userResourceProfileRepository.addUserResourceProfile(userResourceProfile);
+ logger.debug("Airavata registered user resource profile with gateway id : "
+ + userResourceProfile.getGatewayID() + "and user id : " + userResourceProfile.getUserId());
+ return resourceProfile;
+ }
+
+ public boolean isUserResourceProfileExists(String userId, String gatewayId) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayId, userId)) {
+ logger.error("user does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ return userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayId);
+ }
+
+ public UserResourceProfile getUserResourceProfile(String userId, String gatewayId) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayId, userId)) {
+ logger.error("user does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ UserResourceProfile userResourceProfile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayId);
+ logger.debug("Airavata retrieved User resource profile with user id : " + userId);
+ return userResourceProfile;
+ }
+
+ public boolean updateUserResourceProfile(String userId, String gatewayID, UserResourceProfile userResourceProfile) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("User does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, userResourceProfile);
+ logger.debug("Airavata updated gateway profile with gateway id : " + userId);
+ return true;
+ }
+
+ public boolean deleteUserResourceProfile(String userId, String gatewayID) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ userResourceProfileRepository.removeUserResourceProfile(userId, gatewayID);
+ logger.debug("Airavata deleted User profile with gateway id : " + gatewayID + " and user id : " + userId);
+ return true;
+ }
+
+ // Resource Scheduling operations
+ public void updateResourceScheduleing(
+ String airavataExperimentId, ComputationalResourceSchedulingModel resourceScheduling) throws RegistryException {
+ if (!experimentRepository.isExperimentExist(airavataExperimentId)) {
+ logger.debug(
+ airavataExperimentId,
+ "Update resource scheduling failed, experiment {} doesn't exist.",
+ airavataExperimentId);
+ throw new RegistryException(
+ "Requested experiment id " + airavataExperimentId + " does not exist in the system..");
+ }
+ ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
+ if (experimentStatus != null) {
+ ExperimentState experimentState = experimentStatus.getState();
+ switch (experimentState) {
+ case CREATED:
+ case VALIDATED:
+ case CANCELED:
+ case FAILED:
+ processRepository.addProcessResourceSchedule(resourceScheduling, airavataExperimentId);
+ logger.debug(
+ airavataExperimentId,
+ "Successfully updated resource scheduling for the experiment {}.",
+ airavataExperimentId);
+ break;
+ default:
+ logger.error(
+ airavataExperimentId,
+ "Error while updating scheduling info. Update experiment is only valid for experiments "
+ + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
+ + "experiment is in one of above statuses... ");
+ throw new RegistryException(
+ "Error while updating experiment. Update experiment is only valid for experiments "
+ + "with status CREATED, VALIDATED, CANCELLED, FAILED and UNKNOWN. Make sure the given "
+ + "experiment is in one of above statuses... ");
+ }
+ }
+ }
+
+ // User operations
+ public String addUser(UserProfile userProfile) throws RegistryException {
+ logger.info("Adding User in Registry: " + userProfile);
+ if (userRepository.isUserExists(userProfile.getGatewayId(), userProfile.getUserId())) {
+ throw new RegistryException("User already exists, with userId: " + userProfile.getUserId()
+ + ", and gatewayId: " + userProfile.getGatewayId());
+ }
+ UserProfile savedUser = userRepository.addUser(userProfile);
+ return savedUser.getUserId();
+ }
+
+ // User Compute/Storage Preference operations
+ public boolean addUserComputeResourcePreference(
+ String userId,
+ String gatewayID,
+ String computeResourceId,
+ UserComputeResourcePreference userComputeResourcePreference) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
+ throw new AppCatalogException("User resource profile with user id'" + userId + " & gateway Id"
+ + gatewayID + "' does not exist!!!");
+ }
+ UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
+ profile.addToUserComputeResourcePreferences(userComputeResourcePreference);
+ userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
+ logger.debug("Airavata added User compute resource preference with gateway id : " + gatewayID
+ + " and for compute resource id : " + computeResourceId);
+ return true;
+ }
+
+ public boolean isUserComputeResourcePreferenceExists(String userId, String gatewayID, String computeResourceId) throws AppCatalogException {
+ try {
+ if (userRepository.isUserExists(gatewayID, userId)
+ && userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
+ return userResourceProfileRepository.isUserComputeResourcePreferenceExists(
+ userId, gatewayID, computeResourceId);
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ return false;
+ }
+
+ public UserComputeResourcePreference getUserComputeResourcePreference(
+ String userId, String gatewayID, String userComputeResourceId) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
+ throw new AppCatalogException("User resource profile with user id'" + userId + " & gateway Id"
+ + gatewayID + "' does not exist!!!");
+ }
+ ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
+ if (!computeResourceRepository.isComputeResourceExists(userComputeResourceId)) {
+ logger.error(
+ userComputeResourceId,
+ "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
+ throw new AppCatalogException(
+ "Given compute resource does not exist in the system. Please provide a valid compute resource id...");
+ }
+ UserComputeResourcePreference userComputeResourcePreference =
+ userResourceProfileRepository.getUserComputeResourcePreference(
+ userId, gatewayID, userComputeResourceId);
+ logger.debug("Airavata retrieved user compute resource preference with gateway id : " + gatewayID
+ + " and for compute resoruce id : " + userComputeResourceId);
+ return userComputeResourcePreference;
+ }
+
+ public boolean updateUserComputeResourcePreference(
+ String userId,
+ String gatewayID,
+ String computeResourceId,
+ UserComputeResourcePreference userComputeResourcePreference) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
+ List<UserComputeResourcePreference> userComputeResourcePreferences =
+ profile.getUserComputeResourcePreferences();
+ UserComputeResourcePreference preferenceToRemove = null;
+ for (UserComputeResourcePreference preference : userComputeResourcePreferences) {
+ if (preference.getComputeResourceId().equals(computeResourceId)) {
+ preferenceToRemove = preference;
+ break;
+ }
+ }
+ if (preferenceToRemove != null) {
+ profile.getUserComputeResourcePreferences().remove(preferenceToRemove);
+ }
+ profile.getUserComputeResourcePreferences().add(userComputeResourcePreference);
+ userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
+ logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID
+ + " and for compute resource id : " + computeResourceId);
+ return true;
+ }
+
+ public boolean addUserStoragePreference(
+ String userId, String gatewayID, String storageResourceId, UserStoragePreference dataStoragePreference) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
+ throw new AppCatalogException("User resource profile with user id'" + userId + " & gateway Id"
+ + gatewayID + "' does not exist!!!");
+ }
+ UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
+ dataStoragePreference.setStorageResourceId(storageResourceId);
+ profile.addToUserStoragePreferences(dataStoragePreference);
+ userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
+ logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID
+ + " and for storage resource id : " + storageResourceId);
+ return true;
+ }
+
+ public UserStoragePreference getUserStoragePreference(String userId, String gatewayID, String storageId) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
+ throw new AppCatalogException("User resource profile with user id'" + userId + " & gateway Id"
+ + gatewayID + "' does not exist!!!");
+ }
+
+ UserStoragePreference storagePreference =
+ userResourceProfileRepository.getUserStoragePreference(userId, gatewayID, storageId);
+ logger.debug("Airavata retrieved user storage resource preference with gateway id : " + gatewayID
+ + " and for storage resource id : " + storageId);
+ return storagePreference;
+ }
+
+ public List<UserResourceProfile> getAllUserResourceProfiles() throws AppCatalogException {
+ return userResourceProfileRepository.getAllUserResourceProfiles();
+ }
+
+ // Gateway Groups operations
+ public GatewayGroups getGatewayGroups(String gatewayId) throws RegistryException {
+ if (!gatewayGroupsRepository.isExists(gatewayId)) {
+ final String message = "No GatewayGroups entry exists for " + gatewayId;
+ logger.error(message);
+ throw new RegistryException(message);
+ }
+ return gatewayGroupsRepository.get(gatewayId);
+ }
+
+ // Parser operations
+ public Parser getParser(String parserId, String gatewayId) throws RegistryException {
+ if (!parserRepository.isExists(parserId)) {
+ final String message = "No Parser Info entry exists for " + parserId;
+ logger.error(message);
+ throw new RegistryException(message);
+ }
+ return parserRepository.get(parserId);
+ }
+
+ public String saveParser(Parser parser) throws RegistryException {
+ try {
+ Parser saved = parserRepository.saveParser(parser);
+ return saved.getId();
+ } catch (AppCatalogException e) {
+ throw new RegistryException("Error saving parser: " + e.getMessage(), e);
+ }
+ }
+
+ public void removeParser(String parserId, String gatewayId) throws RegistryException {
+ boolean exists = parserRepository.isExists(parserId);
+ if (exists && !gatewayId.equals(parserRepository.get(parserId).getGatewayId())) {
+ parserRepository.delete(parserId);
+ } else {
+ throw new RegistryException("Parser " + parserId + " does not exist");
+ }
+ }
+
+ public ParserInput getParserInput(String parserInputId, String gatewayId) throws RegistryException {
+ if (!parserInputRepository.isExists(parserInputId)) {
+ final String message = "No ParserInput entry exists for " + parserInputId;
+ logger.error(message);
+ throw new RegistryException(message);
+ }
+ return parserInputRepository.get(parserInputId);
+ }
+
+ public String saveParserInput(ParserInput parserInput) throws RegistryException {
+ ParserInput saved = parserInputRepository.create(parserInput);
+ return saved.getId();
+ }
+
+ public void removeParserInput(String parserInputId, String gatewayId) throws RegistryException {
+ boolean exists = parserInputRepository.isExists(parserInputId);
+ if (exists) {
+ ParserInput parserInput = parserInputRepository.get(parserInputId);
+ Parser parser = parserRepository.get(parserInput.getParserId());
+ if (gatewayId.equals(parser.getGatewayId())) {
+ parserInputRepository.delete(parserInputId);
+ } else {
+ throw new RegistryException("ParserInput " + parserInputId + " does not belong to gateway " + gatewayId);
+ }
+ } else {
+ throw new RegistryException("ParserInput " + parserInputId + " does not exist");
+ }
+ }
+
+ public ParserOutput getParserOutput(String parserOutputId, String gatewayId) throws RegistryException {
+ if (!parserOutputRepository.isExists(parserOutputId)) {
+ final String message = "No ParserOutput entry exists for " + parserOutputId;
+ logger.error(message);
+ throw new RegistryException(message);
+ }
+ return parserOutputRepository.get(parserOutputId);
+ }
+
+ public String saveParserOutput(ParserOutput parserOutput) throws RegistryException {
+ ParserOutput saved = parserOutputRepository.create(parserOutput);
+ return saved.getId();
+ }
+
+ public void removeParserOutput(String parserOutputId, String gatewayId) throws RegistryException {
+ boolean exists = parserOutputRepository.isExists(parserOutputId);
+ if (exists) {
+ ParserOutput parserOutput = parserOutputRepository.get(parserOutputId);
+ Parser parser = parserRepository.get(parserOutput.getParserId());
+ if (gatewayId.equals(parser.getGatewayId())) {
+ parserOutputRepository.delete(parserOutputId);
+ } else {
+ throw new RegistryException("ParserOutput " + parserOutputId + " does not belong to gateway " + gatewayId);
+ }
+ } else {
+ throw new RegistryException("ParserOutput " + parserOutputId + " does not exist");
+ }
+ }
+
+ public ParsingTemplate getParsingTemplate(String templateId, String gatewayId) throws RegistryException {
+ if (!parsingTemplateRepository.isExists(templateId)) {
+ final String message = "No ParsingTemplate entry exists for " + templateId;
+ logger.error(message);
+ throw new RegistryException(message);
+ }
+ return parsingTemplateRepository.get(templateId);
+ }
+
+ public String saveParsingTemplate(ParsingTemplate parsingTemplate) throws RegistryException {
+ ParsingTemplate saved = parsingTemplateRepository.create(parsingTemplate);
+ return saved.getId();
+ }
+
+ public void removeParsingTemplate(String templateId, String gatewayId) throws RegistryException {
+ boolean exists = parsingTemplateRepository.isExists(templateId);
+ if (exists && !gatewayId.equals(parsingTemplateRepository.get(templateId).getGatewayId())) {
+ parsingTemplateRepository.delete(templateId);
+ } else {
+ throw new RegistryException("Parsing template " + templateId + " does not exist");
+ }
+ }
+
+ // Gateway Usage Reporting operations
+ public boolean isGatewayUsageReportingAvailable(String gatewayId, String computeResourceId) throws RegistryException {
+ return usageReportingCommandRepository.isGatewayUsageReportingCommandExists(gatewayId, computeResourceId);
+ }
+
+ public GatewayUsageReportingCommand getGatewayReportingCommand(String gatewayId, String computeResourceId) throws RegistryException {
+ if (usageReportingCommandRepository.isGatewayUsageReportingCommandExists(gatewayId, computeResourceId)) {
+ return usageReportingCommandRepository.getGatewayUsageReportingCommand(gatewayId, computeResourceId);
+ } else {
+ String message = "No usage reporting information for the gateway " + gatewayId
+ + " and compute resource " + computeResourceId;
+ logger.error(message);
+ throw new RegistryException(message);
+ }
+ }
+
+ public void addGatewayUsageReportingCommand(GatewayUsageReportingCommand command) throws RegistryException {
+ usageReportingCommandRepository.addGatewayUsageReportingCommand(command);
+ }
+
+ public void removeGatewayUsageReportingCommand(String gatewayId, String computeResourceId) throws RegistryException {
+ usageReportingCommandRepository.removeGatewayUsageReportingCommand(gatewayId, computeResourceId);
+ }
+
+ public boolean updateCloudJobSubmissionDetails(String jobSubmissionInterfaceId, CloudJobSubmission cloudJobSubmission) throws AppCatalogException {
+ cloudJobSubmission.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
+ computeResourceRepository.updateCloudJobSubmission(cloudJobSubmission);
+ logger.debug("Airavata updated Cloud job submission for job submission interface id: " + jobSubmissionInterfaceId);
+ return true;
+ }
+
+ public boolean updateSSHJobSubmissionDetails(String jobSubmissionInterfaceId, SSHJobSubmission sshJobSubmission) throws AppCatalogException {
+ sshJobSubmission.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
+ computeResourceRepository.updateSSHJobSubmission(sshJobSubmission);
+ logger.debug("Airavata updated SSH job submission for job submission interface id: " + jobSubmissionInterfaceId);
+ return true;
+ }
+
+ public boolean updateUnicoreJobSubmissionDetails(String jobSubmissionInterfaceId, UnicoreJobSubmission unicoreJobSubmission) throws AppCatalogException {
+ unicoreJobSubmission.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
+ computeResourceRepository.updateUNICOREJobSubmission(unicoreJobSubmission);
+ logger.debug("Airavata updated UNICORE job submission for job submission interface id: " + jobSubmissionInterfaceId);
+ return true;
+ }
+
+ public boolean updateNotification(Notification notification) throws RegistryException {
+ notificationRepository.updateNotification(notification);
+ logger.debug("Airavata updated notification with notification id: " + notification.getNotificationId());
+ return true;
+ }
+
+ public String createNotification(Notification notification) throws RegistryException {
+ String notificationId = notificationRepository.createNotification(notification);
+ logger.debug("Airavata created notification with notification id: " + notificationId);
+ return notificationId;
+ }
+
+ public boolean updateGateway(String gatewayId, Gateway updatedGateway) throws RegistryException, AppCatalogException {
+ if (!gatewayRepository.isGatewayExist(gatewayId)) {
+ logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
+ throw new RegistryException("Gateway does not exist in the system. Please provide a valid gateway ID...");
+ }
+ updatedGateway.setGatewayId(gatewayId);
+ gatewayRepository.updateGateway(gatewayId, updatedGateway);
+ logger.debug("Airavata updated gateway with gateway id: " + gatewayId);
+ return true;
+ }
+
+ public String addGateway(Gateway gateway) throws RegistryException, AppCatalogException {
+ if (gatewayRepository.isGatewayExist(gateway.getGatewayId())) {
+ logger.error("Gateway already exists in the system. Please provide a different gateway ID...");
+ throw new AppCatalogException("Gateway already exists in the system. Please provide a different gateway ID...");
+ }
+ String gatewayId = gatewayRepository.addGateway(gateway);
+ logger.debug("Airavata registered gateway with gateway id: " + gatewayId);
+ return gatewayId;
+ }
+
+ public boolean updateUserStoragePreference(
+ String userId, String gatewayID, String storageId, UserStoragePreference userStoragePreference) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayID)) {
+ throw new AppCatalogException("User resource profile with user id'" + userId + " & gateway Id"
+ + gatewayID + "' does not exist!!!");
+ }
+ UserResourceProfile profile = userResourceProfileRepository.getUserResourceProfile(userId, gatewayID);
+ List<UserStoragePreference> userStoragePreferences = profile.getUserStoragePreferences();
+ UserStoragePreference preferenceToRemove = null;
+ for (UserStoragePreference preference : userStoragePreferences) {
+ if (preference.getStorageResourceId().equals(storageId)) {
+ preferenceToRemove = preference;
+ break;
+ }
+ }
+ if (preferenceToRemove != null) {
+ profile.getUserStoragePreferences().remove(preferenceToRemove);
+ }
+ userStoragePreference.setStorageResourceId(storageId);
+ profile.getUserStoragePreferences().add(userStoragePreference);
+ userResourceProfileRepository.updateUserResourceProfile(userId, gatewayID, profile);
+ logger.debug("Airavata updated storage resource preference with gateway id : " + gatewayID
+ + " and for storage resource id : " + storageId);
+ return true;
+ }
+
+ public boolean deleteUserComputeResourcePreference(String userId, String gatewayID, String computeResourceId) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ return userResourceProfileRepository.removeUserComputeResourcePreferenceFromGateway(userId, gatewayID, computeResourceId);
+ }
+
+ public boolean deleteUserStoragePreference(String userId, String gatewayID, String storageId) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("user does not exist.Please provide a valid user id...");
+ throw new AppCatalogException("user does not exist.Please provide a valid user id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ return userResourceProfileRepository.removeUserDataStoragePreferenceFromGateway(userId, gatewayID, storageId);
+ }
+
+ public List<QueueStatusModel> getLatestQueueStatuses() throws RegistryException {
+ return queueStatusRepository.getLatestQueueStatuses();
+ }
+
+ public void registerQueueStatuses(List<QueueStatusModel> queueStatuses) throws RegistryException {
+ queueStatusRepository.createQueueStatuses(queueStatuses);
+ }
+
+ public QueueStatusModel getQueueStatus(String hostName, String queueName) throws RegistryException {
+ Optional<QueueStatusModel> optionalQueueStatusModel = queueStatusRepository.getQueueStatus(hostName, queueName);
+ if (optionalQueueStatusModel.isPresent()) {
+ return optionalQueueStatusModel.get();
+ } else {
+ QueueStatusModel queueStatusModel = new QueueStatusModel();
+ queueStatusModel.setHostName(hostName);
+ queueStatusModel.setQueueName(queueName);
+ queueStatusModel.setQueueUp(false);
+ queueStatusModel.setRunningJobs(0);
+ queueStatusModel.setQueuedJobs(0);
+ queueStatusModel.setTime(0);
+ return queueStatusModel;
+ }
+ }
+
+ public void createGatewayGroups(GatewayGroups gatewayGroups) throws RegistryException {
+ if (gatewayGroupsRepository.isExists(gatewayGroups.getGatewayId())) {
+ logger.error("GatewayGroups already exists for " + gatewayGroups.getGatewayId());
+ throw new RegistryException("GatewayGroups for gatewayId: " + gatewayGroups.getGatewayId() + " already exists.");
+ }
+ gatewayGroupsRepository.create(gatewayGroups);
+ }
+
+ public void updateGatewayGroups(GatewayGroups gatewayGroups) throws RegistryException {
+ if (!gatewayGroupsRepository.isExists(gatewayGroups.getGatewayId())) {
+ final String message = "No GatewayGroups entry exists for " + gatewayGroups.getGatewayId();
+ logger.error(message);
+ throw new RegistryException(message);
+ }
+ gatewayGroupsRepository.update(gatewayGroups);
+ }
+
+ public boolean isGatewayGroupsExists(String gatewayId) throws RegistryException {
+ return gatewayGroupsRepository.isExists(gatewayId);
+ }
+
+ public List<Parser> listAllParsers(String gatewayId) throws RegistryException {
+ return parserRepository.getAllParsers(gatewayId);
+ }
+
+ public List<ParsingTemplate> getParsingTemplatesForApplication(String applicationInterfaceId) throws RegistryException {
+ return parsingTemplateRepository.getParsingTemplatesForApplication(applicationInterfaceId);
+ }
+
+ public List<ParsingTemplate> getParsingTemplatesForExperiment(String experimentId, String gatewayId) throws RegistryException {
+ ExperimentModel experiment = experimentRepository.getExperiment(experimentId);
+ List<ProcessModel> processes = experiment.getProcesses();
+ if (processes != null && processes.size() > 0) {
+ return parsingTemplateRepository.getParsingTemplatesForApplication(
+ processes.get(processes.size() - 1).getApplicationInterfaceId());
+ }
+ return Collections.emptyList();
+ }
+
+ public List<ParsingTemplate> listAllParsingTemplates(String gatewayId) throws RegistryException {
+ return parsingTemplateRepository.getAllParsingTemplates(gatewayId);
+ }
+
+ public List<UserComputeResourcePreference> getAllUserComputeResourcePreferences(String userId, String gatewayID) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("User Resource Profile does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("User Resource Profile does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ return userResourceProfileRepository.getUserResourceProfile(userId, gatewayID).getUserComputeResourcePreferences();
+ }
+
+ public List<UserStoragePreference> getAllUserStoragePreferences(String userId, String gatewayID) throws AppCatalogException {
+ try {
+ if (!userRepository.isUserExists(gatewayID, userId)) {
+ logger.error("User does not exist.Please provide a valid gateway id...");
+ throw new AppCatalogException("Gateway does not exist.Please provide a valid gateway id...");
+ }
+ } catch (RegistryException e) {
+ throw new AppCatalogException(e.getMessage(), e);
+ }
+ return userResourceProfileRepository.getUserResourceProfile(userId, gatewayID).getUserStoragePreferences();
+ }
+}
+