Search in sources :

Example 81 with RegistryServiceException

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;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) UserResourceProfile(org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile)

Example 82 with RegistryServiceException

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;
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) JobModel(org.apache.airavata.model.job.JobModel) TaskModel(org.apache.airavata.model.task.TaskModel) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 83 with RegistryServiceException

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;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 84 with RegistryServiceException

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;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)

Example 85 with RegistryServiceException

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;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Aggregations

RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)131 TException (org.apache.thrift.TException)28 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)26 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)9 UserResourceProfile (org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile)5 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)4 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)4 UserComputeResourcePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference)4 UserStoragePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference)4 DataProductModel (org.apache.airavata.model.data.replica.DataProductModel)4 JobModel (org.apache.airavata.model.job.JobModel)3 ProcessModel (org.apache.airavata.model.process.ProcessModel)3 ExperimentState (org.apache.airavata.model.status.ExperimentState)3 ExperimentStatus (org.apache.airavata.model.status.ExperimentStatus)3 Project (org.apache.airavata.model.workspace.Project)3 CredentialStoreService (org.apache.airavata.credential.store.cpi.CredentialStoreService)2 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)2 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)2 StoragePreference (org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)2 PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)2