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;
}
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
Aggregations