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