use of io.gravitee.rest.api.service.exceptions.DashboardNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class DashboardServiceImpl method update.
@Override
public DashboardEntity update(UpdateDashboardEntity dashboardEntity) {
try {
final Optional<Dashboard> dashboardOptional = dashboardRepository.findById(dashboardEntity.getId());
if (dashboardOptional.isPresent()) {
final Dashboard dashboard = convert(dashboardEntity);
final DashboardEntity savedDashboard;
if (dashboard.getOrder() != dashboardOptional.get().getOrder()) {
savedDashboard = reorderAndSaveDashboards(dashboard, false);
} else {
savedDashboard = convert(dashboardRepository.update(dashboard));
}
auditService.createEnvironmentAuditLog(Collections.singletonMap(DASHBOARD, dashboard.getId()), DASHBOARD_UPDATED, new Date(), dashboardOptional.get(), dashboard);
return savedDashboard;
} else {
throw new DashboardNotFoundException(dashboardEntity.getId());
}
} catch (TechnicalException ex) {
final String error = "An error occurred while trying to update dashboard " + dashboardEntity;
LOGGER.error(error, ex);
throw new TechnicalManagementException(error, ex);
}
}
use of io.gravitee.rest.api.service.exceptions.DashboardNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class DashboardServiceImpl method findById.
@Override
public DashboardEntity findById(String dashboardId) {
try {
LOGGER.debug("Find dashboard by ID: {}", dashboardId);
Optional<Dashboard> optDashboard = dashboardRepository.findById(dashboardId);
if (!optDashboard.isPresent()) {
throw new DashboardNotFoundException(dashboardId);
}
return convert(optDashboard.get());
} catch (TechnicalException ex) {
final String error = "An error occurs while trying to find dashboard by ID";
LOGGER.error(error, ex);
throw new TechnicalManagementException(error, ex);
}
}
Aggregations