Search in sources :

Example 1 with PortalNotification

use of io.gravitee.repository.management.model.PortalNotification in project gravitee-management-rest-api by gravitee-io.

the class PortalNotificationServiceImpl method convert.

private PortalNotification convert(NewPortalNotificationEntity entity) {
    PortalNotification notification = new PortalNotification();
    notification.setTitle(entity.getTitle());
    notification.setMessage(entity.getMessage());
    notification.setUser(entity.getUser());
    return notification;
}
Also used : PortalNotification(io.gravitee.repository.management.model.PortalNotification)

Example 2 with PortalNotification

use of io.gravitee.repository.management.model.PortalNotification in project gravitee-management-rest-api by gravitee-io.

the class PortalNotificationServiceImpl method create.

private void create(List<NewPortalNotificationEntity> notificationEntities) {
    final Date now = new Date();
    List<PortalNotification> notifications = notificationEntities.stream().map(this::convert).collect(Collectors.toList());
    notifications.forEach(n -> {
        n.setId(UUID.toString(UUID.random()));
        n.setCreatedAt(now);
    });
    try {
        portalNotificationRepository.create(notifications);
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to create {}", notifications, ex);
        throw new TechnicalManagementException("An error occurs while trying create " + notifications, ex);
    }
}
Also used : PortalNotification(io.gravitee.repository.management.model.PortalNotification) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

PortalNotification (io.gravitee.repository.management.model.PortalNotification)2 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)1 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1