[Resteasy-users] What u want in Restful Java 2 Book?

2012-08-29 Thread Bill Burke
Please comment on blog.

http://bill.burkecentral.com/2012/08/29/what-should-be-in-next-restful-java-book/

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Consumes json multiple parameters question

2012-08-29 Thread Bill Burke
#1 Doesn't fit with MessageBodyReader/Writer pattern
#2  Encourages RPC designs.  We're supposed to be doing REST which is 
message-based.

On 8/29/2012 9:17 AM, Chris Bredesen wrote:
> I haven't thought it through fully but this seems like a very handy
> feature. Here's where someone shows why it won't/can't work...
>
> -CB
>
> On 08/29/2012 08:49 AM, Bill Burke wrote:
>> You can only have one argument to a method that represents the HTTP
>> message body.
>>
>> On 8/29/2012 7:37 AM, Reik Schatz wrote:
>>> Hi, I am wondering if the following is possible since I am having some
>>> problems getting it to work. Lets say you have a service method:
>>>
>>> @PUT
>>> @Path("/store")
>>> @Consumes(MediaType.APPLICATION_JSON)
>>> void store(String user, int score);
>>>
>>> and you run the following command:
>>>
>>> curl -i -v -H "Content-Type: application/json" -X PUT -d '{"user": "me",
>>> "score": 10}' http://localhost:8080/store
>>>
>>> I was expecting that the json content is unmarshalled and mapped to the
>>> 2 primitive arguments, which isn't happening. The immediate problem
>>> might however be unrelated. The first Provider that is being used is
>>> called StringTextStar which reads everything from the InputStream, then
>>> when the ResteasyJacksonProvider is ran, there is no more to read and I
>>> receive java.io.EOFException: No content to map to Object due to end of
>>> input, which might be another problem.
>>>
>>> reik
>>>
>>>
>>> --
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond. Discussions
>>> will include endpoint security, mobile security and the latest in malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>>
>>>
>>>
>>> ___
>>> Resteasy-users mailing list
>>> Resteasy-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>>
>>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Manually Unmarshalling Form Data

2012-08-29 Thread Bill Burke


On 7/5/2012 6:50 PM, Cody Lerum wrote:
> I'm currently using the @Form functionality to handle the
> unmarshalling of form data sent via a cross-domain ajax post
>
>   @Path("/add")
>   @POST
>   @Produces("application/json")
>   @Consumes("application/x-www-form-urlencoded")
>   public Response add(@Form MyForm form) { ... }
>
> This works great except for when coming from Internet Explorer which
> has to be a XDomainRequest and that only supports sending with
> content-type text/plain.
>
> I can obviously create another method to handle this request which is
> receiving valid form data just with the wrong content-type
>
> @Path("/add")
> @POST
> @Produces("application/json")
> @Consumes("text/plain")
> public Response add(String data) { ... }
>
> However at this point I have to manually parse the data and set it
> field by field into my object.
>
> 1. Is there anyway to force the first method to process the the
> request data regardless of the received content-type?
>
> 2. If that isn't possible, is there a way I can manually call an
> internal RESTeasy function to map the String data from my second
> method to a specified class with @FormParam variables.
>


You can't really re-use public Response add(@Form MyForm form) method. 
There's a couple things you could do.  You could inject a Providers 
reference and change the media type:

@POST
@Consumes("text/plain")
public Response add(@Context Providers providers, InputStream content) {

MessageBodyReader reader = 
providers.getMessageBodyReader(MultivaluedMap.class, null, null, new 
MediaType("application/x-www-form-urlencoded");

MultivaluedMap formParams = reader.readFrom(...);
...
}

You could also write a specific MessageBodyReader for your MyForm class 
for text/plain formats.

Bill

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Consumes json multiple parameters question

2012-08-29 Thread Chris Bredesen
I haven't thought it through fully but this seems like a very handy 
feature. Here's where someone shows why it won't/can't work...

-CB

On 08/29/2012 08:49 AM, Bill Burke wrote:
> You can only have one argument to a method that represents the HTTP
> message body.
>
> On 8/29/2012 7:37 AM, Reik Schatz wrote:
>> Hi, I am wondering if the following is possible since I am having some
>> problems getting it to work. Lets say you have a service method:
>>
>> @PUT
>> @Path("/store")
>> @Consumes(MediaType.APPLICATION_JSON)
>> void store(String user, int score);
>>
>> and you run the following command:
>>
>> curl -i -v -H "Content-Type: application/json" -X PUT -d '{"user": "me",
>> "score": 10}' http://localhost:8080/store
>>
>> I was expecting that the json content is unmarshalled and mapped to the
>> 2 primitive arguments, which isn't happening. The immediate problem
>> might however be unrelated. The first Provider that is being used is
>> called StringTextStar which reads everything from the InputStream, then
>> when the ResteasyJacksonProvider is ran, there is no more to read and I
>> receive java.io.EOFException: No content to map to Object due to end of
>> input, which might be another problem.
>>
>> reik
>>
>>
>> --
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>
>>
>>
>> ___
>> Resteasy-users mailing list
>> Resteasy-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>
>

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Consumes json multiple parameters question

2012-08-29 Thread Bill Burke
You can only have one argument to a method that represents the HTTP 
message body.

On 8/29/2012 7:37 AM, Reik Schatz wrote:
> Hi, I am wondering if the following is possible since I am having some
> problems getting it to work. Lets say you have a service method:
>
> @PUT
> @Path("/store")
> @Consumes(MediaType.APPLICATION_JSON)
> void store(String user, int score);
>
> and you run the following command:
>
> curl -i -v -H "Content-Type: application/json" -X PUT -d '{"user": "me",
> "score": 10}' http://localhost:8080/store
>
> I was expecting that the json content is unmarshalled and mapped to the
> 2 primitive arguments, which isn't happening. The immediate problem
> might however be unrelated. The first Provider that is being used is
> called StringTextStar which reads everything from the InputStream, then
> when the ResteasyJacksonProvider is ran, there is no more to read and I
> receive java.io.EOFException: No content to map to Object due to end of
> input, which might be another problem.
>
> reik
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] Consumes json multiple parameters question

2012-08-29 Thread Reik Schatz
Hi, I am wondering if the following is possible since I am having some
problems getting it to work. Lets say you have a service method:

@PUT
@Path("/store")
@Consumes(MediaType.APPLICATION_JSON)
void store(String user, int score);

and you run the following command:

curl -i -v -H "Content-Type: application/json" -X PUT -d '{"user": "me",
"score": 10}' http://localhost:8080/store

I was expecting that the json content is unmarshalled and mapped to the 2
primitive arguments, which isn't happening. The immediate problem might
however be unrelated. The first Provider that is being used is
called StringTextStar which reads everything from the InputStream, then
when the ResteasyJacksonProvider is ran, there is no more to read and I
receive java.io.EOFException: No content to map to Object due to end of
input, which might be another problem.

reik
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users