use of io.gravitee.management.service.exceptions.PageNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class PageServiceImpl method delete.
@Override
public void delete(String pageId) {
try {
logger.debug("Delete Page : {}", pageId);
Optional<Page> optPage = pageRepository.findById(pageId);
if (!optPage.isPresent()) {
throw new PageNotFoundException(pageId);
}
pageRepository.delete(pageId);
createAuditLog(optPage.get().getApi(), PAGE_DELETED, new Date(), optPage.get(), null);
} catch (TechnicalException ex) {
logger.error("An error occurs while trying to delete Page {}", pageId, ex);
throw new TechnicalManagementException("An error occurs while trying to delete Page " + pageId, ex);
}
}
use of io.gravitee.management.service.exceptions.PageNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class PageServiceImpl method findById.
@Override
public PageEntity findById(String pageId, boolean transform) {
try {
logger.debug("Find page by ID: {}", pageId);
Optional<Page> page = pageRepository.findById(pageId);
if (page.isPresent()) {
PageEntity pageEntity = convert(page.get());
if (transform) {
transformUsingConfiguration(pageEntity);
if (page.get().getApi() != null) {
transformWithTemplate(pageEntity, page.get().getApi());
}
}
return pageEntity;
}
throw new PageNotFoundException(pageId);
} catch (TechnicalException ex) {
logger.error("An error occurs while trying to find a page using its ID {}", pageId, ex);
throw new TechnicalManagementException("An error occurs while trying to find a page using its ID " + pageId, ex);
}
}
Aggregations