users@jersey.java.net

GET rest service throwing exceptions

From: Saavedra, Gisella <gsaavedra_at_navis.com>
Date: Mon, 22 Jun 2009 17:55:21 -0700

 

I have the following resource method:

 

  @GET

    @Produces({"application/xml"})

    public Logs getAl() {

 

        // Verify parameters

        NodeConfig nodeConfig = ClusterNodeUtils.getNodeInfo();

 

        // Verify that current node directory path exists

        if
(!FileCompressionUtils.dirExists(nodeConfig.getNodecfgLogDirPath())) {

            throw new
RestApplicationException(Response.Status.PRECONDITION_FAILED, "Log
directory does not exist");

        }

...

}

 

At the client side, it is invoked as:

try {

String xmlResponse =
res.accept(MediaType.APPLICATION_XML_TYPE).get(String.class);

} catch (UniformInterfaceException e) {

                // log it

}

 

/////////////////////////

 

The RestApplicationException class code is:

public class RestApplicationException extends WebApplicationException {

    public RestApplicationException (Response.Status inStatus, String
inMessage) {

 
super(Response.status(inStatus).entity(inMessage).type("text/plain").bui
ld());

 

}

 

 

////////////////////

 

But at the client side, I do not get the exception thrown above. I get
the String xmlResponse = ""Log directory does not exist"

 

What do I need to do, either client or server side, to receive the
exception I threw as an exception?

 

Thanks.

 

 

 

 

Gisella Saavedra
Sr. Software Engineer
gsaavedra_at_zebra.com <mailto:gsaavedra_at_zebra.com>

        
 

1000 Broadway, Suite 150, Oakland, CA 94607 | T+1 510 267 5123 T
Main+1 510 267 5000 F+1 510 267 5100 | http://www.zebra.com/zes
<http://www.zebra.com/zes>



        

 

 






image001.gif
(image/gif attachment: image001.gif)