use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class LogsServiceImpl method findByApi.
@Override
public SearchLogResponse findByApi(String api, LogQuery query) {
try {
TabularResponse response = logRepository.query(QueryBuilders.tabular().page(query.getPage()).size(query.getSize()).query(query.getQuery()).timeRange(DateRangeBuilder.between(query.getFrom(), query.getTo()), IntervalBuilder.interval(query.getInterval())).root("api", api).build());
SearchLogResponse<ApiRequestItem> logResponse = new SearchLogResponse<>(response.getSize());
// Transform repository logs
logResponse.setLogs(response.getLogs().stream().map(this::toApiRequestItem).collect(Collectors.toList()));
// Add metadata (only if they are results)
if (response.getSize() > 0) {
Map<String, Map<String, String>> metadata = new HashMap<>();
logResponse.getLogs().forEach(logItem -> {
String application = logItem.getApplication();
String plan = logItem.getPlan();
if (application != null) {
metadata.computeIfAbsent(application, getApplicationMetadata(application));
}
if (plan != null) {
metadata.computeIfAbsent(plan, getPlanMetadata(plan));
}
});
logResponse.setMetadata(metadata);
}
return logResponse;
} catch (AnalyticsException ae) {
logger.error("Unable to retrieve logs: ", ae);
throw new TechnicalManagementException("Unable to retrieve logs", ae);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class MetadataServiceImpl method findDefaultByKey.
@Override
public MetadataEntity findDefaultByKey(final String key) {
try {
LOGGER.debug("Find default metadata by key");
final Optional<Metadata> optMetadata = metadataRepository.findById(key, DEFAUT_REFERENCE_ID, MetadataReferenceType.DEFAULT);
if (optMetadata.isPresent()) {
return convert(optMetadata.get());
} else {
return null;
}
} catch (TechnicalException ex) {
LOGGER.error("An error occurred while trying to find default metadata by key", ex);
throw new TechnicalManagementException("An error occurred while trying to find default metadata by key", ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class PageServiceImpl method findMaxPortalPageOrder.
@Override
public int findMaxPortalPageOrder() {
try {
logger.debug("Find Max Order Portal Page");
final Integer maxPageOrder = pageRepository.findMaxPortalPageOrder();
return maxPageOrder == null ? 0 : maxPageOrder;
} catch (TechnicalException ex) {
logger.error("An error occured when searching max order portal page", ex);
throw new TechnicalManagementException("An error occured when searching max order portal ", ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class PageServiceImpl method findMaxApiPageOrderByApi.
@Override
public int findMaxApiPageOrderByApi(String apiName) {
try {
logger.debug("Find Max Order Page for api name : {}", apiName);
final Integer maxPageOrder = pageRepository.findMaxApiPageOrderByApiId(apiName);
return maxPageOrder == null ? 0 : maxPageOrder;
} catch (TechnicalException ex) {
logger.error("An error occured when searching max order page for api name [{}]", apiName, ex);
throw new TechnicalManagementException("An error occured when searching max order page for api name " + apiName, ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class TagServiceImpl method delete.
@Override
public void delete(final String tagId) {
try {
Optional<Tag> tagOptional = tagRepository.findById(tagId);
if (tagOptional.isPresent()) {
tagRepository.delete(tagId);
// delete all reference on APIs
apiService.deleteTagFromAPIs(tagId);
auditService.createPortalAuditLog(Collections.singletonMap(TAG, tagId), TAG_DELETED, new Date(), null, tagOptional.get());
}
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to delete tag {}", tagId, ex);
throw new TechnicalManagementException("An error occurs while trying to delete tag " + tagId, ex);
}
}
Aggregations