Search in sources :

Example 96 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project jersey by jersey.

the class FlightsResource method updateStatus.

@POST
@Path("{id}/status")
@Consumes(APPLICATION_FORM_URLENCODED)
@Produces(TEXT_PLAIN)
@RolesAllowed("admin")
public String updateStatus(@ValidFlightId @PathParam("id") String flightId, @FormParam("status") String newStatus) {
    Flight.Status status;
    try {
        status = Flight.Status.valueOf(newStatus);
    } catch (IllegalArgumentException e) {
        throw new BadRequestException("Unknown status.");
    }
    final Flight flight = DataStore.selectFlight(flightId);
    flight.setStatus(status);
    return status.name();
}
Also used : Flight(org.glassfish.jersey.examples.flight.model.Flight) BadRequestException(javax.ws.rs.BadRequestException) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 97 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project jersey by jersey.

the class FlightsResource method create.

@POST
@Consumes(APPLICATION_FORM_URLENCODED)
@RolesAllowed("admin")
@Detail
public Flight create(@ValidAircraftId @FormParam("aircraftId") Integer aircraftId) {
    final Aircraft aircraft = DataStore.selectAircraft(aircraftId);
    if (!aircraft.marAssigned()) {
        throw new BadRequestException("Aircraft already assigned.");
    }
    Flight flight = new Flight(null, aircraft);
    if (!DataStore.addFlight(flight)) {
        aircraft.marAvailable();
        throw new BadRequestException("Flight already exists.");
    }
    return flight;
}
Also used : Flight(org.glassfish.jersey.examples.flight.model.Flight) BadRequestException(javax.ws.rs.BadRequestException) Aircraft(org.glassfish.jersey.examples.flight.model.Aircraft) RolesAllowed(javax.annotation.security.RolesAllowed) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Detail(org.glassfish.jersey.examples.flight.filtering.Detail)

Example 98 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project jersey by jersey.

the class FlightsResource method delete.

@DELETE
@Path("{id}")
@Produces(TEXT_PLAIN)
@RolesAllowed("admin")
public String delete(@ValidFlightId @PathParam("id") String flightId) {
    Flight flight = DataStore.removeFlight(flightId);
    flight.getAircraft().marAvailable();
    return flight.getId();
}
Also used : Flight(org.glassfish.jersey.examples.flight.model.Flight) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces)

Example 99 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project jeeshop by remibantos.

the class Catalogs method delete.

@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed(ADMIN)
@Path("/{catalogId}")
public void delete(@PathParam("catalogId") Long catalogId) {
    Catalog catalog = entityManager.find(Catalog.class, catalogId);
    checkNotNull(catalog);
    entityManager.remove(catalog);
}
Also used : Catalog(org.rembx.jeeshop.catalog.model.Catalog) RolesAllowed(javax.annotation.security.RolesAllowed)

Example 100 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project jeeshop by remibantos.

the class EligibleDiscounts method findEligible.

@GET
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed(JeeshopRoles.USER)
public List<Discount> findEligible(@QueryParam("locale") String locale) {
    User currentUser = userFinder.findByLogin(sessionContext.getCallerPrincipal().getName());
    Long completedOrders = orderFinder.countUserCompletedOrders(currentUser);
    return discountFinder.findEligibleOrderDiscounts(locale, completedOrders);
}
Also used : User(org.rembx.jeeshop.user.model.User) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

RolesAllowed (javax.annotation.security.RolesAllowed)191 Path (javax.ws.rs.Path)127 Produces (javax.ws.rs.Produces)110 Consumes (javax.ws.rs.Consumes)55 GET (javax.ws.rs.GET)54 POST (javax.ws.rs.POST)40 PUT (javax.ws.rs.PUT)35 HashMap (java.util.HashMap)34 ArrayList (java.util.ArrayList)32 IOException (java.io.IOException)30 ApiOperation (io.swagger.annotations.ApiOperation)29 ApiResponses (io.swagger.annotations.ApiResponses)29 Response (javax.ws.rs.core.Response)28 Adapter (nl.nn.adapterframework.core.Adapter)21 DELETE (javax.ws.rs.DELETE)19 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)19 LinkedHashMap (java.util.LinkedHashMap)16 Locale (java.util.Locale)16 Map (java.util.Map)12 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)12