use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method addUserComputeResourcePreference.
/**
* Add a User Compute Resource Preference to a registered gateway profile.
* @param userId
* @param gatewayID The identifier for the gateway profile to be added.
* @param computeResourceId Preferences related to a particular compute resource
* @param userComputeResourcePreference The UserComputeResourcePreference object to be added to the resource profile.
* @return status
* Returns a success/failure of the addition. If a profile already exists, this operation will fail.
* Instead an update should be used.
*/
@Override
public boolean addUserComputeResourcePreference(String userId, String gatewayID, String computeResourceId, UserComputeResourcePreference userComputeResourcePreference) throws RegistryServiceException, TException {
try {
if (!ExpCatResourceUtils.isUserExist(userId, gatewayID)) {
logger.error("user does not exist.Please provide a valid user id...");
throw new RegistryServiceException("user does not exist.Please provide a valid user id...");
}
appCatalog = RegistryFactory.getAppCatalog();
UsrResourceProfile userProfile = appCatalog.getUserResourceProfile();
if (!userProfile.isUserResourceProfileExists(userId, gatewayID)) {
throw new RegistryServiceException("User resource profile with user id'" + userId + " & gateway Id" + gatewayID + "' does not exist!!!");
}
UserResourceProfile profile = userProfile.getUserResourceProfile(userId, gatewayID);
// gatewayProfile.removeGatewayResourceProfile(gatewayID);
profile.addToUserComputeResourcePreferences(userComputeResourcePreference);
userProfile.updateUserResourceProfile(userId, gatewayID, profile);
logger.debug("Airavata added User compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
return true;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while registering User resource profile preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while registering user resource profile preference. More info : " + e.getMessage());
throw exception;
} catch (RegistryException e) {
logger.error(userId, "Error while retrieving user resource profile...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getJobDetails.
/**
* Get Job Details for all the jobs within an Experiment.
* This method to be used when need to get the job details for one or many jobs of an Experiment.
*
* @param airavataExperimentId@return list of JobDetails
* Job details.
*/
@Override
public List<JobModel> getJobDetails(String airavataExperimentId) throws RegistryServiceException, 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;
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while retrieving the job details", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving the job details. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method deleteApplicationModule.
/**
* Delete an Application Module.
*
* @param appModuleId The identifier of the Application Module to be deleted.
* @return status
* Returns a success/failure of the deletion.
*/
@Override
public boolean deleteApplicationModule(String appModuleId) throws RegistryServiceException, TException {
try {
appCatalog = RegistryFactory.getAppCatalog();
logger.debug("Airavata deleted application module with module id : " + appModuleId);
return appCatalog.getApplicationInterface().removeApplicationModule(appModuleId);
} catch (AppCatalogException e) {
logger.error(appModuleId, "Error while deleting application module...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while deleting the application module. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getAllApplicationInterfaces.
/**
* Fetch all Application Interface documents.
*
* @param gatewayId
* @return map<applicationId, applicationInterfaceNames>
* Returns a list of application interfaces documents (Application Interface ID, name, description, Inputs and Outputs objects).
*/
@Override
public List<ApplicationInterfaceDescription> getAllApplicationInterfaces(String gatewayId) throws RegistryServiceException, TException {
if (!isGatewayExistInternal(gatewayId)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
try {
appCatalog = RegistryFactory.getAppCatalog();
List<ApplicationInterfaceDescription> interfaces = appCatalog.getApplicationInterface().getAllApplicationInterfaces(gatewayId);
logger.debug("Airavata retrieved application interfaces for gateway id : " + gatewayId);
return interfaces;
} catch (AppCatalogException e) {
logger.error("Error while retrieving application interfaces...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving application interfaces. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method deleteGateway.
/**
* Delete a Gateway
*
* @param gatewayId The gateway Id of the Gateway to be deleted.
* @return boolean
* Boolean identifier for the success or failure of the deletion operation.
*/
@Override
public boolean deleteGateway(String gatewayId) throws RegistryServiceException, 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) {
logger.error("Error while deleting the gateway", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while deleting the gateway. More info : " + e.getMessage());
throw exception;
}
}
Aggregations