@POST @Path("/country/{countryId}") @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON}) @RolesAllowed({"admin"}) public Response createOrUpdateAbsenceType( @PathParam("countryId") int countryId, AbsenceType absenceType) { try { getAbsenceTypeManager().updateAbsenceTypeBasedOnCountry(absenceType, countryId); return Response.status(Response.Status.OK).build(); } catch (NamingException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (BusinessException e) { return Response.status(e.getStatus()).build(); } }
@GET @Path("/country/{countryId}") @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON}) @PermitAll public Response getAbsenceTypesBasedOnCountry(@PathParam("countryId") int countryId) { try { List<AbsenceType> absenceTypes = getAbsenceTypeManager().findAbsenceTypeInCountry(countryId); final GenericEntity<List<AbsenceType>> absenceTypeGeneric = new GenericEntity<List<AbsenceType>>(absenceTypes) {}; return Response.status(Response.Status.OK).entity(absenceTypeGeneric).build(); } catch (NamingException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (BusinessException e) { return Response.status(e.getStatus()).build(); } }