Is Representation in acceptRepresentation == Request.getEntity() ?

2009-08-04 Thread Paul J. Lucas
If I am implementing: public void acceptRepresentation( Representation rep ) { // ... } Is using that rep exactly the same as if I had instead done: Representation rep1 = getRequest().getEntity(); ? Is the rep being passed to acceptRepresentation() just

Form parsing doesn't work

2009-02-18 Thread Paul J. Lucas
I have a bit of code that processes a multipart/form-data form. I'm sending a test request using curl, e.g.: curl -v -F from=paul%40lucasmail.org http://localhost:8182/foo; I have code that parses the form that starts off with: final MediaType mediaType =

ERROR: 'Broken pipe'

2008-11-17 Thread Paul J. Lucas
I've been seeing a lot of: ERROR: 'Broken pipe' Exception intercepted @ HttpServerConverter.commit lately. What exactly does it mean? How can I print out the exception? And possible how to debug this? I'm using Restlet 1.0.9. - Paul

Re: Knowing if a client disconnected?

2008-08-13 Thread Paul J. Lucas
On Aug 13, 2008, at 9:53 AM, Jerome Louvel wrote: If the socket is broken or was closed by the client while the response is written, you won't be able to restore it. However, you can log the fact the you got this request from this client and wait for the client to retry its request. OK,

Re: Knowing if a client disconnected?

2008-08-13 Thread Paul J. Lucas
On Aug 13, 2008, at 10:26 AM, Jerome Louvel wrote: The closest you'll find in the Restlet API is the org.restlet.service.ConnectorService class that has two callback methods: - beforeSend(Representation entity) - afterSend(Representation entity) Maybe we could introduce a new call-back

Knowing if a client disconnected?

2008-08-12 Thread Paul J. Lucas
Suppose I have a service that takes some time to compute the response to. Further suppose that a client connects but then disconnects prematurely for whatever reason either before I start or while I am returning a response. Is there any way to know if the client is really still there

Any interest in a DTO class?

2008-08-07 Thread Paul J. Lucas
I wanted a simple way to get the values of request parameters into an Object. I've implemented a DTO (Data Transfer Object) class that can be used for this. Suppose you want to implement a query request. You could do something like: public class QueryDTO extends DTO {

Re: Hanging on ServerSocket.accept()

2008-07-07 Thread Paul J. Lucas
On Jul 4, 2008, at 3:57 AM, Jerome Louvel wrote: What do you mean by launching 1/10 times? I mean that the problem only manifests immediately after launch (if it manifests at all). The problem never manifests if the software has been running OK for a while (meaning it has been servicing

Re: Series.getValues()

2008-03-24 Thread Paul J. Lucas
On Mar 23, 2008, at 10:50 AM, Jerome Louvel wrote: Paul, the Series class address the lack of a structure maintaining a list of named entries. There is no reusable Parameter class (name, value pair) in the JDK. Only the Map.EntryK,V interface comes close to it. Having just a ListParameter

Re: Series.getValues()

2008-03-22 Thread Paul J. Lucas
On Mar 22, 2008, at 4:21 AM, Stephan Koops wrote: is it necessary to use the legacy datatype array? Since when is an array a legacy datatype? (If this were C++ instead of Java, that question would have more merit.) I think never the Series deals with arrays. What about returning

Re: Series.getValues()

2008-03-22 Thread Paul J. Lucas
On Mar 22, 2008, at 11:16 AM, Stephan Koops wrote: Since we have java.util.List. Ok, sometime it is useful to ue arrays, but IMO in the most cases the list is the better solution. Typically you collect the result in a List, because you don't know the result size. Than you perhaps convert

Series.getValues()

2008-03-20 Thread Paul J. Lucas
Sorry if this is a duplicate, but I never say my original message echo to the list. Begin forwarded message: Date: March 19, 2008 4:19:32 PM PDT To: discuss@restlet.tigris.org Subject: Series.getValues() This method, as written in Restlet 1.0.8, specifically this variant:

Re: Root URIs under Windows

2008-03-10 Thread Paul J. Lucas
On Mar 10, 2008, at 1:45 AM, Thierry Boileau wrote: I've tested this code below with both Restlet 1.1 (snapshot) and Restlet 1.0.8 and it works. Could you tell us more about your code? I have my own classes derived from Directory and DirectoryResource. I override

Root URIs under Windows

2008-03-07 Thread Paul J. Lucas
Does anybody use Restlet under Windows? I want my server's root URI to be a directory like: C:\Documents and Settings\pjl\My Documents\My Pictures\ That's held in a File variable. I convert that to a URI then to a String like: String rootURI = rootDir.toURI().toString();

Re: Root URIs under Windows

2008-03-07 Thread Paul J. Lucas
On Mar 7, 2008, at 5:12 PM, cleverpig wrote: public Restlet createRoot(){ final String DIR_ROOT_URI=file:///E:/eclipse3.1RC3/workspace/RestletPractice/static_files/ ; Yes, I already know how to do the code. That's not my question. The differences between your

Restlet vs. Resource

2008-02-08 Thread Paul J. Lucas
Is there a guideline when one should extend Restlet vs. extens Resource? My rationalization is that: if X represents some kind of physical resource, the one should extend Resource; if X represents some kind of service, e.g., a search service, then one should extend Restlet. Opinions? -

Status class should have a Throwable field

2008-01-26 Thread Paul J. Lucas
I would like to be able to have code like: try { // ... } catch ( SomeException e ) { response.setStatus( CLIENT_ERROR_BAD_REQUEST, e ); } That is that you can pass a Throwable to setStatus() and that the Status class have the additional

Re: Status class should have a Throwable field

2008-01-26 Thread Paul J. Lucas
OK, fine: then simply add a constructor that takes a Throwable as well as a getThrown() method. Status can stay immutable. - Paul On Jan 26, 2008, at 1:06 PM, Stephan Koops wrote: Hello Paul, if I understood you right, than you want to add method to the class Status to save the

Re: Directory redirection issues

2008-01-21 Thread Paul J. Lucas
On Jan 21, 2008, at 1:32 PM, Jerome Louvel wrote: 1. How do I turn directory redirection off? Specifically, if the request refers to a directory and the URI doesn't end in '/', it's OK for the server to add the '/' internally for processing, but I don't want it to issue a 303 response.

Changing the root URI

2008-01-17 Thread Paul J. Lucas
So I create a Router, create some Directory instances with a given rootURI, and attach them to the router. At some later time, I want to change what the rootURI is globally while the server is running. In Directory, rootRef is private and there's no setRootRef() method. Why not?

Re: Bad implementation of Status error checking

2008-01-16 Thread Paul J. Lucas
Also, it seems that isSuccess() is wrong. In reading RFC 2616, 1xx and 3xx codes are not errors, so they should be considered success codes, no? - Paul On Jan 16, 2008, at 10:09 AM, Paul J. Lucas wrote: What if I want to make up my own Status codes? The isSuccess() and is*Error

Re: Aborting request in Filter

2008-01-13 Thread Paul J. Lucas
Sorry for not commenting earlier, but Anyway, in thinking about this more, I don't think a filter should have any knowledge of its next filter. When a request is received, the engine should have a list of filters, i.e., the list itself should be external to all the filters. So,

Re: Shutting down a server

2008-01-10 Thread Paul J. Lucas
Well, I just tried calling System.exit(0) and nothing happens: the process doesn't exit. FYI: I'm using the Simple HTTP server. There are a bunch of threads stuck in wait(). How can I shutdown the server and cause the process to exit? - Paul On Jan 9, 2008, at 11:43 PM, Paul J. Lucas

Re: Aborting request in Filter

2008-01-10 Thread Paul J. Lucas
Well, if you want to post-process a request in error, you need to distinguish that case from the case where you don't want to post- process in error. Another problem is that the current doHandle() calls next.handle() and that doesn't return a boolean to indicate whether to do post-

Re: Shutting down a server

2008-01-10 Thread Paul J. Lucas
gracefully? - Paul On Jan 10, 2008, at 5:31 AM, Kevin Conaway wrote: Bug the Simple developers. I am absolutely astonished that they don't provide a clean way to shut down their server. On Jan 10, 2008 2:59 AM, Paul J. Lucas [EMAIL PROTECTED] wrote: Well, I just tried calling System.exit

Re: Aborting request in Filter

2008-01-10 Thread Paul J. Lucas
By the way, in the doHandle() method, if there isn't a next Restlet, the method sets the response to CLIENT_ERROR_NOT_FOUND. Shouldn't that be SERVER_ERROR_INTERNAL because the programmer goofed by not setting a next Restlet? - Paul

Aborting request in Filter

2008-01-09 Thread Paul J. Lucas
If I write my own filter and use its beforeHandler(), I would like, upon some catastrophe, to abort the entire request and return some client error code. Unfortunately, it doesn't appear that the API for Filter allows aborting a request. True? This is another good case for using

Shutting down a server

2008-01-09 Thread Paul J. Lucas
When I start my server, I have: component = new Component(); // ... component.start(); To shutdown a server, I assume I do: component.stop(); However, the process doesn't stop. Should I then simply do: System.exit( 0 ); ? - Paul

Re: The alphanum algorithm

2007-12-19 Thread Paul J. Lucas
On Dec 19, 2007, at 8:57 AM, Jerome Louvel wrote: However, there appear to be three authors/contributors, so we would need to get the agreement and JCA of all of them which complicates things a bit. Given the algorithm description in English, just write the code yourself from scratch and

Re: The alphanum algorithm

2007-12-19 Thread Paul J. Lucas
On Dec 19, 2007, at 11:13 AM, Rob Heittman wrote: I have concerns about doing an independent implementation because it would likely bear substantial resemblance to yours. As long as you do a clean room implementation, i.e., you'd swear under oath that you didn't look at the original code,

Limiting threads

2007-12-17 Thread Paul J. Lucas
Is it possible to limit the number of threads that Restlet uses/spawns in servicing requests? - Paul

Restlet and Flickr

2007-12-05 Thread Paul J. Lucas
Has anybody done a Flickr client using Restlet? If so, details appreciated. Or, failing that, being pointed in the right direction on how to do it (what classes to derive from) would be good. I've been looking at the Restlet code and the thing that strikes me as wrong is that the core

Re: Exceptions in general

2007-12-05 Thread Paul J. Lucas
On Dec 4, 2007, at 3:03 AM, Stian Soiland wrote: On 12/3/07, Paul J. Lucas [EMAIL PROTECTED] wrote: Funny, because java.io.FileNotFoundException is derived from IOException. So clearly there's precedent. Did you notice the io package name? :-) The exceptions here are about resources

Re: RESTClient

2007-11-30 Thread Paul J. Lucas
On Nov 30, 2007, at 6:05 AM, Lars Heuer wrote: RESTClient is a Java platform client application to test RESTful webservices. http://code.google.com/p/rest-client/ IMHO, command-line test tools are better because they're far more easily automated. I just write Perl script wrappers around

Re: Exceptions in general

2007-11-29 Thread Paul J. Lucas
On Nov 29, 2007, at 6:30 AM, Tim Peierls wrote: However, I don't have a concrete proposal, and I don't see an easy way to do this without breaking code for 1.1m1 users. Personally, I'd prefer to break an API rather than have to live with a hacked API forever. Since Restlet is currently a

Re: Lightweight alternative to Reference

2007-11-29 Thread Paul J. Lucas
On Nov 29, 2007, at 3:18 PM, Jerome Louvel wrote: It could have methods starting with append like the StringBuilder class, and follow the Reference naming convention. For example it could have: - appendScheme(String scheme) - appendSchemeSpecificPart(String ssp) - appendFragment(String

Re: Lightweight alternative to Reference

2007-11-29 Thread Paul J. Lucas
On Nov 29, 2007, at 4:32 PM, Rob Heittman wrote: The warnings to the user (cough Checked Exceptions /cough) should come in when you try to confess the builder into a URI, Reference, or String and it doesn't contain enough pieces and parts to have meaning. If, as the implementor, you want

Re: Lightweight alternative to Reference

2007-11-29 Thread Paul J. Lucas
On Nov 29, 2007, at 4:52 PM, Tim Peierls wrote: Abstractly, though, would you rather see ReferenceBuilderException checked or unchecked in the following: try { Reference ref = ReferenceBuilder.appendBar(myBar).appendFoo(myFoo); // do something with ref } catch

Re: ConverterService architecture

2007-11-28 Thread Paul J. Lucas
On Nov 28, 2007, at 1:31 PM, Jason Terhune wrote: I haven't actually tried this, but couldn't you just overload the toObject() and toRepresentation() methods? Doesn't Java do the work of choosing the method with the most specific argument? For example: public class ConverterService

Re: ConverterService architecture

2007-11-26 Thread Paul J. Lucas
On Nov 26, 2007, at 2:33 AM, Jerome Louvel wrote: Your suggestion regarding the map of ConverterService is interesting. However, how would you handle the reverse conversion (from Representation to Object) ? Also using a map. For both conversion directions, you allow for the possibility

ConverterService architecture

2007-11-23 Thread Paul J. Lucas
The current architecture of ConverterService is such that if I want to convert to/from an object of a given class, I subclass ConverterService. Well, what if I want to convert to/from several classes? In my subclass, I could do an: if ( obj instanceof MyClass1 ) { //

Why not Reference.getQueryAsObject?

2007-11-23 Thread Paul J. Lucas
If Message.getEntityAsObject() exists, why doesn't Reference.getQueryAsObject() exist? I want to turn a query (via a Form) into an Object using a ConverterService. (I'm converting a query into an Object now, but doing it my own way since the framework apparently provides no right way of

Re: Converting http to file scheme

2007-11-19 Thread Paul J. Lucas
On Nov 19, 2007, at 6:51 AM, Rob Heittman wrote: Or maybe Paul can figure out a way to do it without the mess. Right now, I'm still trying to get my head around all this. It's not totally clear to me when things should be a Restlet or a Resource; whether one should derive from Directory

Implementing COPY and MOVE (Was: Converting http to file scheme)

2007-11-19 Thread Paul J. Lucas
On Nov 19, 2007, at 6:51 AM, Rob Heittman wrote: In my noodling with DAV method support, COPY and MOVE are especially challenging to implement. By extending Directory and friends, you can model a COPY as a GET and a PUT, and a MOVE as a GET, DELETE, and PUT, but this is messy, not atomic

Re: Implementing COPY and MOVE

2007-11-19 Thread Paul J. Lucas
On Nov 19, 2007, at 8:12 PM, Paul J. Lucas wrote: I've figured out that to do this right, yes: you do need to extend DirectoryResource. The problem with that is that Engine insists on creating an instance of DirectoryResource and not an instance of one's derived class. So that means one

Restlet 1.2 (Was: Easier way to get an HTTP header?)

2007-11-18 Thread Paul J. Lucas
On Nov 17, 2007, at 2:42 PM, Rob Heittman wrote: It, and other full WebDAV stuff is targeted to land in Restlet 1.2. When is 1.2 targeted to be released? - Paul

One Directory for entire tree?

2007-11-18 Thread Paul J. Lucas
I was playing around with trying to derive from Directory to implement the WebDAV COPY and MOVE methods. (How feasible is that?) One of the first things I did was to call setModifiable() based on whether the directory is actually writable (File.canWrite()). This worked fine. I then

Converting http to file scheme

2007-11-18 Thread Paul J. Lucas
When a client specifies a URL like: http://server/path/to/file how do I convert that into a file URI: file://localhost/path/to/root/path/to/file ? The context is in trying to implement the Destination header for a WebDAV COPY or MOVE method. The client specifies the

Easier way to get an HTTP header?

2007-11-17 Thread Paul J. Lucas
To get the value of an HTTP header, it seems as though I have to do: Form f = (Form)request.getAttributes().get( ATTRIBUTE_HEADERS ); String value = f.getFirstValue( MyHeader ); That seems rather... cumbersome. Is there an easier way? - Paul

Re: Easier way to get an HTTP header?

2007-11-17 Thread Paul J. Lucas
On Nov 17, 2007, at 2:42 PM, Rob Heittman wrote: The non-standard header mechanism is the way to go for Destination: and Overwrite: and such for the moment. By which you mean the way I've already shown in code? Or something else? - Paul

Re: New user: guidance for server?

2007-11-15 Thread Paul J. Lucas
- Original Message - From: Paul J. Lucas [EMAIL PROTECTED] To: discuss@restlet.tigris.org Sent: Thursday, November 15, 2007 1:05:56 PM (GMT-0500) America/ New_York Subject: New user: guidance for server? Hi - I'm new to Restlet. I want to create a simple server that serves the contents