use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class AiravataServerHandler method deleteProject.
@Override
@SecurityCheck
public boolean deleteProject(AuthzToken authzToken, String projectId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, ProjectNotFoundException, AuthorizationException, TException {
RegistryService.Client regClient = registryClientPool.getResource();
SharingRegistryService.Client sharingClient = sharingClientPool.getResource();
try {
Project existingProject = regClient.getProject(projectId);
if (ServerSettings.isEnableSharing() && !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 {
String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
String userId = authzToken.getClaimsMap().get(Constants.USER_NAME);
if (!sharingClient.userHasAccess(gatewayId, userId + "@" + gatewayId, projectId, gatewayId + ":WRITE")) {
throw new AuthorizationException("User does not have permission to access this resource");
}
} catch (Exception e) {
throw new AuthorizationException("User does not have permission to access this resource");
}
}
boolean ret = regClient.deleteProject(projectId);
logger.debug("Airavata deleted project with project Id : " + projectId);
registryClientPool.returnResource(regClient);
sharingClientPool.returnResource(sharingClient);
return ret;
} catch (Exception e) {
logger.error("Error while removing the project", e);
ProjectNotFoundException exception = new ProjectNotFoundException();
exception.setMessage("Error while removing the project. More info : " + e.getMessage());
registryClientPool.returnBrokenResource(regClient);
sharingClientPool.returnBrokenResource(sharingClient);
throw exception;
}
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class AiravataServerHandler method getProject.
/**
* Get a Project by ID
*
* @param projectId
*/
@Override
@SecurityCheck
public Project getProject(AuthzToken authzToken, String projectId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, ProjectNotFoundException, AuthorizationException, TException {
RegistryService.Client regClient = registryClientPool.getResource();
SharingRegistryService.Client sharingClient = sharingClientPool.getResource();
try {
Project project = regClient.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())) {
registryClientPool.returnResource(regClient);
sharingClientPool.returnResource(sharingClient);
return project;
} else if (ServerSettings.isEnableSharing()) {
try {
String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
String userId = authzToken.getClaimsMap().get(Constants.USER_NAME);
if (!sharingClient.userHasAccess(gatewayId, userId + "@" + gatewayId, projectId, gatewayId + ":READ")) {
throw new AuthorizationException("User does not have permission to access this resource");
}
registryClientPool.returnResource(regClient);
sharingClientPool.returnResource(sharingClient);
return project;
} catch (Exception e) {
throw new AuthorizationException("User does not have permission to access this resource");
}
} else {
registryClientPool.returnResource(regClient);
sharingClientPool.returnResource(sharingClient);
return null;
}
} catch (Exception e) {
logger.error("Error while retrieving the project", e);
ProjectNotFoundException exception = new ProjectNotFoundException();
exception.setMessage("Error while retrieving the project. More info : " + e.getMessage());
registryClientPool.returnBrokenResource(regClient);
sharingClientPool.returnBrokenResource(sharingClient);
throw exception;
}
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class ExperimentExecution method createLocalEchoExperiment.
public String createLocalEchoExperiment(String gatewayId, String applicationInterfaceId, String storageId, String computeResourceId) throws Exception {
String experimentId = null;
try {
List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, applicationInterfaceId);
List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, applicationInterfaceId);
for (InputDataObjectType inputDataObjectType : applicationInputs) {
if (inputDataObjectType.getName().equalsIgnoreCase(INPUT_NAME)) {
inputDataObjectType.setValue(LOCAL_ECHO_EXPERIMENT_INPUT);
}
}
List<Project> projectsPerGateway = projectsMap.get(gatewayId);
String projectID = null;
if (projectsPerGateway != null && !projectsPerGateway.isEmpty()) {
projectID = projectsPerGateway.get(0).getProjectID();
}
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(gatewayId, projectID, properties.getTestUserName(), "Local Echo Experiment", "Local Echo Experiment run", applicationInterfaceId, applicationInputs);
simpleExperiment.setExperimentOutputs(appOutputs);
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResourceId, 4, 1, 1, "cpu", 20, 0);
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
userConfigurationData.setStorageId(storageId);
userConfigurationData.setExperimentDataDir(TestFrameworkConstants.STORAGE_LOCATION);
simpleExperiment.setUserConfigurationData(userConfigurationData);
experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
experimentsWithGateway.put(experimentId, gatewayId);
} catch (Exception e) {
logger.error("Error while creating Echo experiment", e);
throw new Exception("Error while creating Echo experiment", e);
}
return experimentId;
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class GatewayRegister method createProject.
public void createProject(String gatewayId) throws Exception {
Project project = new Project();
project.setGatewayId(gatewayId);
project.setName(testProject);
project.setOwner(testUser);
String projectId = airavata.createProject(authzToken, gatewayId, project);
projectMap.put(projectId, gatewayId);
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class RegistryServerHandler method getProject.
/**
* Get a Project by ID
* This method is to obtain a project by providing a projectId.
*
* @param projectId projectId of the project you require.
* @return project
* project data model will be returned.
*/
@Override
public Project getProject(String projectId) throws RegistryServiceException, 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);
return project;
} catch (RegistryException e) {
logger.error("Error while retrieving the project", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving the project. More info : " + e.getMessage());
throw exception;
}
}
Aggregations