Search in sources :

Example 11 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method updateUserStoragePreference.

/**
 * Update a Storage Resource Preference of a registered user resource profile.
 * @param userId identifier for user data model
 * @param gatewayID         The identifier of the gateway profile to be updated.
 * @param storageId         The Storage resource identifier of the one that you want to update
 * @param userStoragePreference The storagePreference object to be updated to the resource profile.
 * @return status
 * Returns a success/failure of the updation.
 */
@Override
public boolean updateUserStoragePreference(String userId, String gatewayID, String storageId, UserStoragePreference userStoragePreference) 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();
        UserResourceProfile profile = userProfile.getUserResourceProfile(userId, gatewayID);
        List<UserStoragePreference> dataStoragePreferences = profile.getUserStoragePreferences();
        UserStoragePreference preferenceToRemove = null;
        for (UserStoragePreference preference : dataStoragePreferences) {
            if (preference.getStorageResourceId().equals(storageId)) {
                preferenceToRemove = preference;
                break;
            }
        }
        if (preferenceToRemove != null) {
            profile.getUserStoragePreferences().remove(preferenceToRemove);
        }
        profile.getUserStoragePreferences().add(userStoragePreference);
        userProfile.updateUserResourceProfile(userId, gatewayID, profile);
        logger.debug("Airavata updated user storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageId);
        return true;
    } catch (AppCatalogException e) {
        logger.error(gatewayID, "Error while reading user data storage preference...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating user data storage 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) UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) UserResourceProfile(org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile)

Example 12 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method getLatestQueueStatuses.

/**
 * * Get queue statuses of all compute resources
 * *
 */
@Override
public List<QueueStatusModel> getLatestQueueStatuses() throws RegistryServiceException, TException {
    try {
        experimentCatalog = RegistryFactory.getExperimentCatalog(ServerSettings.getDefaultUserGateway());
        List<Object> temp = experimentCatalog.get(ExperimentCatalogModelType.QUEUE_STATUS, null, null, -1, 0, null, null);
        List<QueueStatusModel> queueStatusModels = new ArrayList<>();
        temp.stream().forEach(t -> {
            queueStatusModels.add((QueueStatusModel) t);
        });
        return queueStatusModels;
    } catch (RegistryException | ApplicationSettingsException e) {
        logger.error("Error while reading queue status models....", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while reading queue status models.... : " + e.getMessage());
        throw exception;
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) QueueStatusModel(org.apache.airavata.model.status.QueueStatusModel) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 13 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method updateGatewayResourceProfile.

/**
 * Update a Gateway Resource Profile.
 *
 * @param gatewayID              The identifier for the requested gateway resource to be updated.
 * @param gatewayResourceProfile Gateway Resource Profile Object.
 * @return status
 * Returns a success/failure of the update.
 */
@Override
public boolean updateGatewayResourceProfile(String gatewayID, GatewayResourceProfile gatewayResourceProfile) throws RegistryServiceException, TException {
    try {
        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...");
        }
        appCatalog = RegistryFactory.getAppCatalog();
        GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
        gatewayProfile.updateGatewayResourceProfile(gatewayID, gatewayResourceProfile);
        logger.debug("Airavata updated gateway profile with gateway id : " + gatewayID);
        return true;
    } catch (AppCatalogException e) {
        logger.error(gatewayID, "Error while updating gateway resource profile...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating gateway resource profile. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 14 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method getAllUserResourceProfiles.

/**
 * Fetch all User Resource Profiles registered
 *
 * @return UserResourceProfile
 * Returns all the UserResourceProfile list object.
 */
@Override
public List<UserResourceProfile> getAllUserResourceProfiles() throws RegistryServiceException, TException {
    try {
        appCatalog = RegistryFactory.getAppCatalog();
        UsrResourceProfile userProfile = appCatalog.getUserResourceProfile();
        return userProfile.getAllUserResourceProfiles();
    } catch (AppCatalogException e) {
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while reading retrieving all gateway profiles. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException)

Example 15 with RegistryServiceException

use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.

the class RegistryServerHandler method deleteGatewayStoragePreference.

/**
 * Delete the Storage Resource Preference of a registered gateway profile.
 *
 * @param gatewayID The identifier of the gateway profile to be deleted.
 * @param storageId ID of the storage preference you want to delete.
 * @return status
 * Returns a success/failure of the deletion.
 */
@Override
public boolean deleteGatewayStoragePreference(String gatewayID, String storageId) throws RegistryServiceException, TException {
    try {
        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...");
        }
        appCatalog = RegistryFactory.getAppCatalog();
        GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
        return gatewayProfile.removeDataStoragePreferenceFromGateway(gatewayID, storageId);
    } catch (AppCatalogException e) {
        logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while updating gateway data storage preference. 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