users@jersey.java.net

[Jersey] Re: Rest Post Unsupported Media Type

From: peterwkc <peterapiit_at_gmail.com>
Date: Tue, 28 Jun 2011 03:12:52 -0700 (PDT)

Jakub Podlesak-2 wrote:
>
> Hi Peter,
>
> ad 1) the content-type should be set to application/xml rather than just
> xml.
> some server log snippet would also be handy to such requests
>
> ad 2) i do not quite understand the question, you are setting the order id
> on the CustOrderResource returned by the sub-locator method
> what else would you want to pass?
>
>

1.
I have set them using this annotation
@POST
  @Consumes({MediaType.WILDCARD, MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML,
    MediaType.APPLICATION_FORM_URLENCODED}) for create order function but it
just rerun unsupported media type. What wrong with it ?

2. @Path("{orderID}")
  public CustOrderResource ReadSingleCustomerOrder(@PathParam("orderID")
String orderID) {
    
    int userOrderID = Integer.parseInt(orderID);
    int myOrderID = myCustOrderDAO.count();
    
    CustOrderResource myCustorder = null;
     
    if(userOrderID > myOrderID
            || myCustOrderDAO.find(orderID) == null) {
      throw new OrderNotFoundException("Order ID Not Found");
    }

    if(!mySecurityContext.isUserInRole("admin")) {
      // Propogates to specific resource class
      myCustorder = myResourceContext.getResource(CustOrderResource.class);
      myCustorder.setOrderID(orderID);
    }
    
    return myCustorder;
  }

This function is redirect to sub resource locator based on the HTTP method
like DELETE or POST where delete will called the deleteOrder function with
the order data.
The order data where i need to pass from resource class to sub resource
locator method otherwise i cannot query the database.

Another scenario is when i update order i need the updater order data too
when the jersey servlet will call the updateOrder function.

How to retrieve the data in message body ?

Thanks.




--
View this message in context: http://jersey.576304.n2.nabble.com/Rest-Post-Unsupported-Media-Type-tp6499271p6524282.html
Sent from the Jersey mailing list archive at Nabble.com.