Search in sources :

Example 1 with ApplicationAlertMaximumException

use of io.gravitee.rest.api.service.exceptions.ApplicationAlertMaximumException in project gravitee-management-rest-api by gravitee-io.

the class ApplicationAlertsResource method createApplicationAlert.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_ALERT, acls = RolePermissionAction.CREATE) })
public Response createApplicationAlert(@PathParam("applicationId") String applicationId, @Valid @NotNull(message = "Input must not be null.") AlertInput alertInput) {
    checkPlugins();
    if (applicationAlertService.findByApplication(applicationId).size() == 10) {
        throw new ApplicationAlertMaximumException(applicationId, 10);
    }
    final NewAlertTriggerEntity newAlertTriggerEntity = alertMapper.convert(alertInput);
    final AlertTriggerEntity alert = applicationAlertService.create(applicationId, newAlertTriggerEntity);
    return Response.created(this.getLocationHeader(alert.getId())).entity(alertMapper.convert(alert)).build();
}
Also used : ApplicationAlertMaximumException(io.gravitee.rest.api.service.exceptions.ApplicationAlertMaximumException) NewAlertTriggerEntity(io.gravitee.rest.api.model.alert.NewAlertTriggerEntity) AlertTriggerEntity(io.gravitee.rest.api.model.alert.AlertTriggerEntity) NewAlertTriggerEntity(io.gravitee.rest.api.model.alert.NewAlertTriggerEntity) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Permissions(io.gravitee.rest.api.portal.rest.security.Permissions)

Aggregations

AlertTriggerEntity (io.gravitee.rest.api.model.alert.AlertTriggerEntity)1 NewAlertTriggerEntity (io.gravitee.rest.api.model.alert.NewAlertTriggerEntity)1 Permissions (io.gravitee.rest.api.portal.rest.security.Permissions)1 ApplicationAlertMaximumException (io.gravitee.rest.api.service.exceptions.ApplicationAlertMaximumException)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1