RE: Re: Paging resources in GWT
Thanks for your answers. I will rethink the implementation for the paging in our resources. - Harald -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642446
RE: Re: PROPFIND doesn't work anymore after the switch from 2.0RC4 to 2.0.0
Hello Fabian, I guess the converter service is messing a little bit here. Can you try with the following signature? @Propfind public Representation propfind(String text) throws ResourceException I have a look at your code. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642426
RE: Warnings from Finder?
Hello Alex, this warning should happen in very specific cases, when the resource cannot be instantiated. Actually, if you have implemented the default constructor. I think you can move this code to the doInit() method. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642425
Re: PROPFIND doesn't work anymore after the switch from 2.0RC4 to 2.0.0
Hello Thierry, the signature of the PROPFIND handler is this: @Propfind public Representation propfind() throws ResourceException I don't remember if I've tried (I'll do it later and inform here) with @Propfind public Representation propfind(Variant variant) throws ResourceException You can find the full code for the server resource at: http://trac.calenco.com/browser/branches/stable/src/com/calenco/resource/workspace/ContentResource.java and the @Propfind annotation definition at: http://trac.calenco.com/browser/branches/stable/src/com/calenco/dav/annotation/Propfind.java (shamesly modelled after the Restlet annotations, of course...) On Mon, Aug 2, 2010 at 5:43 PM, Thierry Boileau wrote: > Hello Fabian, > > I wonder what is the signature of the Java method that supports the > "propfind" method, especially the parameters. > > Best regards, > Thierry Boileau > > >> Hello, >> >> first things first: Congratulations for the release of Restlet 2.0.0! >> >> >> I've switched from 2.0RC4 to 2.0.0 and all PROPFIND requests (the >> handler is implemented with a custom @Propfind annotation, modeled >> after the standard Restlet annotations, I've also made such >> annotations for LOCK and UNLOCK, the other WebDAV verbs I needed, and >> they are working fine, only PROPFIND is failing) are being answered >> with 405 (No Such Method), so WebDAV support in my app is broken with >> 2.0.0 (worked fine with 2.0RC4). >> >> My server resource class has this on its init() method: >> >> getAllowedMethods().add(Method.PROPFIND); >> getAllowedMethods().add(Method.LOCK); >> getAllowedMethods().add(Method.UNLOCK); >> >> And indeed an OPTIONS request to the resource returns all supported >> methods fine: >> >> fab...@monster:~$ curl -i -uad...@calenco.com:admin -XOPTIONS >> http://localhost:9000/workspaces/WKSP/content >> HTTP/1.1 200 OK >> Connection: close >> Date: Tue, 20 Jul 2010 16:49:24 GMT >> Accept-Ranges: bytes >> Allow: LOCK, GET, PUT, DELETE, UNLOCK, OPTIONS, POST, PROPFIND >> Server: Restlet-Framework/2.0.0 >> Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept >> DAV: 1 >> MS-Author-Via: DAV >> Content-Length: 1 >> Content-Type: text/plain; charset=UTF-8 >> >> fab...@monster:~$ >> >> I've added a log trace to the PROPFIND handler, like this: >> >> �...@propfind >> public Representation propfind() throws ResourceException { >> getLogger().info("Handling PROPFIND Request..."); >> >> But I'm not seeing the call in the logs, when I try to connect with >> cadaver (a CLI WebDAV client): >> >> Jul 20, 2010 1:51:48 PM com.calenco.resource.workspace.ContentResource >> options >> INFO: OPTIONS request processed in 0.003 sec. >> Jul 20, 2010 1:51:48 PM org.restlet.engine.log.LogFilter afterHandle >> INFO: 2010-07-20 13:51:48 0:0:0:0:0:0:0:1 ad...@calenco.com >> - 9000 OPTIONS /workspaces/WKSP/content/ - 200 >> 1 010 http://localhost:9000 cadaver/0.23.3 >> neon/0.29.0 - >> Jul 20, 2010 1:51:48 PM org.restlet.engine.log.LogFilter afterHandle >> INFO: 2010-07-20 13:51:48 0:0:0:0:0:0:0:1 ad...@calenco.com >> - 9000 PROPFIND /workspaces/WKSP/content/ - >> 405323 288 5 http://localhost:9000 cadaver/0.23.3 >> neon/0.29.0 - >> >> The funny thing is that it seems the ContentResource (my class) is not >> handling the PROPFIND and that's why it may be failing (also notice >> the 405323, which should be 405 323, where 405 is the HTTP resposne >> code). >> >> Any ideas? Thanks in advance. >> >> -- >> Fabián Mandelbaum >> IS Engineer >> >> -- >> >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2635851 > > -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642424
Re: amultipart/form-data with an uploaded file not able to read
Hello Pracheer, at this time multipart entities are not supported by the framework ( http://restlet.tigris.org/issues/show_bug.cgi?id=71). You can still use the fileupload extension as illustrated here: http://wiki.restlet.org/docs_1.1/42-restlet.html. Best regards, Thierry Boileau This is my html form POSTing a file and some form data to the server: > > http://localhost:8383/compareviews3/sites/sitename5/products/product2/"; > enctype="multipart/form-data" method="post" name="newImage"> id="command" name="command" type="hidden" value="newImageValue"/> id="imgFile" name="imgFile" type="file"/> type="submit">Submit > > > When I try to create a form object of the entity received > Form form = new Form(entity) > > This is the error I get: > java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape > (%) pattern >at java.net.URLDecoder.decode(Unknown Source) >at org.restlet.data.Reference.decode(Reference.java:165) >at com.noelios.restlet.util.FormUtils.create(FormUtils.java:75) >at > com.noelios.restlet.util.FormReader.readNextParameter(FormReader.java:245) >at > com.noelios.restlet.util.FormReader.addParameters(FormReader.java:129) >at com.noelios.restlet.util.FormUtils.parse(FormUtils.java:240) >at com.noelios.restlet.Engine.parse(Engine.java:979) >at org.restlet.data.Form.(Form.java:84) >at org.restlet.data.Form.(Form.java:133) >at > restlet.resources.NodeResource.acceptRepresentation(NodeResource.java:1076) > ... > > But I am able to receive the input file at the server end. I am having > problem reading only the form input sent along with the file. > > Any clues/hints/solutions?? > > Thanks in advance > Pracheer Gupta > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2634012 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2641923
Re: PROPFIND doesn't work anymore after the switch from 2.0RC4 to 2.0.0
Hello Fabian, I wonder what is the signature of the Java method that supports the "propfind" method, especially the parameters. Best regards, Thierry Boileau Hello, > > first things first: Congratulations for the release of Restlet 2.0.0! > > > I've switched from 2.0RC4 to 2.0.0 and all PROPFIND requests (the > handler is implemented with a custom @Propfind annotation, modeled > after the standard Restlet annotations, I've also made such > annotations for LOCK and UNLOCK, the other WebDAV verbs I needed, and > they are working fine, only PROPFIND is failing) are being answered > with 405 (No Such Method), so WebDAV support in my app is broken with > 2.0.0 (worked fine with 2.0RC4). > > My server resource class has this on its init() method: > > getAllowedMethods().add(Method.PROPFIND); > getAllowedMethods().add(Method.LOCK); > getAllowedMethods().add(Method.UNLOCK); > > And indeed an OPTIONS request to the resource returns all supported > methods fine: > > fab...@monster:~$ curl -i -uad...@calenco.com:admin -XOPTIONS > http://localhost:9000/workspaces/WKSP/content > HTTP/1.1 200 OK > Connection: close > Date: Tue, 20 Jul 2010 16:49:24 GMT > Accept-Ranges: bytes > Allow: LOCK, GET, PUT, DELETE, UNLOCK, OPTIONS, POST, PROPFIND > Server: Restlet-Framework/2.0.0 > Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept > DAV: 1 > MS-Author-Via: DAV > Content-Length: 1 > Content-Type: text/plain; charset=UTF-8 > > fab...@monster:~$ > > I've added a log trace to the PROPFIND handler, like this: > >@Propfind >public Representation propfind() throws ResourceException { >getLogger().info("Handling PROPFIND Request..."); > > But I'm not seeing the call in the logs, when I try to connect with > cadaver (a CLI WebDAV client): > > Jul 20, 2010 1:51:48 PM com.calenco.resource.workspace.ContentResource > options > INFO: OPTIONS request processed in 0.003 sec. > Jul 20, 2010 1:51:48 PM org.restlet.engine.log.LogFilter afterHandle > INFO: 2010-07-2013:51:480:0:0:0:0:0:0:1 ad...@calenco.com > - 9000OPTIONS /workspaces/WKSP/content/ - 200 > 1 010 http://localhost:9000 cadaver/0.23.3 > neon/0.29.0 - > Jul 20, 2010 1:51:48 PM org.restlet.engine.log.LogFilter afterHandle > INFO: 2010-07-2013:51:480:0:0:0:0:0:0:1 ad...@calenco.com > - 9000PROPFIND/workspaces/WKSP/content/ - > 405323 288 5 http://localhost:9000 cadaver/0.23.3 > neon/0.29.0 - > > The funny thing is that it seems the ContentResource (my class) is not > handling the PROPFIND and that's why it may be failing (also notice > the 405323, which should be 405 323, where 405 is the HTTP resposne > code). > > Any ideas? Thanks in advance. > > -- > Fabián Mandelbaum > IS Engineer > > -- > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2635851 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2641929
Android client : how to add cookies ?
Hello ! Salut les gars ! I am currently trying to do a nice mix : GAE on server side, GWT and Android for the client side, with users authenticated using their Google Accounts. So far so good, I've been able to use GAE / GWT with Restlet, as well as to authenticate on GAE from Android with a Google Account. To authenticate my requests, all I need to do is to add a cookie to the the request. Which I know how to do on an HttpClient. Here is how I configure my Android client : * List converters = Engine.getInstance().getRegisteredConverters(); converters.add(new JacksonConverter()); ClientResource clientResource = new ClientResource("https://XXX";); TagResource tagRes = clientResource.wrap(TagResource.class); I am quite stuck here, since I use all the "magic" found in the docs, I'm definitely lost with the internals of Restlet, although I've really tried to go deep in the code / the docs . I tried to build a HttpClientHelper, start it, get its HttpClient, cast it to DefaultHttpClient, and change the cookie store : didn't seem to work. BTW, HttpClientHelper needs a Client in its constructor, and I don't quite understand how this works. Here is my solution : Client restClient = new Client(Arrays.asList(Protocol.HTTP, Protocol.HTTPS)); HttpClientHelper httpClientHelper = new HttpClientHelper(restClient); httpClientHelper.start(); BasicCookieStore cookieStore = new BasicCookieStore(); cookieStore.addCookie(cookies[0]); ((DefaultHttpClient) httpClientHelper.getHttpClient()).setCookieStore(cookieStore); Engine.getInstance().getRegisteredClients().add(httpClientHelper); I hope you'll be able to help me, and maybe guide me through the docs. I just met so many pages with "TODO"'s inside that I almost got mad... Oh, and BTW : there is still a bug in the JacksonConverter, that throws an Exception when a method returns a void type (Jackson shouldn't have to convert anything in those cases). Thanks, and best regards. Piwaï -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2641943
Deserialization issue !!
Hi Techies, I have an issue with deserialization issue in my Restlet. My code is below, I have an interface , public interface MiddleWare extends Serializable{ @Put public void addGroup(String name); @Get public ObjectRepresentation> getUserList(); } My server side code is : === public class ReceiveRequest extends Application{ @Override public Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/start", Resource.class); return router; } } The Resource class is : == public class Resource extends ServerResource implements MiddleWare, Serializable{ private static final long serialVersionUID = 6705338955844911422L; @Put public void addGroup(String name) { // Add the Data in to DB } @Get public ObjectRepresentation> getUserList() { ObjectRepresentation> obj = null; List list = new ArrayList(); // Getting the data from DB and putting into Array List try { obj = new ObjectRepresentation((ArrayList) list,MediaType.APPLICATION_JAVA_OBJECT); } catch (IllegalArgumentException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println("The List is ::"+list.size()); return obj; } } And my client side code is :: = ClientResource clientResource = new ClientResource("http://springdboperation.com:8080/InvokeRestletWS/start";); MiddleWare testResource = clientResource.wrap(MiddleWare.class); testResource.addGroup("Thangavel"); // This method invoking and adding the values in DB // But while getting the List from DB am using the following class and its throwing null exception. ObjectRepresentation> objec = new ObjectRepresentation>(testResource.getUserList()); = Any idea to get the Array list from the server through interface with good practice.. Thanks in Advance.. -- Thangavel -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Deserialization-issue-tp5367438p5367438.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642245
RE: Correct way to use android ClientResource
I've traced further into the code and it seems to be the BaseHelper class that is creating a controller service and worker service. This happens for each new clientresource object. I currently have a clientresource object for each of my resources, is this the right way to go about it or should I be sharing one clientresource or maybe using the lower level client class?? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642256
BundleResource Loader for use in OSGI
Created a simple BundleResourceClientHelper for use in an OSGI environment. It's probably ugly, but wanted to share it anyway. Start code public class BundleResourceClientHelper extends LocalClientHelper { public static final Protocol BUNDLERESOURCE = new Protocol("bundleresource","BUNDLERESOURCE", "OSGI Bundle Resource", Protocol.UNKNOWN_PORT); public BundleResourceClientHelper(Client client) { super(client); getProtocols().add(BUNDLERESOURCE); } @Override protected void handleLocal(Request request, Response response, String decodedPath) { String scheme = request.getResourceRef().getScheme(); if(BUNDLERESOURCE.getSchemeName().equalsIgnoreCase(scheme)) { handleFile(request,response); } else { throw new IllegalArgumentException("Protocol " + scheme + " not supported, only BUNDLERESOURCE is supported"); } } private void handleFile(Request request, Response response) { if(Method.GET.equals(request.getMethod()) || Method.HEAD.equals(request.getMethod())) { handleGet(request,response); } else { response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); response.getAllowedMethods().add(Method.GET); response.getAllowedMethods().add(Method.HEAD); } } private void handleGet(Request request, Response response) { try { String path = request.getResourceRef().getPath(); URL url = new URL(request.getResourceRef().toString()); Representation output = new InputRepresentation(url .openStream(), getMetadataService() .getDefaultMediaType()); output.setLocationRef(request.getResourceRef()); output.setModificationDate(new Date()); // Update the expiration date long timeToLive = getTimeToLive(); if (timeToLive == 0) { output.setExpirationDate(null); } else if (timeToLive > 0) { output.setExpirationDate(new Date(System .currentTimeMillis() + (1000L * timeToLive))); } // Update the metadata based on file extensions String name = path.substring(path.lastIndexOf('/') + 1); Entity.updateMetadata(name, output, true, getMetadataService()); // Update the response response.setEntity(output); response.setStatus(Status.SUCCESS_OK); } catch(Exception e) { response.setStatus(Status.CLIENT_ERROR_NOT_FOUND); } } } = End code = Usage: Step 1: enable the client helper in the restlet engine: Engine.getInstance().getRegisteredClients().add(new BundleResourceClientHelper(null)); Step 2: enable the protocol on your component: component.getClients().add(BundleResourceClientHelper.BUNDLERESOURCE); Step 3: call a resource from your (running) bundle: new Directory(getContext(), new Reference(getClass().getClassLoader().getResource("/www"))); It's probably already done, but I could not find it anyware. Note: some kind of OSGI scheme notation could be used with some small modifications -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642292
Re: Paging resources in GWT
On 03/08/10 15:35, Harald Pehl wrote: > I thought using query parameters too, but decided against it, because it > prevents caching of the resources. I'd say you're more likely to have problems with caching if you use a 'Range' header with a custom range unit than with a "normal" request with query parameters. Best wishes, Bruno. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642370
RE: Re: Paging resources in GWT
Harald Pehl wrote: > > I thought using query parameters too, but decided against it, because it > prevents caching of the resources. > Why and where? Query parameters are used for non-hierarchical parts of the URI such as pagination information. The query is just as integral to the identifier as any other part and an HTTP cache can't ignore the request because it doesn't like some part of the URI. Webbrowser caches certainly don't care and will cache the content for any URL with or without query part. Web crawler like the one Google uses might decide not to index content when the URI of a link contains query parameters but that's not a cache. -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Paging-resources-in-GWT-tp5368360p5368680.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642354
RE: Re: Paging resources in GWT
I thought using query parameters too, but decided against it, because it prevents caching of the resources. What really would help is a way to set header values in GWT. For that the relevant code seems to be hidden behind helpers and adapters. - Harald -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642349
Re: Paging resources in GWT
On 03/08/10 14:36, Harald Pehl wrote: > In our current project we have lots of resources which return a subset of > bigger datasets. For that the paging information is provided as part of the > URL: > > //{offset}/{limit}[/{sortBy}[/{sortDirection}]] > > [] parts are optional. So valid URLs are > /customers/0/50 > /customers/0/50/name > /customers/0/50/createdAt/desc > > This works perfectly up to the fact that lots of request attributes are > occupied. For example we cannot map the URL "/customers/orders/{orderId}", > because it is already used for "/customers/{offset}/{limit}. Perhaps you could use the query part for these things: /customers/?offset=50&limit=20&sortBy=name&sortDirection=asc I think this might help make the implementation easier on both sides. Best wishes, Bruno. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642347
Paging resources in GWT
In our current project we have lots of resources which return a subset of bigger datasets. For that the paging information is provided as part of the URL: //{offset}/{limit}[/{sortBy}[/{sortDirection}]] [] parts are optional. So valid URLs are /customers/0/50 /customers/0/50/name /customers/0/50/createdAt/desc This works perfectly up to the fact that lots of request attributes are occupied. For example we cannot map the URL "/customers/orders/{orderId}", because it is already used for "/customers/{offset}/{limit}. As an alternative I like to provide the paging information using the range header: Range: items={offset}-{lastIndex} For more information see discussions at http://stackoverflow.com/questions/924472/paging-in-a-rest-collection and http://docs.dojocampus.org/dojox/data/JsonRestStore#paging. What I lack is a possibility to set this kind of header information in GWT. There's the method "ClientResource.setRanges()", but it generates the range header using a hardcoded "bytes=..." value, which I don't want to use. Is there a way to set custom HTTP headers in GWT? Another more compliant solution would be to include some kind of unit in the Range class. This unit would be "bytes" by default and is used by the RangeWriter when generating the header value. - Harald -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2642337