use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getAllAppModules.
/**
* Fetch all Application Module Descriptions.
*
* @param gatewayId ID of the gateway which need to list all available application deployment documentation.
* @return list
* Returns the list of all Application Module Objects.
*/
@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 {
appCatalog = RegistryFactory.getAppCatalog();
List<ApplicationModule> moduleList = appCatalog.getApplicationInterface().getAllApplicationModules(gatewayId);
logger.debug("Airavata retrieved modules for gateway id : " + gatewayId);
return moduleList;
} 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;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getAppModuleDeployedResources.
/**
* Fetch a list of Deployed Compute Hosts.
*
* @param appModuleId The identifier for the requested application module
* @return list<string>
* Returns a list of Deployed Resources.
*/
@Override
public List<String> getAppModuleDeployedResources(String appModuleId) throws RegistryServiceException, TException {
try {
List<String> appDeployments = new ArrayList<String>();
appCatalog = RegistryFactory.getAppCatalog();
Map<String, String> filters = new HashMap<String, String>();
filters.put(AppCatAbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID, appModuleId);
List<ApplicationDeploymentDescription> applicationDeployments = appCatalog.getApplicationDeployment().getApplicationDeployements(filters);
for (ApplicationDeploymentDescription description : applicationDeployments) {
appDeployments.add(description.getAppDeploymentId());
}
logger.debug("Airavata retrieved application deployments for module id : " + appModuleId);
return appDeployments;
} 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;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method addUser.
@Override
public String addUser(UserProfile userProfile) throws RegistryServiceException, DuplicateEntryException, TException {
try {
// FIXME: figure out a way to get password
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());
}
ExpCatResourceUtils.addUser(userProfile.getUserId(), null, userProfile.getGatewayId());
return userProfile.getUserId();
} 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;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method createProject.
/**
* Creates a Project with basic metadata.
* A Project is a container of experiments.
*
* @param gatewayId The identifier for the requested gateway.
* @param project
*/
@Override
public String createProject(String gatewayId, Project project) throws RegistryServiceException, 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);
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;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method createExperiment.
/**
* *
* * Create New Experiment
* * Create an experiment for the specified user belonging to the gateway. The gateway identity is not explicitly passed
* * but inferred from the sshKeyAuthentication header. This experiment is just a persistent place holder. The client
* * has to subsequently configure and launch the created experiment. No action is taken on Airavata Server except
* * registering the experiment in a persistent store.
* *
* * @param gatewayId
* * The unique ID of the gateway where the experiment is been created.
* *
* * @param ExperimentModel
* * The create experiment will require the basic experiment metadata like the name and description, intended user,
* * the gateway identifer and if the experiment should be shared public by defualt. During the creation of an experiment
* * the ExperimentMetadata is a required field.
* *
* * @return
* * The server-side generated.airavata.registry.core.experiment.globally unique identifier.
* *
* * @throws org.apache.airavata.model.error.InvalidRequestException
* * For any incorrect forming of the request itself.
* *
* * @throws org.apache.airavata.model.error.AiravataClientException
* * The following list of exceptions are thrown which Airavata Client can take corrective actions to resolve:
* *
* * UNKNOWN_GATEWAY_ID - If a Gateway is not registered with Airavata as a one time administrative
* * step, then Airavata Registry will not have a provenance area setup. The client has to follow
* * gateway registration steps and retry this request.
* *
* * AUTHENTICATION_FAILURE - How Authentication will be implemented is yet to be determined.
* * For now this is a place holder.
* *
* * INVALID_AUTHORIZATION - This will throw an authorization exception. When a more robust security hand-shake
* * is implemented, the authorization will be more substantial.
* *
* * @throws org.apache.airavata.model.error.AiravataSystemException
* * This exception will be thrown for any Airavata Server side issues and if the problem cannot be corrected by the client
* * rather an Airavata Administrator will be notified to take corrective action.
* *
* *
*
* @param gatewayId
* @param experiment
*/
@Override
public String createExperiment(String gatewayId, ExperimentModel experiment) throws RegistryServiceException, TException {
try {
experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
appCatalog = RegistryFactory.getAppCatalog();
if (!validateString(experiment.getExperimentName())) {
logger.error("Cannot create experiments with empty experiment name");
AiravataSystemException exception = new AiravataSystemException();
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);
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;
}
}
Aggregations