use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getParentDataProduct.
@Override
public DataProductModel getParentDataProduct(String productUri) throws RegistryServiceException, TException {
try {
dataCatalog = RegistryFactory.getReplicaCatalog();
DataProductModel dataProductModel = dataCatalog.getParentDataProduct(productUri);
return dataProductModel;
} catch (RegistryException e) {
String msg = "Error in retreiving the parent data product for " + productUri + ".";
logger.error(msg, e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage(msg + " More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getExperimentsInProject.
/**
* Get All Experiments of the Project
* Get Experiments within project with pagination. Results will be sorted based on creation time DESC.
*
* @param projectId Uniqie identifier of the project.
* @param limit Amount of results to be fetched.
* @param offset The starting point of the results to be fetched.
*/
@Override
public List<ExperimentModel> getExperimentsInProject(String projectId, int limit, int offset) throws RegistryServiceException, TException {
if (!validateString(projectId)) {
logger.error("Project id cannot be empty. Please provide a valid project ID...");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Project id cannot be empty. Please provide a valid project ID...");
throw exception;
}
try {
experimentCatalog = RegistryFactory.getDefaultExpCatalog();
if (!experimentCatalog.isExist(ExperimentCatalogModelType.PROJECT, projectId)) {
logger.error("Project does not exist in the system. Please provide a valid project ID...");
ProjectNotFoundException exception = new ProjectNotFoundException();
exception.setMessage("Project does not exist in the system. Please provide a valid project ID...");
throw exception;
}
List<ExperimentModel> experiments = new ArrayList<ExperimentModel>();
List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, Constants.FieldConstants.ExperimentConstants.PROJECT_ID, projectId, limit, offset, Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
experiments.add((ExperimentModel) o);
}
}
logger.debug("Airavata retrieved experiments for project : " + projectId);
return experiments;
} catch (Exception e) {
logger.error("Error while retrieving the experiments", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving the experiments. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method registerUserResourceProfile.
/**
* Register a User Resource Profile.
*
* @param userResourceProfile User Resource Profile Object.
* The GatewayID should be obtained from Airavata user profile data model and passed to register a corresponding
* resource profile.
* @return status
* Returns a success/failure of the update.
*/
@Override
public String registerUserResourceProfile(UserResourceProfile userResourceProfile) throws RegistryServiceException, TException {
try {
if (!validateString(userResourceProfile.getUserId())) {
logger.error("Cannot create user resource profile with empty user id");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Cannot create user resource profile with empty gateway id");
throw exception;
}
if (!validateString(userResourceProfile.getGatewayID())) {
logger.error("Cannot create user resource profile with empty gateway id");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Cannot create user resource profile with empty gateway id");
throw exception;
}
if (!ExpCatResourceUtils.isUserExist(userResourceProfile.getUserId(), userResourceProfile.getGatewayID())) {
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();
String resourceProfile = userProfile.addUserResourceProfile(userResourceProfile);
logger.debug("Airavata registered user resource profile with gateway id : " + userResourceProfile.getGatewayID() + "and user id : " + userResourceProfile.getUserId());
return resourceProfile;
} catch (AppCatalogException e) {
logger.error("Error while registering user resource profile...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while registering user resource profile. More info : " + e.getMessage());
throw exception;
} catch (RegistryException e) {
logger.error("Error while registering user resource profile...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while registering 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 getUserStoragePreference.
/**
* Fetch a Storage Resource Preference of a registered gateway profile.
* @param userId identifier for user data model
* @param gatewayID The identifier of the gateway profile to request to fetch the particular storage resource preference.
* @param storageId Identifier of the Storage Preference required to be fetched.
* @return StoragePreference
* Returns the StoragePreference object.
*/
@Override
public UserStoragePreference getUserStoragePreference(String userId, String gatewayID, String storageId) 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!!!");
}
UserStoragePreference storagePreference = userProfile.getUserStoragePreference(userId, gatewayID, storageId);
logger.debug("Airavata retrieved user storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageId);
return storagePreference;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while reading gateway data storage preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while reading gateway 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 updateNotification.
@Override
public boolean updateNotification(Notification notification) throws RegistryServiceException, TException {
try {
experimentCatalog = RegistryFactory.getExperimentCatalog(notification.getGatewayId());
experimentCatalog.update(ExperimentCatalogModelType.NOTIFICATION, notification, notification.getGatewayId());
return true;
} catch (RegistryException e) {
logger.error("Error while updating notification", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while getting gateway. More info : " + e.getMessage());
throw exception;
}
}
Aggregations