Пример #1
0
 @RolesAllowed({"ROLE_USER"})
 @Path("{id}")
 @DELETE
 public Response delete(final @PathParam("id") String id) {
   reportService.deleteReport(id);
   return Response.ok().build();
 }
Пример #2
0
 @RolesAllowed({"ROLE_USER"})
 @Path("{id}")
 @GET
 public ReportResponse gerReport(
     final @PathParam("id") String reportId, final @Context SecurityContext securityContext) {
   User user = loadUserFromSecurityContext(securityContext);
   if (user == null)
     throw new UnauthorizedUserException("you don't have permit to update this entities");
   return reportService.getReport(reportId);
 }
Пример #3
0
 @RolesAllowed({"ROLE_USER"})
 @GET
 public List<ReportResponse> getReports(@Context SecurityContext context) throws EntityException {
   User user = loadUserFromSecurityContext(context);
   if (user != null) {
     log.info("reading all entities by " + user.getId());
     List<Report> list = reportService.listReports();
     List<ReportResponse> listResponse =
         list.stream().map(ReportResponse::new).collect(Collectors.toList());
     return listResponse;
   } else {
     log.info("rejected unauth user reading entities action");
     throw new UnauthorizedUserException("you don't have permit to loading all entities");
   }
 }
Пример #4
0
 @RolesAllowed({"ROLE_USER"})
 @POST
 public ReportResponse createReport(@Context SecurityContext context, CreateReportRequest request)
     throws EntityException {
   if (request == null) {
     throw new NullParametersException("report");
   }
   User user = loadUserFromSecurityContext(context);
   if (user != null) {
     log.info("creating report [" + request.getName() + "] by [" + user.getId() + "]");
     ReportResponse reportResponse = reportService.createReportFromRequest(request);
     return reportResponse;
   } else {
     log.info("rejected unauth user creating report action");
     throw new UnauthorizedUserException("you don't have permit to create reports");
   }
 }