Hello,

I guess I should explain the mapping between Java methods and HTTP request.
Using Restlet Framework, the annotated methods follow these conventions:
 - there is either one or no parameter to a Java method.
 - such parameter is either an instance of the Representation (that wraps the 
flow of bytes coming from the socket) or an instance of a Java bean which is 
the conversion of the entity sent by the client in the incoming request.

In your case, the annotated method is as follow:

@Get
public void readThing(Long id, Result<ThingItem> callback);

Which can't happen since a GET request has no entity. Same issue for the DELETE 
method.

Here is my first refactoring:
 - GaeThingServerResource is attached as follow
router.attach("/thingitems/{thingitemid}"

 - Here is content of the GaeThingServerResource class.
public class GaeThingServerResource extends SelfInjectingServerResource
         implements ThingResource {
     private static final Logger LOG
             = Logger.getLogger(Gae​ThingServerResource.​class.getName());

     /** The identifier of the resource. */
     private Long id;

     @Override
     public ThingItem doInit() {
         id = Long.parseLong(getAttribute("thingitemid"));
         // You may check that the resource really exist
        // setExisting(true or false);
     }

     @Override
     public ThingItem createThing(ThingItem Thing) {
         store().put(Thing);
         return Thing;
     }

     @Override
     public ThingItem readThing() {
         LOG.info("Read Thing id=" + id);
         ThingItem result = store().get(ThingItem.class, id);
         return result;
     }

     @Override
     public ThingItem updateThing(ThingItem Thing) {
         LOG.info("Updating Thing=" + Thing.toString());
         store().put(Thing);
         return Thing;
     }

     @Override
     public void deleteThing() {
         LOG.info("Delete Thing id=" + id);
         store().delete(ThingItem.class, id);
     }
}

I guess you may have another question about how to create an entity.

Best regards,
Thierry Boileau

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

Reply via email to