setExisting works as advertised?

2009-06-05 Thread webpost
Hi,

I'm evaluating restlet and I like what I see, especially the 2.0 version.

If I understand ServerResource.setEx​isting(false) correctly, the restlet 
infrastructure should send back a 404 when I call setExisting(false) on a 
request (called within the doInit method)

Reproducable with 2.0m3 by navigating to /firstResource/items/333 on a server 
restart. Server is returning 500 because the example is throwing an exception 
in toXml() (because item is null), but that is only the symptom -- I would 
think it should never get there because the example is calling 
setExisting(false) in doInit.

Jim

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


Re: restlet server NoSuchMethodError

2009-06-05 Thread Matt Stromske
I just realized I am using an old version of Tomcat (4.1) and the 
servlet spec for that version of Tomcat does not have support the 
'getLocalAddr' method.   Darn it.



Stephan Koops wrote:
 Hi Matt,

 looks like that the JARs are from different Restlet versions.

 best regards
Stephan

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

-- 
Matt Stromske
Software Engineer
Singlewire Software, LLC
www.singlewire.com
--
608.298.1020
matt.strom...@singlewire.com

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


Re: setExisting works as advertised?

2009-06-05 Thread Thierry Boileau
Hello Jim,

this bug is actually covered by this issue = 
http://restlet.tigris.org/issues/show_bug.cgi?id=822
It will be fixed soon.

best regards,
Thierry Boileau

 Hi,

 I'm evaluating restlet and I like what I see, especially the 2.0 version.

 If I understand ServerResource.setEx​isting(false) correctly, the restlet 
 infrastructure should send back a 404 when I call setExisting(false) on a 
 request (called within the doInit method)

 Reproducable with 2.0m3 by navigating to /firstResource/items/333 on a server 
 restart. Server is returning 500 because the example is throwing an exception 
 in toXml() (because item is null), but that is only the symptom -- I would 
 think it should never get there because the example is calling 
 setExisting(false) in doInit.

 Jim

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



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


JSON and File Representation

2009-06-05 Thread Thomas Cozien
Hi,

I use RestLet server to send JSON Object with JsonRepresentation object.

I want to send picture (or image) with this Json representation. I know i can 
send picture with FileRepresentation but I wonder if it possible to send both 
picture and json?

Or may I use an other representation?

Best regards
Tom

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


Help with a basic Application and Resources (on JBOSS)

2009-06-05 Thread Andrew Moore
Hi, I'm new to RESTful services and Restlets.

I'm trying to create a hello world application that is integrated with my
company's J2EE app (we're running on JBOSS).

From what I can tell from the tutorials and example source code, it seems
pretty simple to add an Application and Resources. I'm definitely missing
something though.

We have a hierarchy of information which I would like to have resources for.
For example, I want to have URI's like these:

/myapp/zipcodes/{zip}/
/myapp/zipcodes/{zip}/locations/{location}
/myapp/zipcodes/{zip}/locations/{location}/users/{user}

This way I'll be able to return information depending on what level of the
hierarchy I'm interested in.

I first tried creating an application in which I used the equivalent of
router.attachDefault(DefaultResource.class) to just return Hello to my
browser. This worked just fine. My next step though, was to create resources
for the other URI's and simply echo back the various values ({zip},
{location}, {user}) found by my Resource to the browser.

This is where I'm not having success, and I am wondering what I'm doing
wrong, or what concept I'm not catching onto. Since I can't publish the code
for work on here, I've re-worded the packages and code... the application
class I'm using:

package com.myapp.applications;

import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.routing.Router;

import com.myapp.resources.ZipsResource;
import com.myapp.resources.ZipsLocsResource;
import com.myapp.resources.ZipsLocsUsersResource;

public class MyApplication extends Application {

  public MyApplication() {
// TODO Auto-generated constructor stub
  }

  public MyApplication(Context context) {
super(context);
// TODO Auto-generated constructor stub
  }

  @Override
  public Restlet createRoot() {

// Create a router Restlet that routes each call to a
Router router = new Router(getContext());

router.attach(/myapp/zipcodes/{zip}/, ZipsResource.class);
router.attach(/myapp/zipcodes/{zip}/locations/{location},
ZipsLocsResource.class);
router.attach(/myapp/zipcodes/{zip}/locations/{location}/users/{user},
ZipsLocsUsersResource.class);

return router;
  }
}


And the code for my resources are all basically the same as this one:

package com.myapp.resources;

import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

public class Resource extends ServerResource {
 
  private String zip;
  private String location;
  private String user;
 
  @Get
  public Representation represent() {
System.out.println(ZipLocsUsersResource.represent());
   
this.zip = (String) getRequest().getAttributes().get(zip);
this.location = (String) getRequest().getAttributes().get(location);
this.user = (String) getRequest().getAttributes().get(user);
   
Representation result = new StringRepresentation(ZipsLocsUsersResource
zip[ + this.zip + ] location[ + this.location + ] user[ + this.user +
]);
return result;
  }
}



Again... in my application class, if I use the .attachDefault() I can hit
the URI with my browser and get my Hello World response just fine. The
second I remove .attachDefault() and start attaching specific URI's, I get
404 responses with the restlet page that says The server has not found
anything matching the request URI.

I really appreciate any help on what I'm doing wrong or not understanding...
I have read the first steps, read the first resource page, read through the
tutorial, and I have been looking at the example code that came with the
restlets package (2.0M3). I'm assuming my web.xml is properly configured or
I wouldn't have been successful with the attachDefault() first attempt I
made.

Thanks in advance and regards,

Andrew

-- 
View this message in context: 
http://n2.nabble.com/Help-with-a-basic-Application-and-Resources-%28on-JBOSS%29-tp3032757p3032757.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Help with a basic Application and Resources (on JBOSS)

2009-06-05 Thread Andrew Moore
Well... I figured it out. And I am an idiot. 

I had setup my web.xml to associate my Application class with /myapp.

I was then attaching my resources to a URI that started with /myapp/

So therefore, in my browser the URI which properly returned me my resource
was: /myapp/myapp/zipcodes/{zip}/...

I had been trying this instead: /myapp/zipcodes/{zip}/...

Yes, I do feel extremely cool now... (and yes that was some self deprecating
sarcasm...)

~ Andrew

-- 
View this message in context: 
http://n2.nabble.com/Help-with-a-basic-Application-and-Resources-%28on-JBOSS%29-tp3032757p3033033.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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