use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.
the class UsrResourceProfileImpl method removeUserDataStoragePreferenceFromGateway.
@Override
public boolean removeUserDataStoragePreferenceFromGateway(String userId, String gatewayId, String preferenceId) throws AppCatalogException {
try {
UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
CompositeIdentifier ids = new CompositeIdentifier(preferenceId, userId, gatewayId);
resource.remove(ids);
return true;
} catch (Exception e) {
logger.error("Error while deleting user resource profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.
the class UsrResourceProfileImpl method removeUserResourceProfile.
@Override
public boolean removeUserResourceProfile(String userId, String gatewayId) throws AppCatalogException {
try {
UserResourceProfileResource resource = new UserResourceProfileResource();
CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
resource.remove(ids);
return true;
} catch (Exception e) {
logger.error("Error while deleting user resource profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.
the class UsrResourceProfileImpl method getUserComputeResourcePreference.
/**
* @param gatewayId
* @param hostId
* @return ComputeResourcePreference
*/
@Override
public UserComputeResourcePreference getUserComputeResourcePreference(String userId, String gatewayId, String hostId) throws AppCatalogException {
try {
UserComputeHostPreferenceResource prefResource = new UserComputeHostPreferenceResource();
CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.UserComputeResourcePreferenceConstants.USER_ID, ids);
for (AppCatalogResource resource : computePrefList) {
UserComputeHostPreferenceResource cmP = (UserComputeHostPreferenceResource) resource;
if (cmP.getResourceId() != null && !cmP.getResourceId().equals("")) {
if (cmP.getResourceId().equals(hostId)) {
return AppCatalogThriftConversion.getUserComputeResourcePreference(cmP);
}
}
}
} catch (Exception e) {
logger.error("Error while retrieving user compute resource preference...", e);
throw new AppCatalogException(e);
}
return null;
}
use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.
the class UsrResourceProfileImpl method updateUserResourceProfile.
@Override
public void updateUserResourceProfile(String userId, String gatewayId, org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile updatedProfile) throws AppCatalogException {
try {
UserResourceProfileResource profileResource = new UserResourceProfileResource();
CompositeIdentifier ids = new CompositeIdentifier(userId, gatewayId);
UserResourceProfileResource existingUP = (UserResourceProfileResource) profileResource.get(ids);
existingUP.setCredentialStoreToken(updatedProfile.getCredentialStoreToken());
existingUP.setIdentityServerTenant(updatedProfile.getIdentityServerTenant());
existingUP.setIdentityServerPwdCredToken(updatedProfile.getIdentityServerPwdCredToken());
existingUP.save();
List<UserComputeResourcePreference> userComputeResourcePreferences = updatedProfile.getUserComputeResourcePreferences();
if (userComputeResourcePreferences != null && !userComputeResourcePreferences.isEmpty()) {
for (UserComputeResourcePreference preference : userComputeResourcePreferences) {
UserComputeHostPreferenceResource resource = new UserComputeHostPreferenceResource();
resource.setUserResourceProfileResource(existingUP);
resource.setResourceId(preference.getComputeResourceId());
ComputeResourceResource computeHostResource = new ComputeResourceResource();
resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
resource.setUserId(userId);
resource.setGatewayId(gatewayId);
resource.setLoginUserName(preference.getLoginUserName());
resource.setBatchQueue(preference.getPreferredBatchQueue());
resource.setProjectNumber(preference.getAllocationProjectNumber());
resource.setScratchLocation(preference.getScratchLocation());
resource.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
resource.setQualityOfService(preference.getQualityOfService());
resource.setReservation(preference.getReservation());
if (preference.getReservationStartTime() > 0) {
resource.setReservationStartTime(AiravataUtils.getTime(preference.getReservationStartTime()));
}
if (preference.getReservationEndTime() > 0) {
resource.setReservationEndTime(AiravataUtils.getTime(preference.getReservationEndTime()));
}
resource.setValidated(preference.isValidated());
resource.save();
}
}
List<UserStoragePreference> dataStoragePreferences = updatedProfile.getUserStoragePreferences();
if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
for (UserStoragePreference storagePreference : dataStoragePreferences) {
UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
resource.setStorageResourceId(storagePreference.getStorageResourceId());
resource.setGatewayId(existingUP.getGatewayID());
resource.setUserId(existingUP.getUserId());
resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
resource.setLoginUserName(storagePreference.getLoginUserName());
resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
resource.setUserResourceProfileResource(existingUP);
resource.save();
}
}
} catch (Exception e) {
logger.error("Error while updating User Resource profile...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.CompositeIdentifier in project airavata by apache.
the class UsrResourceProfileImpl method removeUserComputeResourcePreferenceFromGateway.
@Override
public boolean removeUserComputeResourcePreferenceFromGateway(String userId, String gatewayId, String preferenceId) throws AppCatalogException {
try {
UserComputeHostPreferenceResource resource = new UserComputeHostPreferenceResource();
CompositeIdentifier ids = new CompositeIdentifier(preferenceId, userId, gatewayId);
resource.remove(ids);
return true;
} catch (Exception e) {
logger.error("Error while deleting user resource profile...", e);
throw new AppCatalogException(e);
}
}
Aggregations