1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| public class CountriesRessource {
@GET
@Produces("application/json;charset=utf-8")
public Response getAll( @Context UriInfo uriInfo,@QueryParam("dialingcode") Integer dc,@QueryParam("countrycode") String iso2,
@QueryParam("countryname") String name,@QueryParam("msisdn") String msisdn,@QueryParam("sort") String choix) {
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
String dcParam = queryParams.getFirst("dialingcode");
String iso2Param = queryParams.getFirst("countrycode");
String nameParam = queryParams.getFirst("countryname");
String msisdnParam = queryParams.getFirst("msisdn");
if(dcParam != null){
try {
return Response.status(Status.OK).entity(CountriesService.getDataDialingCode(dc)).build();
} catch (RuntimeException e) {
e.printStackTrace();
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
}
}
if(iso2Param != null){
try {
return Response.status(Status.OK).entity(CountriesService.getDataCountryCode(iso2)).build();
} catch (RuntimeException e) {
e.printStackTrace();
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
}
} ... |
Partager