use of bio.terra.workspace.db.exception.ApplicationNotFoundException in project terra-workspace-manager by DataBiosphere.
the class ApplicationAblePrecheckStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
WsmApplication application = applicationDao.getApplication(applicationId);
// For enable, we require that the application be in the operating state
if (ableEnum == AbleEnum.ENABLE) {
if (application.getState() != WsmApplicationState.OPERATING) {
throw new InvalidApplicationStateException("Applications is " + application.getState().toApi() + " and cannot be enabled");
}
}
FlightMap workingMap = context.getWorkingMap();
workingMap.put(WsmApplicationKeys.WSM_APPLICATION, application);
// See if the application is enabled
WsmWorkspaceApplication workspaceApp;
try {
workspaceApp = applicationDao.getWorkspaceApplication(workspaceId, applicationId);
workingMap.put(WsmApplicationKeys.APPLICATION_ABLE_DAO, computeCorrectState(ableEnum, workspaceApp.isEnabled()));
} catch (ApplicationNotFoundException e) {
workingMap.put(WsmApplicationKeys.APPLICATION_ABLE_DAO, computeCorrectState(ableEnum, false));
}
// See if the application already has APPLICATION role for the workspace
boolean enabledSam = samService.isApplicationEnabledInSam(workspaceId, application.getServiceAccount(), userRequest);
workingMap.put(WsmApplicationKeys.APPLICATION_ABLE_SAM, computeCorrectState(ableEnum, enabledSam));
return StepResult.getStepResultSuccess();
}
use of bio.terra.workspace.db.exception.ApplicationNotFoundException in project terra-workspace-manager by DataBiosphere.
the class ApplicationDao method getWorkspaceApplicationWorker.
// internal workspace application lookup
private WsmWorkspaceApplication getWorkspaceApplicationWorker(UUID workspaceId, UUID applicationId) {
final String sql = WORKSPACE_APPLICATION_QUERY + " WHERE A.application_id = :application_id";
var params = new MapSqlParameterSource().addValue("application_id", applicationId.toString()).addValue("workspace_id", workspaceId.toString());
try {
WsmWorkspaceApplication result = DataAccessUtils.requiredSingleResult(jdbcTemplate.query(sql, params, WORKSPACE_APPLICATION_ROW_MAPPER));
result.workspaceId(workspaceId);
return result;
} catch (EmptyResultDataAccessException e) {
throw new ApplicationNotFoundException(String.format("Application %s not found.", applicationId.toString()));
}
}
use of bio.terra.workspace.db.exception.ApplicationNotFoundException in project terra-workspace-manager by DataBiosphere.
the class ApplicationDao method getApplicationOrThrow.
// internal application lookup
private WsmApplication getApplicationOrThrow(UUID applicationId) {
final String sql = APPLICATION_QUERY + " WHERE application_id = :application_id";
var params = new MapSqlParameterSource().addValue("application_id", applicationId.toString());
try {
return DataAccessUtils.requiredSingleResult(jdbcTemplate.query(sql, params, APPLICATION_ROW_MAPPER));
} catch (EmptyResultDataAccessException e) {
throw new ApplicationNotFoundException(String.format("Application %s not found.", applicationId.toString()));
}
}
use of bio.terra.workspace.db.exception.ApplicationNotFoundException in project terra-workspace-manager by DataBiosphere.
the class ApplicationDao method getApplicationByEmail.
@ReadTransaction
public WsmApplication getApplicationByEmail(String email) {
final String sql = APPLICATION_QUERY + " WHERE service_account = :email";
var params = new MapSqlParameterSource().addValue("email", StringUtils.lowerCase(email));
try {
return DataAccessUtils.requiredSingleResult(jdbcTemplate.query(sql, params, APPLICATION_ROW_MAPPER));
} catch (EmptyResultDataAccessException e) {
throw new ApplicationNotFoundException("Requester is not a configured application: " + email);
}
}
Aggregations