use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class EventServiceImpl method findById.
@Override
public EventEntity findById(String id) {
try {
LOGGER.debug("Find event by ID: {}", id);
Optional<Event> event = eventRepository.findById(id);
if (event.isPresent()) {
return convert(event.get());
}
throw new EventNotFoundException(id);
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find an event using its ID {}", id, ex);
throw new TechnicalManagementException("An error occurs while trying to find an event using its ID " + id, ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class EventServiceImpl method create.
@Override
public EventEntity create(NewEventEntity newEventEntity) {
String hostAddress = "";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
LOGGER.debug("Create {} for server {}", newEventEntity, hostAddress);
Event event = convert(newEventEntity);
event.setId(io.gravitee.common.utils.UUID.random().toString());
// Set origin
event.getProperties().put(Event.EventProperties.ORIGIN.getValue(), hostAddress);
// Set date fields
event.setCreatedAt(new Date());
event.setUpdatedAt(event.getCreatedAt());
Event createdEvent = eventRepository.create(event);
return convert(createdEvent);
} catch (UnknownHostException e) {
LOGGER.error("An error occurs while getting the server IP address", e);
throw new TechnicalManagementException("An error occurs while getting the server IP address", e);
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to create {} for server {}", newEventEntity, hostAddress, ex);
throw new TechnicalManagementException("An error occurs while trying create " + newEventEntity + " for server " + hostAddress, ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class FetcherServiceImpl method findAll.
@Override
public Set<FetcherEntity> findAll() {
try {
LOGGER.debug("List all fetchers");
final Collection<FetcherPlugin> fetcherDefinitions = fetcherPluginManager.findAll();
return fetcherDefinitions.stream().map(fetcherDefinition -> convert(fetcherDefinition, false)).collect(Collectors.toSet());
} catch (Exception ex) {
LOGGER.error("An error occurs while trying to list all fetchers", ex);
throw new TechnicalManagementException("An error occurs while trying to list all fetchers", ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class GenericNotificationConfigServiceImpl method update.
@Override
public GenericNotificationConfigEntity update(GenericNotificationConfigEntity entity) {
try {
if (entity.getNotifier() == null || entity.getNotifier().isEmpty() || entity.getName() == null || entity.getName().isEmpty()) {
throw new BadNotificationConfigException("Name or notifier is missing !");
}
if (entity.getId() == null || entity.getId().isEmpty()) {
throw new NotificationConfigNotFoundException();
}
Optional<GenericNotificationConfig> optionalConfig = genericNotificationConfigRepository.findById(entity.getId());
if (!optionalConfig.isPresent()) {
throw new NotificationConfigNotFoundException();
}
GenericNotificationConfig notificationConfig = convert(entity);
notificationConfig.setCreatedAt(optionalConfig.get().getCreatedAt());
notificationConfig.setUpdatedAt(new Date());
return convert(genericNotificationConfigRepository.update(notificationConfig));
} catch (TechnicalException te) {
LOGGER.error("An error occurs while trying to save the generic notification settings {}", entity, te);
throw new TechnicalManagementException("An error occurs while trying to save the generic notification settings " + entity, te);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class GroupServiceImpl method findByEvent.
@Override
public Set<GroupEntity> findByEvent(GroupEvent event) {
try {
logger.debug("findByEvent : {}", event);
Set<GroupEntity> set = groupRepository.findAll().stream().filter(g -> g.getEventRules() != null && g.getEventRules().stream().map(GroupEventRule::getEvent).collect(Collectors.toList()).contains(event)).map(this::map).collect(Collectors.toSet());
logger.debug("findByEvent : {} - DONE", set);
return set;
} catch (TechnicalException ex) {
logger.error("An error occurs while trying to find groups by event", ex);
throw new TechnicalManagementException("An error occurs while trying to find groups by event", ex);
}
}
Aggregations