use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.
the class ApplicationAlertResource method updateAlert.
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_ALERT, acls = RolePermissionAction.UPDATE) })
public Response updateAlert(@PathParam("applicationId") String applicationId, @PathParam("alertId") String alertId, @Valid @NotNull(message = "Input must not be null.") AlertInput alertInput) {
LOGGER.info("Updating alert {}", alertId);
checkPlugins();
final UpdateAlertTriggerEntity updateAlertTriggerEntity = alertMapper.convertToUpdate(alertInput);
updateAlertTriggerEntity.setId(alertId);
final AlertTriggerEntity updated = applicationAlertService.update(applicationId, updateAlertTriggerEntity);
Alert alert = alertMapper.convert(updated);
return Response.ok(alert).build();
}
use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.
the class ApiRatingAnswersResource method createApiRatingAnswer.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.API_RATING_ANSWER, acls = RolePermissionAction.CREATE) })
public Response createApiRatingAnswer(@PathParam("apiId") String apiId, @PathParam("ratingId") String ratingId, @Valid RatingAnswerInput ratingAnswerInput) {
if (ratingAnswerInput == null) {
throw new BadRequestException("Input must not be null.");
}
final ApiQuery apiQuery = new ApiQuery();
apiQuery.setIds(Collections.singletonList(apiId));
Collection<ApiEntity> userApis = apiService.findPublishedByUser(getAuthenticatedUserOrNull(), apiQuery);
if (userApis.stream().anyMatch(a -> a.getId().equals(apiId))) {
RatingEntity ratingEntity = ratingService.findById(ratingId);
if (ratingEntity != null && ratingEntity.getApi().equals(apiId)) {
NewRatingAnswerEntity ratingAnswerEntity = new NewRatingAnswerEntity();
ratingAnswerEntity.setComment(ratingAnswerInput.getComment());
ratingAnswerEntity.setRatingId(ratingId);
RatingEntity updatedRating = ratingService.createAnswer(ratingAnswerEntity);
return Response.status(Status.CREATED).entity(ratingMapper.convert(updatedRating, uriInfo)).build();
}
throw new RatingNotFoundException(ratingId, apiId);
}
throw new ApiNotFoundException(apiId);
}
use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.
the class ApplicationNotificationResource method get.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = RolePermission.APPLICATION_NOTIFICATION, acls = RolePermissionAction.READ) })
public Response get(@PathParam("applicationId") String applicationId) {
// Does application exists ?
applicationService.findById(applicationId);
final PortalNotificationConfigEntity portalConfig = portalNotificationConfigService.findById(getAuthenticatedUser(), NotificationReferenceType.APPLICATION, applicationId);
final Set<String> hooks = new HashSet<>(portalConfig.getHooks());
genericNotificationConfigService.findByReference(NotificationReferenceType.APPLICATION, applicationId).forEach(genericNotif -> hooks.addAll(genericNotif.getHooks()));
return Response.ok(hooks).build();
}
use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.
the class ApplicationResource method getPictureByApplicationId.
@GET
@Path("picture")
@Produces({ MediaType.WILDCARD, MediaType.APPLICATION_JSON })
@Permissions({ @Permission(value = RolePermission.APPLICATION_DEFINITION, acls = RolePermissionAction.READ) })
public Response getPictureByApplicationId(@Context Request request, @PathParam("applicationId") String applicationId) {
applicationService.findById(applicationId);
InlinePictureEntity image = applicationService.getPicture(applicationId);
return createPictureResponse(request, image);
}
use of io.gravitee.rest.api.portal.rest.security.Permissions in project gravitee-management-rest-api by gravitee-io.
the class ApplicationResource method getBackgroundByApplicationId.
@GET
@Path("background")
@Produces({ MediaType.WILDCARD, MediaType.APPLICATION_JSON })
@Permissions({ @Permission(value = RolePermission.APPLICATION_DEFINITION, acls = RolePermissionAction.READ) })
public Response getBackgroundByApplicationId(@Context Request request, @PathParam("applicationId") String applicationId) {
applicationService.findById(applicationId);
InlinePictureEntity image = applicationService.getBackground(applicationId);
return createPictureResponse(request, image);
}
Aggregations