You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/08/09 21:24:42 UTC
[5/7] airavata git commit: moving registry code from API server to
registry server
http://git-wip-us.apache.org/repos/asf/airavata/blob/c01d7a14/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 47d9fb6..21e2cb8 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -67,38 +67,34 @@ import org.apache.airavata.model.group.ResourceType;
import org.apache.airavata.model.job.JobModel;
import org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent;
import org.apache.airavata.model.messaging.event.MessageType;
-import org.apache.airavata.model.process.ProcessModel;
import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
import org.apache.airavata.model.security.AuthzToken;
import org.apache.airavata.model.status.ExperimentState;
import org.apache.airavata.model.status.ExperimentStatus;
import org.apache.airavata.model.status.JobStatus;
-import org.apache.airavata.model.task.TaskModel;
import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Notification;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.orchestrator.client.OrchestratorClientFactory;
import org.apache.airavata.orchestrator.cpi.OrchestratorService;
import org.apache.airavata.orchestrator.cpi.OrchestratorService.Client;
-import org.apache.airavata.registry.core.app.catalog.resources.*;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogThriftConversion;
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.api.RegistryService;
+import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
+import org.apache.airavata.registry.api.exception.RegistryServiceException;
import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
import org.apache.airavata.registry.cpi.*;
-import org.apache.airavata.registry.cpi.utils.Constants;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class AiravataServerHandler implements Airavata.Iface {
private static final Logger logger = LoggerFactory.getLogger(AiravataServerHandler.class);
- private ExperimentCatalog experimentCatalog;
- private AppCatalog appCatalog;
private Publisher publisher;
- private ReplicaCatalog dataCatalog;
- private WorkflowCatalog workflowCatalog;
private CredentialStoreService.Client csClient;
public AiravataServerHandler() {
@@ -134,8 +130,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public boolean isUserExists(AuthzToken authzToken, String gatewayId, String userName) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- return ExpCatResourceUtils.isUserExist(userName, gatewayId);
- } catch (RegistryException e) {
+ return getRegistryServiceClient().isUserExists(userName, gatewayId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while verifying user", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -148,32 +144,14 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public String addGateway(AuthzToken authzToken, Gateway gateway) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
-
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- appCatalog = RegistryFactory.getAppCatalog();
- if (!validateString(gateway.getGatewayId())){
- logger.error("Gateway id cannot be empty...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
- String gatewayId = (String) experimentCatalog.add(ExpCatParentDataType.GATEWAY, gateway, gateway.getGatewayId());
- GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
- gatewayResourceProfile.setGatewayID(gatewayId);
- appCatalog.getGatewayProfile().addGatewayResourceProfile(gatewayResourceProfile);
- logger.debug("Airavata added gateway with gateway id : " + gateway.getGatewayId());
- return gatewayId;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().addGateway(gateway);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while adding gateway", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Error while adding gateway. More info : " + e.getMessage());
throw exception;
- } catch (AppCatalogException e) {
- logger.error("Error while adding gateway profile", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while adding gateway profile. More info : " + e.getMessage());
- throw exception;
}
}
@@ -189,8 +167,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<String> getAllUsersInGateway(AuthzToken authzToken, String gatewayId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- return ExpCatResourceUtils.getAllUsersInGateway(gatewayId);
- } catch (RegistryException e) {
+ return getRegistryServiceClient().getAllUsersInGateway(gatewayId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while retrieving users", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -205,17 +183,8 @@ public class AiravataServerHandler implements Airavata.Iface {
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, 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;
- }
- experimentCatalog.update(ExperimentCatalogModelType.GATEWAY, updatedGateway, gatewayId);
- logger.debug("Airavata update gateway with gateway id : " + gatewayId);
- return true;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().updateGateway(gatewayId, updatedGateway);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while updating the gateway", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -230,17 +199,8 @@ public class AiravataServerHandler implements Airavata.Iface {
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, 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 = (Gateway) experimentCatalog.get(ExperimentCatalogModelType.GATEWAY, gatewayId);
- logger.debug("Airavata retrieved gateway with gateway id : " + gateway.getGatewayId());
- return gateway;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().getGateway(gatewayId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while getting the gateway", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -254,17 +214,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public boolean deleteGateway(AuthzToken authzToken, String gatewayId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, 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;
- }
- experimentCatalog.remove(ExperimentCatalogModelType.GATEWAY, gatewayId);
- logger.debug("Airavata deleted gateway with gateway id : " + gatewayId);
- return true;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().deleteGateway(gatewayId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while deleting the gateway", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -278,15 +229,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<Gateway> getAllGateways(AuthzToken authzToken) throws InvalidRequestException, AiravataClientException,
AiravataSystemException, AuthorizationException, TException {
try {
- List<Gateway> gateways = new ArrayList<Gateway>();
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.GATEWAY, null, null);
- for (Object gateway : list){
- gateways.add((Gateway)gateway);
- }
- logger.debug("Airavata retrieved all available gateways...");
- return gateways;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().getAllGateways();
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while getting all the gateways", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -301,9 +245,8 @@ public class AiravataServerHandler implements Airavata.Iface {
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- return experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, gatewayId);
- } catch (RegistryException e) {
+ return getRegistryServiceClient().isGatewayExist(gatewayId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while getting gateway", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -324,9 +267,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public String createNotification(AuthzToken authzToken, Notification notification) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(notification.getGatewayId());
- return (String) experimentCatalog.add(ExpCatParentDataType.NOTIFICATION, notification, notification.getGatewayId());
- } catch (RegistryException e) {
+ return getRegistryServiceClient().createNotification(notification);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while creating notification", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -340,10 +282,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public boolean updateNotification(AuthzToken authzToken, Notification notification) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(notification.getGatewayId());
- experimentCatalog.update(ExperimentCatalogModelType.NOTIFICATION, notification, notification.getGatewayId());
- return true;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().updateNotification(notification);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while updating notification", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -357,10 +297,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public boolean deleteNotification(AuthzToken authzToken, String gatewayId, String notificationId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- experimentCatalog.remove(ExperimentCatalogModelType.NOTIFICATION, notificationId);
- return true;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().deleteNotification(gatewayId, notificationId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while deleting notification", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -374,9 +312,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public Notification getNotification(AuthzToken authzToken, String gatewayId, String notificationId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- return (Notification)experimentCatalog.get(ExperimentCatalogModelType.NOTIFICATION, notificationId);
- } catch (RegistryException e) {
+ return getRegistryServiceClient().getNotification(gatewayId, notificationId);
+ } catch (RegistryServiceException | ApplicationSettingsException e) {
logger.error("Error while retrieving notification", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -390,13 +327,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<Notification> getAllNotifications(AuthzToken authzToken, String gatewayId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- List<Object> objectList = experimentCatalog.get(ExperimentCatalogModelType.NOTIFICATION, null, gatewayId);
- List<Notification> notifications = new ArrayList<>();
- for(Object o : objectList)
- notifications.add((Notification) o);
- return notifications;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().getAllNotifications(gatewayId);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while getting all notifications", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -405,21 +337,6 @@ public class AiravataServerHandler implements Airavata.Iface {
}
}
- /*Following method wraps the logic of isGatewayExist method and this is to be called by any other method of the API as needed.*/
- private boolean isGatewayExistInternal(String gatewayId) throws InvalidRequestException, AiravataClientException,
- AiravataSystemException, AuthorizationException, TException{
- try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- return experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, gatewayId);
- } catch (RegistryException e) {
- logger.error("Error while getting gateway", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while getting gateway. More info : " + e.getMessage());
- throw exception;
- }
- }
-
@Override
@SecurityCheck
public String generateAndRegisterSSHKeys(AuthzToken authzToken, String gatewayId, String userName) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
@@ -585,20 +502,7 @@ public class AiravataServerHandler implements Airavata.Iface {
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- 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 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
+ String projectId = getRegistryServiceClient().createProject(gatewayId, project);
GroupManagerCPI groupManager = GroupManagerFactory.getGroupManager();
Resource projResource = new Resource(projectId, org.apache.airavata.grouper.resource.ResourceType.PROJECT);
projResource.setOwnerId(project.getOwner() + "@" + project.getGatewayId());
@@ -620,24 +524,9 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public void updateProject(AuthzToken authzToken, String projectId, Project updatedProject) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, ProjectNotFoundException, AuthorizationException, 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 {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.PROJECT, 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;
- }
-
- Project existingProject = (Project) experimentCatalog.get(ExperimentCatalogModelType.PROJECT, projectId);
+ RegistryService.Client regClient = getRegistryServiceClient();
+ Project existingProject = regClient.getProject(projectId);
if(!authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(existingProject.getOwner())
|| !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(existingProject.getGatewayId())){
try {
@@ -650,34 +539,24 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AuthorizationException("User does not have permission to access this resource");
}
}
-
- experimentCatalog.update(ExperimentCatalogModelType.PROJECT, updatedProject, projectId);
+ regClient.updateProject(projectId, updatedProject);
logger.debug("Airavata updated project with project Id : " + projectId );
- } catch (RegistryException e) {
+ } catch (RegistryServiceException | ApplicationSettingsException e) {
logger.error("Error while updating the project", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Error while updating the project. More info : " + e.getMessage());
throw exception;
}
-
}
@Override
@SecurityCheck
public boolean deleteProject(AuthzToken authzToken, String projectId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, ProjectNotFoundException, AuthorizationException, TException {
-
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.PROJECT, 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;
- }
-
- Project existingProject = (Project) experimentCatalog.get(ExperimentCatalogModelType.PROJECT, projectId);
+ RegistryService.Client regClient = getRegistryServiceClient();
+ Project existingProject = regClient.getProject(projectId);
if(!authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(existingProject.getOwner())
|| !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(existingProject.getGatewayId())){
try {
@@ -690,11 +569,10 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AuthorizationException("User does not have permission to access this resource");
}
}
-
- experimentCatalog.remove(ExperimentCatalogModelType.PROJECT, projectId);
+ boolean ret = regClient.deleteProject(projectId);
logger.debug("Airavata deleted project with project Id : " + projectId );
- return true;
- } catch (RegistryException e) {
+ return ret;
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while removing the project", e);
ProjectNotFoundException exception = new ProjectNotFoundException();
exception.setMessage("Error while removing the project. More info : " + e.getMessage());
@@ -720,16 +598,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public Project getProject(AuthzToken authzToken, String projectId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, ProjectNotFoundException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.PROJECT, 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 = (Project) experimentCatalog.get(ExperimentCatalogModelType.PROJECT, projectId);
+ Project project = getRegistryServiceClient().getProject(projectId);
if(authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(project.getOwner())
&& authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(project.getGatewayId())){
return project;
@@ -746,7 +615,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AuthorizationException("User does not have permission to access this resource");
}
}
- } catch (RegistryException e) {
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while retrieving the project", e);
ProjectNotFoundException exception = new ProjectNotFoundException();
exception.setMessage("Error while retrieving the project. More info : " + e.getMessage());
@@ -773,40 +642,9 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<Project> getUserProjects(AuthzToken authzToken, String gatewayId, String userName,
int limit, int offset)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, 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<Project> projects = new ArrayList<Project>();
try {
- if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){
- logger.error("User does not exist in the system. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("User does not exist in the system. Please provide a valid user..");
- throw exception;
- }
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- Map<String, String> filters = new HashMap<String, String>();
- filters.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
- filters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
- List<Object> list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters, limit, offset,
- Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
- if (list != null && !list.isEmpty()){
- for (Object o : list){
- projects.add((Project) o);
- }
- }
- logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId );
- return projects;
- } catch (RegistryException e) {
+ return getRegistryServiceClient().getUserProjects(gatewayId, userName, limit, offset);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while retrieving projects", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -840,50 +678,11 @@ public class AiravataServerHandler implements Airavata.Iface {
@Override
public List<Project> searchProjects(AuthzToken authzToken, String gatewayId, String userName, Map<ProjectSearchFields,
String> filters, int limit, int offset) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, 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 (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){
- logger.error("User does not exist in the system. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("User does not exist in the system. Please provide a valid user..");
- throw exception;
- }
- List<Project> projects = new ArrayList<Project>();
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- Map<String, String> regFilters = new HashMap<String, String>();
- 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());
- }
- }
List<String> accessibleProjIds = new ArrayList<>();
accessibleProjIds.addAll(getAllAccessibleResourcesForUser(userName+"@"+gatewayId, ResourceType.PROJECT, ResourcePermissionType.READ));
- if(accessibleProjIds.size() == 0)
- return new ArrayList<>();
-
- List<Object> results = experimentCatalog.searchAllAccessible(ExperimentCatalogModelType.PROJECT, accessibleProjIds,
- regFilters, limit, offset, Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
- for (Object object : results) {
- projects.add((Project)object);
- }
- logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId);
- return projects;
+ return getRegistryServiceClient().searchProjects(gatewayId, userName, accessibleProjIds, filters, limit, offset);
}catch (Exception e) {
logger.error("Error while retrieving projects", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -914,61 +713,10 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<ExperimentSummaryModel> searchExperiments(AuthzToken authzToken, String gatewayId, String userName, Map<ExperimentSearchFields,
String> filters, int limit, int offset)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, 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 (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){
- logger.error("User does not exist in the system. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("User does not exist in the system. Please provide a valid user..");
- throw exception;
- }
- List<ExperimentSummaryModel> summaries = new ArrayList<ExperimentSummaryModel>();
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- 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());
- }
- }
List<String> accessibleExpIds = new ArrayList<>();
accessibleExpIds.addAll(getAllAccessibleResourcesForUser(userName + "@" + gatewayId, ResourceType.EXPERIMENT, ResourcePermissionType.READ));
-
- if(accessibleExpIds.size() == 0)
- return new ArrayList<>();
-
- List<Object> results = experimentCatalog.searchAllAccessible(ExperimentCatalogModelType.EXPERIMENT,
- accessibleExpIds, regFilters, limit,
- offset, Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
- for (Object object : results) {
- summaries.add((ExperimentSummaryModel) object);
- }
- logger.debug("Airavata retrieved experiments for user : " + userName + " and gateway id : " + gatewayId );
- return summaries;
+ return getRegistryServiceClient().searchExperiments(gatewayId, userName, accessibleExpIds, filters, limit, offset);
}catch (Exception e) {
logger.error("Error while retrieving experiments", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -995,19 +743,8 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public ExperimentStatistics getExperimentStatistics(AuthzToken authzToken, String gatewayId, long fromTime, long toTime)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- if (!isGatewayExistInternal(gatewayId)){
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
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+"");
-
- List<Object> results = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT_STATISTICS, filters);
- logger.debug("Airavata retrieved experiments for gateway id : " + gatewayId + " between : " + AiravataUtils.getTime(fromTime) + " and " + AiravataUtils.getTime(toTime));
- return (ExperimentStatistics) results.get(0);
+ return getRegistryServiceClient().getExperimentStatistics(gatewayId, fromTime, toTime);
}catch (Exception e) {
logger.error("Error while retrieving experiments", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1033,23 +770,10 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<ExperimentModel> getExperimentsInProject(AuthzToken authzToken, String projectId, int limit, int offset)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, ProjectNotFoundException,
AuthorizationException, TException {
- if (!validateString(projectId)){
- logger.error("Project id cannot be empty. Please provide a valid project ID...");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Project id cannot be empty. Please provide a valid project ID...");
- throw exception;
- }
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.PROJECT, 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;
- }
+ RegistryService.Client regClient = getRegistryServiceClient();
+ Project project = regClient.getProject(projectId);
- Project project = (Project) experimentCatalog.get(ExperimentCatalogModelType.PROJECT, projectId);
if(!authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(project.getOwner())
|| !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(project.getGatewayId())){
try {
@@ -1062,18 +786,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AuthorizationException("User does not have permission to access this resource");
}
}
-
- List<ExperimentModel> experiments = new ArrayList<ExperimentModel>();
- List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT,
- Constants.FieldConstants.ExperimentConstants.PROJECT_ID, projectId, limit, offset,
- Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
- if (list != null && !list.isEmpty()) {
- for (Object o : list) {
- experiments.add((ExperimentModel) o);
- }
- }
- logger.debug("Airavata retrieved experiments for project : " + projectId);
- return experiments;
+ return regClient.getExperimentsInProject(projectId, limit, offset);
} catch (Exception e) {
logger.error("Error while retrieving the experiments", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1101,37 +814,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<ExperimentModel> getUserExperiments(AuthzToken authzToken, String gatewayId, String userName, int limit,
int offset) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, 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 (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){
- logger.error("User does not exist in the system. Please provide a valid user..");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("User does not exist in the system. Please provide a valid user..");
- throw exception;
- }
- List<ExperimentModel> experiments = new ArrayList<ExperimentModel>();
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT,
- Constants.FieldConstants.ExperimentConstants.USER_NAME, userName, limit, offset,
- Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
- if (list != null && !list.isEmpty()){
- for (Object o : list){
- experiments.add((ExperimentModel)o);
- }
- }
- logger.debug("Airavata retrieved experiments for user : " + userName);
- return experiments;
+ return getRegistryServiceClient().getUserExperiments(gatewayId, userName, limit, offset);
} catch (Exception e) {
logger.error("Error while retrieving the experiments", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1168,37 +852,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public String createExperiment(AuthzToken authzToken, String gatewayId, ExperimentModel experiment) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
- appCatalog = RegistryFactory.getAppCatalog();
- if (!validateString(experiment.getExperimentName())){
- logger.error("Cannot create experiments with empty experiment name");
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Cannot create experiments with empty experiment name");
- throw exception;
- }
- 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){
-
- String compResourceId = experiment.getUserConfigurationData()
- .getComputationalResourceScheduling().getResourceHostId();
- ComputeResourceDescription computeResourceDescription = appCatalog.getComputeResource()
- .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;
- }
- }
-
- String experimentId = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, experiment, gatewayId);
+ String experimentId = getRegistryServiceClient().createExperiment(gatewayId, experiment);
GroupManagerCPI groupManager = GroupManagerFactory.getGroupManager();
Resource expResource = new Resource(experimentId, org.apache.airavata.grouper.resource.ResourceType.EXPERIMENT);
expResource.setOwnerId(experiment.getUserName()+"@"+experiment.getGatewayId());
@@ -1241,11 +895,8 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public boolean deleteExperiment(AuthzToken authzToken, String experimentId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, experimentId)){
- throw new ExperimentNotFoundException("Requested experiment id " + experimentId + " does not exist in the system..");
- }
- ExperimentModel experimentModel = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, experimentId);
+ RegistryService.Client regClient = getRegistryServiceClient();
+ ExperimentModel experimentModel = regClient.getExperiment(experimentId);
if(!authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(experimentModel.getUserName())
|| !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(experimentModel.getGatewayId())){
@@ -1264,9 +915,7 @@ public class AiravataServerHandler implements Airavata.Iface {
logger.error("Error while deleting the experiment");
throw new ExperimentCatalogException("Experiment is not in CREATED state. Hence cannot deleted. ID:"+ experimentId);
}
- experimentCatalog.remove(ExperimentCatalogModelType.EXPERIMENT, experimentId);
- logger.debug("Airavata removed experiment with experiment id : " + experimentId);
- return true;
+ return regClient.deleteExperiment(experimentId);
} catch (Exception e) {
logger.error("Error while deleting the experiment", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1302,7 +951,16 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public ExperimentModel getExperiment(AuthzToken authzToken, String airavataExperimentId) throws InvalidRequestException,
ExperimentNotFoundException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- ExperimentModel experimentModel = getExperimentInternal(airavataExperimentId);
+ ExperimentModel experimentModel = null;
+ try {
+ experimentModel = getRegistryServiceClient().getExperiment(airavataExperimentId);
+ } catch (ApplicationSettingsException e) {
+ logger.error("Error while getting the experiment", e);
+ AiravataSystemException exception = new AiravataSystemException();
+ exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+ exception.setMessage("Error while getting the experiment. More info : " + e.getMessage());
+ throw exception;
+ }
if(authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(experimentModel.getUserName())
&& authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(experimentModel.getGatewayId())){
return experimentModel;
@@ -1349,39 +1007,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public ExperimentModel getDetailedExperimentTree(AuthzToken authzToken, String airavataExperimentId) throws InvalidRequestException,
ExperimentNotFoundException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- ExperimentModel experimentModel = getExperimentInternal(airavataExperimentId);
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- List<Object> processObjects = experimentCatalog.get(ExperimentCatalogModelType.PROCESS,
- Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentModel.getExperimentId());
- List<ProcessModel> processList = new ArrayList<>();
- if(processObjects != null){
- processObjects.stream().forEach(p -> {
- //Process already has the task object
- ((ProcessModel)p).getTasks().stream().forEach(t->{
- try {
- List<Object> jobObjects = experimentCatalog.get(ExperimentCatalogModelType.JOB,
- Constants.FieldConstants.JobConstants.TASK_ID, ((TaskModel)t).getTaskId());
- List<JobModel> jobList = new ArrayList<JobModel>();
- if(jobObjects != null){
- jobObjects.stream().forEach(j -> jobList.add((JobModel)j));
- 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);
- }
- });
- processList.add((ProcessModel)p);
- });
- experimentModel.setProcesses(processList);
- }
- logger.debug("Airavata retrieved detailed experiment with experiment id : " + airavataExperimentId);
- return experimentModel;
+ return getRegistryServiceClient().getDetailedExperimentTree(airavataExperimentId);
} catch (Exception e) {
logger.error("Error while retrieving the experiment", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1391,24 +1017,6 @@ public class AiravataServerHandler implements Airavata.Iface {
}
}
- /*This private method wraps the logic of getExperiment method as this method is called internally in the API.*/
- private ExperimentModel getExperimentInternal(String airavataExperimentId) throws InvalidRequestException,
- ExperimentNotFoundException, AiravataClientException, AiravataSystemException, TException {
- try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)){
- throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
- return (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId);
- } catch (RegistryException e) {
- logger.error("Error while retrieving the experiment", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving the experiment. More info : " + e.getMessage());
- throw exception;
- }
- }
-
/**
* Configure a previously created experiment with required inputs, scheduling and other quality of service
* parameters. This method only updates the experiment object within the registry. The experiment has to be launched
@@ -1439,13 +1047,8 @@ public class AiravataServerHandler implements Airavata.Iface {
throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException,
AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
- logger.error(airavataExperimentId, "Update request failed, Experiment {} doesn't exist.", airavataExperimentId);
- throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
- }
-
- ExperimentModel experimentModel = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId);
+ RegistryService.Client regClient = getRegistryServiceClient();
+ ExperimentModel experimentModel = regClient.getExperiment(airavataExperimentId);
if(!authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME).equals(experimentModel.getUserName())
|| !authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.GATEWAY_ID).equals(experimentModel.getGatewayId())){
try {
@@ -1459,47 +1062,8 @@ public class AiravataServerHandler implements Airavata.Iface {
}
}
- ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
- if (experimentStatus != null){
- ExperimentState experimentState = experimentStatus.getState();
- switch (experimentState){
- case CREATED: case VALIDATED:
- if(experiment.getUserConfigurationData() != null && experiment.getUserConfigurationData()
- .getComputationalResourceScheduling() != null){
- String compResourceId = experiment.getUserConfigurationData()
- .getComputationalResourceScheduling().getResourceHostId();
- ComputeResourceDescription computeResourceDescription = appCatalog.getComputeResource()
- .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;
- }
- }
- experimentCatalog.update(ExperimentCatalogModelType.EXPERIMENT, 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;
- }
- }
- } catch (RegistryException e) {
- logger.error(airavataExperimentId, "Error while updating experiment", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while updating experiment. More info : " + e.getMessage());
- throw exception;
- } catch (AppCatalogException e) {
+ regClient.updateExperiment(airavataExperimentId, experiment);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error(airavataExperimentId, "Error while updating experiment", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -1513,31 +1077,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public void updateExperimentConfiguration(AuthzToken authzToken, String airavataExperimentId, UserConfigurationDataModel userConfiguration)
throws AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, 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:
- experimentCatalog.add(ExpCatChildDataType.USER_CONFIGURATION_DATA, 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;
- }
- }
+ getRegistryServiceClient().send_updateExperimentConfiguration(airavataExperimentId, userConfiguration);
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while updating user configuration", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1555,31 +1095,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public void updateResourceScheduleing(AuthzToken authzToken, String airavataExperimentId,
ComputationalResourceSchedulingModel resourceScheduling) throws AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, 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:
- experimentCatalog.add(ExpCatChildDataType.PROCESS_RESOURCE_SCHEDULE, 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;
- }
- }
+ getRegistryServiceClient().updateResourceScheduleing(airavataExperimentId, resourceScheduling);
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while updating scheduling info", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1608,12 +1124,12 @@ public class AiravataServerHandler implements Airavata.Iface {
public boolean validateExperiment(AuthzToken authzToken, String airavataExperimentId) throws InvalidRequestException,
ExperimentNotFoundException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
+ ExperimentModel experimentModel = getRegistryServiceClient().getExperiment(airavataExperimentId);
+ if (experimentModel == null) {
logger.error(airavataExperimentId, "Experiment validation failed , experiment {} doesn't exist.", airavataExperimentId);
throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
- } catch (RegistryException e1) {
+ } catch (RegistryServiceException | ApplicationSettingsException e1) {
logger.error(airavataExperimentId, "Error while retrieving projects", e1);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -1665,43 +1181,22 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public ExperimentStatus getExperimentStatus(AuthzToken authzToken, String airavataExperimentId) throws InvalidRequestException,
ExperimentNotFoundException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- ExperimentStatus experimentStatus = getExperimentStatusInternal(airavataExperimentId);
- logger.debug("Airavata retrieved experiment status for experiment id : " + airavataExperimentId);
- return experimentStatus;
- }
-
- /*Private method wraps the logic of getExperimentStatus method since this method is called internally.*/
- private ExperimentStatus getExperimentStatusInternal(String airavataExperimentId) throws InvalidRequestException,
- ExperimentNotFoundException, AiravataClientException, AiravataSystemException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, 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 (ExperimentStatus) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT_STATUS, airavataExperimentId);
- } catch (Exception e) {
- logger.error(airavataExperimentId, "Error while retrieving the experiment status", e);
+ return getRegistryServiceClient().getExperimentStatus(airavataExperimentId);
+ } catch (ApplicationSettingsException e) {
AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while retrieving the experiment status. More info : " + e.getMessage());
+ exception.setMessage(e.getMessage());
throw exception;
}
}
+
@Override
@SecurityCheck
public List<OutputDataObjectType> getExperimentOutputs(AuthzToken authzToken, String airavataExperimentId)
throws AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, 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 (List<OutputDataObjectType>) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT_OUTPUT, airavataExperimentId);
+ return getRegistryServiceClient().getExperimentOutputs(airavataExperimentId);
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while retrieving the experiment outputs", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1722,37 +1217,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public Map<String, JobStatus> getJobStatuses(AuthzToken authzToken, String airavataExperimentId)
throws AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, 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<Object> processModels = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
- Map<String, JobStatus> jobStatus = new HashMap<String, JobStatus>();
- if (processModels != null && !processModels.isEmpty()){
- for (Object process : processModels) {
- ProcessModel processModel = (ProcessModel) process;
- List<TaskModel> tasks = processModel.getTasks();
- if (tasks != null && !tasks.isEmpty()){
- for (TaskModel task : tasks){
- String taskId = task.getTaskId();
- List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, taskId);
- if (jobs != null && !jobs.isEmpty()){
- for (Object jobObject : jobs) {
- JobModel jobModel = (JobModel) jobObject;
- String jobID = jobModel.getJobId();
- JobStatus status = jobModel.getJobStatus();
- if (status != null){
- jobStatus.put(jobID, status);
- }
- }
- }
- }
- }
- }
- }
- logger.debug("Airavata retrieved job statuses for experiment with experiment id : " + airavataExperimentId);
- return jobStatus;
+ return getRegistryServiceClient().getJobStatuses(airavataExperimentId);
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while retrieving the job statuses", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1767,30 +1232,7 @@ public class AiravataServerHandler implements Airavata.Iface {
public List<JobModel> getJobDetails(AuthzToken authzToken, String airavataExperimentId) throws InvalidRequestException,
ExperimentNotFoundException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, 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<Object> processModels = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
- List<JobModel> jobList = new ArrayList<>();
- if (processModels != null && !processModels.isEmpty()){
- for (Object process : processModels) {
- ProcessModel processModel = (ProcessModel) process;
- List<TaskModel> tasks = processModel.getTasks();
- if (tasks != null && !tasks.isEmpty()){
- for (TaskModel taskModel : tasks){
- String taskId = taskModel.getTaskId();
- List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, taskId);
- for (Object jobObject : jobs) {
- jobList.add ((JobModel)jobObject);
- }
- }
- }
- }
- }
- logger.debug("Airavata retrieved job models for experiment with experiment id : " + airavataExperimentId);
- return jobList;
+ return getRegistryServiceClient().getJobDetails(airavataExperimentId);
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while retrieving the job details", e);
AiravataSystemException exception = new AiravataSystemException();
@@ -1833,45 +1275,35 @@ public class AiravataServerHandler implements Airavata.Iface {
public void launchExperiment(AuthzToken authzToken, final String airavataExperimentId, String gatewayId)
throws AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- appCatalog = RegistryFactory.getAppCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
+ ExperimentModel experiment = getRegistryServiceClient().getExperiment(airavataExperimentId);
+ if (experiment == null) {
logger.error(airavataExperimentId, "Error while launching experiment, experiment {} doesn't exist.", airavataExperimentId);
throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, gatewayId)) {
- logger.error(airavataExperimentId, "Error while launching experiment, gatewayId {} doesn't exist.", gatewayId);
- throw new ExperimentNotFoundException("Requested gateway id " + gatewayId + " does not exist in the system..");
- }
- ExperimentModel experiment = getExperimentInternal(airavataExperimentId);
- String applicationID = experiment.getExecutionId();
- if (!appCatalog.getApplicationInterface().isApplicationInterfaceExists(applicationID)){
- logger.error(airavataExperimentId, "Error while launching experiment, application id {} for experiment {} doesn't exist.", applicationID, airavataExperimentId);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while launching experiment, application id : " + applicationID + " for experiment : " + airavataExperimentId +
- " doesn't exist..");
- throw exception;
- }
+// FIXME
+// String applicationID = experiment.getExecutionId();
+// if (!appCatalog.getApplicationInterface().isApplicationInterfaceExists(applicationID)){
+// logger.error(airavataExperimentId, "Error while launching experiment, application id {} for experiment {} doesn't exist.", applicationID, airavataExperimentId);
+// AiravataSystemException exception = new AiravataSystemException();
+// exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+// exception.setMessage("Error while launching experiment, application id : " + applicationID + " for experiment : " + airavataExperimentId +
+// " doesn't exist..");
+// throw exception;
+// }
OrchestratorService.Client orchestratorClient = getOrchestratorClient();
if (orchestratorClient.validateExperiment(airavataExperimentId)) {
orchestratorClient.launchExperiment(airavataExperimentId, gatewayId);
logger.debug("Airavata launched experiment with experiment id : " + airavataExperimentId);
}else {
logger.error(airavataExperimentId, "Couldn't identify experiment type, experiment {} is neither single application nor workflow.", airavataExperimentId);
- throw new InvalidRequestException("Experiment '" + airavataExperimentId + "' launch failed. Unable to figureout execution type for application " + applicationID);
+ throw new InvalidRequestException("Experiment '" + airavataExperimentId + "' launch failed. Unable to figureout execution type for application " + experiment.getExecutionId());
}
- } catch (RegistryException e1) {
+ } catch (RegistryServiceException | ApplicationSettingsException e1) {
logger.error(airavataExperimentId, "Error while instantiate the registry instance", e1);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Error while instantiate the registry instance. More info : " + e1.getMessage());
throw exception;
- } catch (AppCatalogException e) {
- logger.error(airavataExperimentId, "Error while instantiate the registry instance", e);
- AiravataSystemException exception = new AiravataSystemException();
- exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
- exception.setMessage("Error while instantiate the registry instance. More info : " + e.getMessage());
}
}
@@ -1933,16 +1365,17 @@ public class AiravataServerHandler implements Airavata.Iface {
throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException,
AuthorizationException, TException {
try {
- experimentCatalog = RegistryFactory.getDefaultExpCatalog();
- if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, existingExperimentID)){
+ RegistryService.Client regClient = getRegistryServiceClient();
+ ExperimentModel existingExperiment = regClient.getExperiment(existingExperimentID);
+ if (existingExperiment == null){
logger.error(existingExperimentID, "Error while cloning experiment {}, experiment doesn't exist.", existingExperimentID);
throw new ExperimentNotFoundException("Requested experiment id " + existingExperimentID + " does not exist in the system..");
}
- ExperimentModel existingExperiment = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, existingExperimentID);
- String gatewayId = (String) experimentCatalog.getValue(ExperimentCatalogModelType.EXPERIMENT, existingExperimentID, Constants.FieldConstants.ExperimentConstants.GATEWAY_ID);
+
+ String gatewayId = existingExperiment.getGatewayId();
existingExperiment.setCreationTime(AiravataUtils.getCurrentTimestamp().getTime());
if (existingExperiment.getExecutionId() != null){
- List<OutputDataObjectType> applicationOutputs = getApplicationOutputsInternal(existingExperiment.getExecutionId());
+ List<OutputDataObjectType> applicationOutputs = regClient.getApplicationOutputs(existingExperiment.getExecutionId());
existingExperiment.setExperimentOutputs(applicationOutputs);
}
if (validateString(newExperiementName)){
@@ -1956,15 +1389,14 @@ public class AiravataServerHandler implements Airavata.Iface {
String compResourceId = existingExperiment.getUserConfigurationData()
.getComputationalResourceScheduling().getResourceHostId();
- ComputeResourceDescription computeResourceDescription = appCatalog.getComputeResource()
- .getComputeResource(compResourceId);
+ ComputeResourceDescription computeResourceDescription = regClient.getComputeResource(compResourceId);
if(!computeResourceDescription.isEnabled()){
existingExperiment.getUserConfigurationData().setComputationalResourceScheduling(null);
}
}
logger.debug("Airavata cloned experiment with experiment id : " + existingExperimentID);
existingExperiment.setUserName(authzToken.getClaimsMap().get(org.apache.airavata.common.utils.Constants.USER_NAME));
- String expId = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, existingExperiment, gatewayId);
+ String expId = regClient.createExperiment(gatewayId, existingExperiment);
String projectId = existingExperiment.getProjectId();
if(!isResourceExistsInGrouper(projectId, ResourceType.PROJECT)){
@@ -2007,14 +1439,17 @@ public class AiravataServerHandler implements Airavata.Iface {
public void terminateExperiment(AuthzToken authzToken, String airavataExperimentId, String gatewayId) throws InvalidRequestException,
ExperimentNotFoundException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- if (!(experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId))){
- logger.error("Experiment does not exist.Please provide a valid experiment id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+ RegistryService.Client regClient = getRegistryServiceClient();
+ ExperimentModel existingExperiment = regClient.getExperiment(airavataExperimentId);
+ if (existingExperiment == null){
+ logger.error(airavataExperimentId, "Error while cloning experiment {}, experiment doesn't exist.", airavataExperimentId);
+ throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
+
Client client = getOrchestratorClient();
client.terminateExperiment(airavataExperimentId, gatewayId);
logger.debug("Airavata cancelled experiment with experiment id : " + airavataExperimentId);
- } catch (RegistryException e) {
+ } catch (RegistryServiceException | ApplicationSettingsException e) {
logger.error(airavataExperimentId, "Error while cancelling the experiment...", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -2034,16 +1469,9 @@ public class AiravataServerHandler implements Airavata.Iface {
@SecurityCheck
public String registerApplicationModule(AuthzToken authzToken, String gatewayId, ApplicationModule applicationModule)
throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
- if (!isGatewayExistInternal(gatewayId)){
- logger.error("Gateway does not exist.Please provide a valid gateway id...");
- throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
- }
try {
- appCatalog = RegistryFactory.getAppCatalog();
- String module = appCatalog.getApplicationInterface().addApplicationModule(applicationModule, gatewayId);
- logger.debug("Airavata registered application module for gateway id : " + gatewayId);
- return module;
- } catch (AppCatalogException e) {
+ return getRegistryServiceClient().registerApplicationModule(gatewayId,applicationModule);
+ } catch (ApplicationSettingsException | RegistryServiceException e) {
logger.error("Error while adding application module...", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -2064,11 +1492,8 @@ public class AiravataServerHandler implements Airavata.Iface {
public ApplicationModule getApplicationModule(AuthzToken authzToken, String appModuleId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, AuthorizationException, TException {
try {
- appCatalog = RegistryFactory.getAppCatalog();
- ApplicationModule module = appCatalog.getApplicationInterface().getApplicationModule(appModuleId);
- logger.debug("Airavata retrieved application module with module id : " + appModuleId);
- return module;
- } catch (AppCatalogException e) {
+
<TRUNCATED>