Hi There,

We are prototyping with Restlet JEE 2.0.1 to see how can we use the Response 
object to send some information back to the client. I see that different APIs 
are available to allow us to set the description, Throwable and attribute map 
in the status object. While when we test those APIs, we found that the client 
can only get back the Restlet defined status (ex, 
Status.SERVER_ERROR_INTERNAL),the description, Throwable and attribute map set 
by the server resource code are all lost. Can you guys explain why this is not 
working? Below is the sample code:

------ Server side ---
    @put
    public void send(DataTransporter obj)
    {
        Response response = getResponse();
        String xmlFile = obj.getXmlConfigFileName();
        if (obj.getObjList() == null || obj.getObjList().isEmpty())
        {
            getLogger().info("No object in DataTransporter.");
           response.setStatus(Status.SERVER_ERROR_INTERNAL, "No object in 
DataTransporter.");
           response.setAutoCommitting(true);
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("123", "ABC");
            response.setAttributes(map);
        }
       ...

    }

--- client side ---
ClientResource cr = new 
ClientResource("http://localhost:8182/test/objectService";);
DataTransporterResource resourceService = 
cr.wrap(DataTransporterResource.class);

        NetBackupBackupEvent obj = populateData("Host123");
        DataTransporter<NetBackupBackupEvent> transporter = new 
DataTransporter<NetBackupBackupEvent>();
       // transporter.add(obj);
        transporter.setXmlConfigFileName("test.xml");
        Representation re = null;
        try
        {
//            resourceService.send(transporter);
           re = cr.put(transporter);
        }
        catch (Exception e)
        {
            e.printStackTrace();  //To change body of catch statement use File 
| Settings | File Templates.
        }
        Response response = Response.getCurrent();
        System.out.println("Status: " + 
cr.getResponse().getStatus().getDescription());
        System.out.println("Throwable: " + 
cr.getResponse().getStatus().getThrowable());

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2942075

Reply via email to