1

I created a web services that needs to get a string with blanks, commas, parenthesis and other special characters. I would like pass it as PathParam but I wasn't able to manage this string.

The string that I want to manage is similar to the follow:

POLYGON((9.5 44.6, 12.5 44.6, 12.5 42.0, 9.5 42.0, 9.5 44.6))

My method is:

@POST
@Path("/j_update_spi/{step}/{srid}/{polygon:.+}")
public Response updateSPI(@PathParam("step") String step,
                          @PathParam("srid") String srid,
                          @PathParam("polygon") String polygon){
...
}

i tried to set ".+" for polygon parameter but it doesn't work (i also tried to use .*).

If I call this service the method doesn't start.

user1803551
  • 12,965
  • 5
  • 47
  • 74
N3tMaster
  • 398
  • 3
  • 13

1 Answers1

0

I solved my problem: I changed the PathParam "polygon" and made it as optional. Then I changed regex rules into polygon PathParam.

@POST
@Path("/update_spi/{step}/{srid}{polygon:(/polygon/.+?)?}")
public Response updateSPI(@PathParam("step") String step,
                          @PathParam("srid") String srid,
                          @PathParam("polygon") String polygon)

in order to extract the string that defines my WKT Polygon I used split method:

if(!polygon.matches(""))
     polygon = polygon.split("/")[2];
N3tMaster
  • 398
  • 3
  • 13