01: /*
02: * Copyright 2005-2007 Noelios Consulting.
03: *
04: * The contents of this file are subject to the terms
05: * of the Common Development and Distribution License
06: * (the "License"). You may not use this file except
07: * in compliance with the License.
08: *
09: * You can obtain a copy of the license at
10: * http://www.opensource.org/licenses/cddl1.txt
11: * See the License for the specific language governing
12: * permissions and limitations under the License.
13: *
14: * When distributing Covered Code, include this CDDL
15: * HEADER in each file and include the License file at
16: * http://www.opensource.org/licenses/cddl1.txt
17: * If applicable, add the following below this CDDL
18: * HEADER, with the fields enclosed by brackets "[]"
19: * replaced with your own identifying information:
20: * Portions Copyright [yyyy] [name of copyright owner]
21: */
22:
23: package org.restlet.example.tutorial;
24:
25: import org.restlet.Context;
26: import org.restlet.data.MediaType;
27: import org.restlet.data.Request;
28: import org.restlet.data.Response;
29: import org.restlet.resource.Representation;
30: import org.restlet.resource.StringRepresentation;
31: import org.restlet.resource.Variant;
32:
33: /**
34: * @author Jerome Louvel (contact@noelios.com)
35: */
36: public class OrderResource extends UserResource {
37: String orderId;
38:
39: Object order;
40:
41: public OrderResource(Context context, Request request,
42: Response response) {
43: super (context, request, response);
44: this .orderId = (String) request.getAttributes().get("order");
45: this .order = null; // Could be a lookup to a domain object.
46: }
47:
48: @Override
49: public Representation getRepresentation(Variant variant) {
50: Representation result = null;
51: if (variant.getMediaType().equals(MediaType.TEXT_PLAIN)) {
52: result = new StringRepresentation("Order \"" + this .orderId
53: + "\" for user \"" + this .userName + "\"");
54: }
55: return result;
56: }
57:
58: }
|