Search in sources :

Example 1 with TagNotFoundException

use of io.gravitee.rest.api.service.exceptions.TagNotFoundException in project gravitee-management-rest-api by gravitee-io.

the class TagServiceImpl method findByIdAndReference.

@Override
public TagEntity findByIdAndReference(String tagId, String referenceId, TagReferenceType referenceType) {
    try {
        LOGGER.debug("Find tag by ID: {}", tagId);
        Optional<Tag> optTag = tagRepository.findByIdAndReference(tagId, referenceId, repoTagReferenceType(referenceType));
        if (!optTag.isPresent()) {
            throw new TagNotFoundException(tagId);
        }
        return convert(optTag.get());
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to find tag by ID", ex);
        throw new TechnicalManagementException("An error occurs while trying to find tag by ID", ex);
    }
}
Also used : TagNotFoundException(io.gravitee.rest.api.service.exceptions.TagNotFoundException) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) Tag(io.gravitee.repository.management.model.Tag) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Aggregations

TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1 Tag (io.gravitee.repository.management.model.Tag)1 TagNotFoundException (io.gravitee.rest.api.service.exceptions.TagNotFoundException)1 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)1