Differences @Get x @GET; @Post x @POST with @Path

2011-05-05 Thread Bruno Mendes
I'm developing an application where a POST to /operations will create a new 
Operation, a GET to /operations/{code} will either return the Operation in XML 
or in JSON, depending on the Header parameter Accept.

In order to achieve the path, I had to use @Path(operations) in the class 
declaration and @Path({code}) in the GET methods.

Using @Get or @Post (from org.restlet) didn't work at all. But when I changed 
it to @GET and @POST (from javax.ws) it worked as expected.

So I have three questions:

1- Is it possible to use @Get and @Post with @Path?
2- What are the differences between: @Get and @GET; and between @Post and @POST 
(because it seems using @GET and @POST I can do more things)?
3- If they have different purposes, then am I supposed to annotate my methods 
with both @Get and @GET?

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2730188package br.org.bmnds.restlet.thirdapplication;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import org.restlet.data.Form;

@Path(operations)
public class OperationServerResource {

	private static OperationDAO operationDAO = new OperationDAO();
	
	@GET
	@Path({code})
	@Produces({text/xml,application/json})
	public Operation retrieveXML(@PathParam(code) String code) {
		return operationDAO.find(code);
	}
	
	@POST
	public void handlePostJAXRS(Form form) {
		String code = form.getFirstValue(code);
		String name = form.getFirstValue(name);
		String type = form.getFirstValue(type);
		Operation operation = new Operation(code, name, OperationType.valueOf(type));
		operationDAO.save(operation);
	}
	
}


Restlet Extensions and Maven

2011-05-05 Thread Dave Muirhead
Greetings-

The Restlet JAXB extension (org.restlet.ext.jaxb) has a dependency on 
javax.xml.bind.

For folks using a downloaded Restlet full distribution, that dependency is 
satisfied by the exploded bundle shipped in the lib/javax.xml.bind_2.1 
directory.

But, for folks using Maven (or Ivy in my case), the javax-api and javax-impl 
jars that get downloaded are not OSGI bundles.

The use of the 'wrapper' style exploded OSGI bundles for dependencies looks to 
be the general approach taken for Restlet extensions (as opposed to maybe a 
bundle classpath approach).

So, is anybody who is using Maven also using any of the extensions that have 
dependencies that are not readily available in OSGI bundle form? If so, did you 
resort to OSGI bundle-izing the dependencies or is there some other better 
approach?

Thanks,

Dave

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


RE: Re: GWT 2.3

2011-05-05 Thread Mike
I am able to run the code with no issues under GWT 2.2.  The problem happens 
when I switch to GWT 2.3.  Are you sure the problem you fixed exists with GWT 
2.2?

I guess it's possible that my code takes a different path under GWT 2.2 that 
does not use Serializa​bleTypeOracleBuilder.

Thanks,
Mike

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


RE: Status code being overwritten

2011-05-05 Thread anoop kulkarni
btw the exception thats being thrown is a runtimeexception (dont know why that 
decision was made, but that's what it is)

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


RE: Re: Status code being overwritten

2011-05-05 Thread anoop kulkarni
We set the status code on the response and throw an exception. 

When the StatusFilter intercepts this response, it overrides the status code 
with 500 while keeping our original exception in place.

So the client sees our exception, but without the corresponding status code.

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


Restlet+Mule - Concurrent request results 404

2011-05-05 Thread Gaurav Gupta
Hey All,

I followed
http://www.mulesoft.org/documentation/display/RESTLET/User%27s+Guide#User%27sGuide-EmbeddingRestletsinMule

Querying http://localhost:9002 is working fine for one request. But when I
hit multiple request concurrently, most request fails with 404 status.
Although those response error code is 404 but it still contain Hello World
in response data.
So I think the requests are processed successfully but why it is returning
as 404?
I think it might be something related to connection pool.
so added following line in my mule config -

configuration 
default-threading-profile doThreading=true/
default-dispatcher-threading-profile doThreading=true
  maxBufferSize=50
threadWaitTimeout=2000 maxThreadsActive=200
  maxThreadsIdle=50
poolExhaustedAction=WAIT threadTTL=5000/
default-receiver-threading-profile doThreading=true
maxBufferSize=50
threadWaitTimeout=2000 maxThreadsActive=200
maxThreadsIdle=50
poolExhaustedAction=WAIT threadTTL=5000/
default-service-threading-profile doThreading=true
   maxBufferSize=50
   threadWaitTimeout=2000
maxThreadsActive=200 maxThreadsIdle=50
   poolExhaustedAction=WAIT
threadTTL=5000/

/configuration

But no change in its behavior.

Please help.

Thanks,
Gaurav Gupta

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

Using the simple framework in Restlet

2011-05-05 Thread Steve Ferris
Hi,

I cannot work out how to tell my standalone Restlet application to the use the 
Simple framework as it's chosen server connector. Is this some method I have to 
call or property to set?

I am using maven and have included the correct dependency. 

thanks
Steve

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


Re: Fwd: Bug in WriterRepresentation with internal connector

2011-05-05 Thread Tim Peierls
In summary, this is a reproducible bug: Using WriterRepresentation and the
internal connector with content of size  1024 in 2.1-M4 (at least) on
Windows (at least) hangs the Restlet component.

WriterRepresentation is the supertype of JacksonRepresentation, so this
means you can't use Jackson with the internal connector, at least not
reliably.

--tim
On May 2, 2011 10:43 AM, Tim Peierls t...@peierls.net wrote:
 [I already posted to the Restlet code list, but I'm posting here as well,
in
 case anyone else has noticed this and come up with workarounds.]

 I've created an issue in the issue tracker about a problem with
 WriterRepresentation, the internal connector, and large (1024) entities:

 http://restlet.tigris.org/issues/show_bug.cgi?id=1264

 The code to reproduce is here:

 http://pastebin.com/XDr36dyc

 --tim

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

Re: Restlet+Mule - Concurrent request results 404

2011-05-05 Thread Gaurav Gupta
Found the solution.
Resource bean must be scope prototype in spring context fine
refer
http://www.restlet.org/documentation/snapshot/jse/ext/org/restlet/ext/spring/SpringBeanRouter.htm

-- 
Gaurav Gupta

On Thu, May 5, 2011 at 4:43 PM, Gaurav Gupta gaurav.gu...@joshlabs.inwrote:

 Hey All,

 I followed
 http://www.mulesoft.org/documentation/display/RESTLET/User%27s+Guide#User%27sGuide-EmbeddingRestletsinMule

 Querying http://localhost:9002 is working fine for one request. But when I
 hit multiple request concurrently, most request fails with 404 status.
 Although those response error code is 404 but it still contain Hello
 World in response data.
 So I think the requests are processed successfully but why it is returning
 as 404?
 I think it might be something related to connection pool.
 so added following line in my mule config -

 configuration 
 default-threading-profile doThreading=true/
 default-dispatcher-threading-profile doThreading=true
   maxBufferSize=50
 threadWaitTimeout=2000 maxThreadsActive=200
   maxThreadsIdle=50
 poolExhaustedAction=WAIT threadTTL=5000/
 default-receiver-threading-profile doThreading=true
 maxBufferSize=50
 threadWaitTimeout=2000 maxThreadsActive=200
 maxThreadsIdle=50
 poolExhaustedAction=WAIT threadTTL=5000/
 default-service-threading-profile doThreading=true
maxBufferSize=50
threadWaitTimeout=2000
 maxThreadsActive=200 maxThreadsIdle=50
poolExhaustedAction=WAIT
 threadTTL=5000/

 /configuration

 But no change in its behavior.

 Please help.

 Thanks,
 Gaurav Gupta


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

No extra detail found in web service response entity when an error occurs

2011-05-05 Thread Simon Earnshaw
I have a restlet web service.

When the client requests some data from the web service, sometimes that data is 
missing unexpectedly so I return a 404 (maybe it should be 500) error - and I 
would like to add some extra detail along with the reponse. This would be good 
for the client application to use to diagnose problems/faults etc. Looking up 
the official documentation at Restlet, it says the following:

a description can be added to the status report to help the client understand 
the situation and correct its request if needed. For this purpose, you can 
create new instances of the Status class instead of using the constants or, 
more simply, you can use response.setStatus(Status.CLIENT_ERROR_NOT_FOUND, 
Your comment goes here).

I was expecting to see Your comment goes here somewhere in the response 
entity but there was nothing (I'm using Fiddler with IE to examine the response 
entity).

Can anyone point out what I might be doing wrong here?

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


Re: Using the simple framework in Restlet

2011-05-05 Thread Matt Kennedy
It should be as simple as having
$RESTLET_HOME/lib/org.restlet.ext.simple.jar and
$RESTLET_HOME/lib/org.simpleframework_N.N/org.simpleframework.jar on your
classpath.

On Thu, May 5, 2011 at 7:20 AM, Steve Ferris steve.fer...@forgerock.comwrote:

 Hi,

 I cannot work out how to tell my standalone Restlet application to the use
 the Simple framework as it's chosen server connector. Is this some method I
 have to call or property to set?

 I am using maven and have included the correct dependency.

 thanks
 Steve

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2730537


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

Custom Error Handling

2011-05-05 Thread Bruno Mendes
How can I provide a custom error handler for a service?

Case Study: I have this service which persists the Operation passed either by 
xml or by json. The problem is, when a malformed structure is passed, the 
server it returns a predefined error message.
@POST
@Consumes({text/xml, application/json})
public void save(Operation operation) {
operationDAO.save(operation);
}

Where should I handle the exceptions to provide a different status code other 
than 500 and custom messages.
The FAQ tells If you want a different status when an exception is thrown, you 
have to catch it manually at a lower level (inside the handle(Call) or 
handleGet|Post|etc. method of your intermediary Restlet), but following the 
pattern from the jaxrs extension example I have a Resource 
(OperationServerResource), an Application config (OperationApplication) and the 
Server (for now it only has the OperationApplication being attached, but later 
there is going to be a lot of applications). In this pattern, the only place 
where I can override the handle() is at the server, but by doing this I'll 
handle all specific exceptions from all bussiness classes (as Operation) at the 
same place ;/.
Is there a different pattern I could use or a different way to handle the 
exceptions than ovewriting the component's handle in the server?

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


Re: Custom Error Handling

2011-05-05 Thread Tim Peierls
Sometimes it seems like every tenth message to this list is asking a
variation of this question. I know that we're free to define our own
StatusService implementations, overriding getRepresentation, but wouldn't it
be nice if the *default* StatusService had support that would let us throw a
resource exception containing a Java object that was convertible to the
error representation?

throw new ResourceException(Status.CLIENT_ERROR_GONE, myGoneErrorObject,
initCause);
// myGoneErrorObject converted by StatusService/ConvertService to error
representation

It would be particularly useful to be able to specific a Freemarker template
and data model to supply HTML error representations.

--tim


On Thu, May 5, 2011 at 1:50 PM, Bruno Mendes b.mende...@gmail.com wrote:

 How can I provide a custom error handler for a service?

 Case Study: I have this service which persists the Operation passed either
 by xml or by json. The problem is, when a malformed structure is passed, the
 server it returns a predefined error message.
@POST
@Consumes({text/xml, application/json})
public void save(Operation operation) {
operationDAO.save(operation);
}

 Where should I handle the exceptions to provide a different status code
 other than 500 and custom messages.
 The FAQ tells If you want a different status when an exception is thrown,
 you have to catch it manually at a lower level (inside the handle(Call) or
 handleGet|Post|etc. method of your intermediary Restlet), but following the
 pattern from the jaxrs extension example I have a Resource
 (OperationServerResource), an Application config (OperationApplication) and
 the Server (for now it only has the OperationApplication being attached, but
 later there is going to be a lot of applications). In this pattern, the only
 place where I can override the handle() is at the server, but by doing this
 I'll handle all specific exceptions from all bussiness classes (as
 Operation) at the same place ;/.
 Is there a different pattern I could use or a different way to handle the
 exceptions than ovewriting the component's handle in the server?

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2731311


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