use of org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile in project airavata by apache.
the class AiravataServerHandler method getUserResourceProfile.
/**
* Fetch the given User Resource Profile.
*
* @param userId The identifier for the requested User resource
*
* @param gatewayID The identifier to link a gateway for the requested User resource
*
* @return userResourceProfile
* User Resource Profile Object.
*/
@Override
@SecurityCheck
public UserResourceProfile getUserResourceProfile(AuthzToken authzToken, String userId, String gatewayID) throws InvalidRequestException, AiravataClientException, AiravataSystemException, AuthorizationException, TException {
RegistryService.Client regClient = registryClientPool.getResource();
try {
UserResourceProfile result = regClient.getUserResourceProfile(userId, gatewayID);
registryClientPool.returnResource(regClient);
return result;
} catch (Exception e) {
logger.error(userId, "Error while retrieving user resource profile...", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Error while retrieving user resource profile. More info : " + e.getMessage());
registryClientPool.returnBrokenResource(regClient);
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile in project airavata by apache.
the class GFacEngineImpl method setUserResourceProfile.
private void setUserResourceProfile(String gatewayId, ProcessContext processContext) throws AppCatalogException {
AppCatalog appCatalog = processContext.getAppCatalog();
ProcessModel processModel = processContext.getProcessModel();
UserResourceProfile userResourceProfile = appCatalog.getUserResourceProfile().getUserResourceProfile(processModel.getUserName(), gatewayId);
processContext.setUserResourceProfile(userResourceProfile);
}
use of org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile 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.model.appcatalog.userresourceprofile.UserResourceProfile in project airavata by apache.
the class RegistryServerHandler method updateUserComputeResourcePreference.
/**
* Update a Compute Resource Preference to a registered user resource profile.
* @param userId identifier for user data model
* @param gatewayID The identifier for the gateway profile to be updated.
* @param computeResourceId Preferences related to a particular compute resource
* @param userComputeResourcePreference The ComputeResourcePreference object to be updated to the resource profile.
* @return status
* Returns a success/failure of the updation.
*/
@Override
public boolean updateUserComputeResourcePreference(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();
UserResourceProfile profile = userProfile.getUserResourceProfile(userId, gatewayID);
List<UserComputeResourcePreference> userComputeResourcePreferences = profile.getUserComputeResourcePreferences();
UserComputeResourcePreference preferenceToRemove = null;
for (UserComputeResourcePreference preference : userComputeResourcePreferences) {
if (preference.getComputeResourceId().equals(computeResourceId)) {
preferenceToRemove = preference;
break;
}
}
if (preferenceToRemove != null) {
profile.getUserComputeResourcePreferences().remove(preferenceToRemove);
}
profile.getUserComputeResourcePreferences().add(userComputeResourcePreference);
userProfile.updateUserResourceProfile(userId, gatewayID, profile);
logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
return true;
} catch (AppCatalogException e) {
logger.error(userId, "Error while reading user compute resource preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while updating user compute resource 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.model.appcatalog.userresourceprofile.UserResourceProfile in project airavata by apache.
the class RegistryServerHandler method addUserStoragePreference.
/**
* Add a Storage Resource Preference to a registered gateway profile.
*
* @param gatewayID The identifier of the gateway profile to be added.
* @param storageResourceId Preferences related to a particular compute resource
* @param dataStoragePreference
* @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 addUserStoragePreference(String userId, String gatewayID, String storageResourceId, UserStoragePreference dataStoragePreference) 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);
dataStoragePreference.setStorageResourceId(storageResourceId);
profile.addToUserStoragePreferences(dataStoragePreference);
userProfile.updateUserResourceProfile(userId, gatewayID, profile);
logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageResourceId);
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;
}
}
Aggregations