use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getExperimentStatistics.
/**
* Get Experiment Statistics
* Get Experiment Statisitics for a given gateway for a specific time period. This feature is available only for admins of a particular gateway. Gateway admin access is managed by the user roles.
*
* @param gatewayId Unique identifier of the gateway making the request to fetch statistics.
* @param fromTime Starting date time.
* @param toTime Ending data time.
*/
@Override
public ExperimentStatistics getExperimentStatistics(String gatewayId, long fromTime, long toTime, String userName, String applicationName, String resourceHostName) throws RegistryServiceException, TException {
if (!isGatewayExistInternal(gatewayId)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
Map<String, String> filters = new HashMap();
filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);
filters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, fromTime + "");
filters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, toTime + "");
if (userName != null) {
filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
}
if (applicationName != null) {
filters.put(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID, applicationName);
}
if (resourceHostName != null) {
filters.put(Constants.FieldConstants.ExperimentConstants.RESOURCE_HOST_ID, resourceHostName);
}
List<Object> results = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT_STATISTICS, filters);
logger.debug("Airavata retrieved experiments for gateway id : " + gatewayId + " between : " + AiravataUtils.getTime(fromTime) + " and " + AiravataUtils.getTime(toTime));
return (ExperimentStatistics) results.get(0);
} catch (Exception e) {
logger.error("Error while retrieving experiments", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving 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 deleteUserStoragePreference.
/**
* Delete the Storage Resource Preference of a registered gateway profile.
* @param userId The identifier for user data model
* @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 deleteUserStoragePreference(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();
return userProfile.removeUserDataStoragePreferenceFromGateway(userId, gatewayID, storageId);
} 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 registerApplicationModule.
/**
* Register a Application Module.
*
* @param gatewayId
* @param applicationModule Application Module Object created from the datamodel.
* @return appModuleId
* Returns the server-side generated airavata appModule globally unique identifier.
* @gatewayId ID of the gateway which is registering the new Application Module.
*/
@Override
public String registerApplicationModule(String gatewayId, ApplicationModule applicationModule) throws RegistryServiceException, TException {
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...");
}
try {
appCatalog = RegistryFactory.getAppCatalog();
String module = appCatalog.getApplicationInterface().addApplicationModule(applicationModule, gatewayId);
logger.debug("Airavata registered application module for gateway id : " + gatewayId);
return module;
} catch (AppCatalogException e) {
logger.error("Error while adding application module...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while adding application module. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getGatewayStoragePreference.
/**
* Fetch a Storage Resource Preference of a registered gateway profile.
*
* @param gatewayID The identifier of the gateway profile to request to fetch the particular storage resource preference.
* @param storageId Identifier of the Stprage Preference required to be fetched.
* @return StoragePreference
* Returns the StoragePreference object.
*/
@Override
public StoragePreference getGatewayStoragePreference(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();
if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)) {
logger.error(gatewayID, "Given gateway profile does not exist in the system. Please provide a valid gateway id...");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Given gateway profile does not exist in the system. Please provide a valid gateway id...");
throw exception;
}
StoragePreference storagePreference = gatewayProfile.getStoragePreference(gatewayID, storageId);
logger.debug("Airavata retrieved 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;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getAllApplicationDeployments.
/**
* Fetch all Application Deployment Descriptions.
*
* @param gatewayId ID of the gateway which need to list all available application deployment documentation.
* @param gatewayId
* @return list<applicationDeployment.
* Returns the list of all application Deployment Objects.
*/
@Override
public List<ApplicationDeploymentDescription> getAllApplicationDeployments(String gatewayId) throws RegistryServiceException, TException {
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...");
}
try {
appCatalog = RegistryFactory.getAppCatalog();
List<ApplicationDeploymentDescription> deployements = appCatalog.getApplicationDeployment().getAllApplicationDeployements(gatewayId);
logger.debug("Airavata retrieved application deployments for gateway id : " + gatewayId);
return deployements;
} catch (AppCatalogException e) {
logger.error("Error while retrieving application deployments...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving application deployments. More info : " + e.getMessage());
throw exception;
}
}
Aggregations