Search in sources :

Example 1 with PortalNotificationConfigEntity

use of io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.

the class ApplicationNotificationResource method update.

@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_NOTIFICATION, acls = RolePermissionAction.UPDATE) })
public Response update(@PathParam("applicationId") String applicationId, @NotNull(message = "Input must not be null.") NotificationInput notification) {
    // Does application exists ?
    applicationService.findById(applicationId);
    final PortalNotificationConfigEntity portalConfig = portalNotificationConfigService.findById(getAuthenticatedUser(), NotificationReferenceType.APPLICATION, applicationId);
    portalConfig.setHooks(notification.getHooks());
    portalNotificationConfigService.save(portalConfig);
    genericNotificationConfigService.findByReference(NotificationReferenceType.APPLICATION, applicationId).forEach(genericConfig -> {
        genericConfig.setHooks(notification.getHooks());
        genericNotificationConfigService.update(genericConfig);
    });
    return Response.ok(notification.getHooks()).build();
}
Also used : PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity) Permissions(io.gravitee.rest.api.portal.rest.security.Permissions)

Example 2 with PortalNotificationConfigEntity

use of io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.

the class PortalNotificationConfigServiceImpl method convert.

private PortalNotificationConfigEntity convert(PortalNotificationConfig portalNotificationConfig) {
    PortalNotificationConfigEntity entity = new PortalNotificationConfigEntity();
    entity.setConfigType(NotificationConfigType.PORTAL);
    entity.setReferenceType(portalNotificationConfig.getReferenceType().name());
    entity.setReferenceId(portalNotificationConfig.getReferenceId());
    entity.setUser(portalNotificationConfig.getUser());
    entity.setHooks(portalNotificationConfig.getHooks());
    return entity;
}
Also used : PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity)

Example 3 with PortalNotificationConfigEntity

use of io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.

the class ApplicationNotificationSettingsResource method convert.

private PortalNotificationConfigEntity convert(GenericNotificationConfigEntity generic) {
    PortalNotificationConfigEntity portalNotificationConfigEntity = new PortalNotificationConfigEntity();
    portalNotificationConfigEntity.setConfigType(generic.getConfigType());
    portalNotificationConfigEntity.setReferenceType(generic.getReferenceType());
    portalNotificationConfigEntity.setReferenceId(generic.getReferenceId());
    portalNotificationConfigEntity.setUser(getAuthenticatedUser());
    portalNotificationConfigEntity.setHooks(generic.getHooks());
    return portalNotificationConfigEntity;
}
Also used : PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity)

Example 4 with PortalNotificationConfigEntity

use of io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.

the class PortalNotificationSettingsResource method convert.

private PortalNotificationConfigEntity convert(GenericNotificationConfigEntity generic) {
    PortalNotificationConfigEntity portalNotificationConfigEntity = new PortalNotificationConfigEntity();
    portalNotificationConfigEntity.setConfigType(generic.getConfigType());
    portalNotificationConfigEntity.setReferenceType(generic.getReferenceType());
    portalNotificationConfigEntity.setReferenceId(generic.getReferenceId());
    portalNotificationConfigEntity.setUser(getAuthenticatedUser());
    portalNotificationConfigEntity.setHooks(generic.getHooks());
    return portalNotificationConfigEntity;
}
Also used : PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity)

Example 5 with PortalNotificationConfigEntity

use of io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiNotificationSettingsResource method convert.

private PortalNotificationConfigEntity convert(GenericNotificationConfigEntity generic) {
    PortalNotificationConfigEntity portalNotificationConfigEntity = new PortalNotificationConfigEntity();
    portalNotificationConfigEntity.setConfigType(generic.getConfigType());
    portalNotificationConfigEntity.setReferenceType(generic.getReferenceType());
    portalNotificationConfigEntity.setReferenceId(generic.getReferenceId());
    portalNotificationConfigEntity.setUser(getAuthenticatedUser());
    portalNotificationConfigEntity.setHooks(generic.getHooks());
    return portalNotificationConfigEntity;
}
Also used : PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity)

Aggregations

PortalNotificationConfigEntity (io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity)12 Test (org.junit.Test)5 PortalNotificationConfig (io.gravitee.repository.management.model.PortalNotificationConfig)3 Permissions (io.gravitee.rest.api.portal.rest.security.Permissions)2 HashSet (java.util.HashSet)1