use of io.gravitee.rest.api.service.exceptions.ThemeNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class ThemeServiceImpl method findByIdWithoutConvert.
private Theme findByIdWithoutConvert(String themeId) {
try {
LOGGER.debug("Find theme by ID: {}", themeId);
Optional<Theme> optTheme = themeRepository.findById(themeId);
if (!optTheme.isPresent()) {
throw new ThemeNotFoundException(themeId);
}
Theme theme = optTheme.get();
if (!theme.getReferenceId().equals(GraviteeContext.getCurrentEnvironment())) {
LOGGER.warn("Theme is not in current environment " + GraviteeContext.getCurrentEnvironment() + " actual:" + theme.getReferenceId());
throw new ThemeNotFoundException(themeId);
}
return theme;
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find theme by ID", ex);
throw new TechnicalManagementException("An error occurs while trying to find theme by ID", ex);
}
}
Aggregations