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();
}
Aggregations