Search in sources :

Example 1 with ThemeNotFoundException

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);
    }
}
Also used : TechnicalException(io.gravitee.repository.exceptions.TechnicalException) ThemeNotFoundException(io.gravitee.rest.api.service.exceptions.ThemeNotFoundException) Theme(io.gravitee.repository.management.model.Theme) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Aggregations

TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1 Theme (io.gravitee.repository.management.model.Theme)1 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)1 ThemeNotFoundException (io.gravitee.rest.api.service.exceptions.ThemeNotFoundException)1