Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improve documentation

  • Loading branch information...
commit f0c0e81254b48cde2c04a6645f57d7817234655e 1 parent e5b8a70
Jeanfrancois Arcand jfarcand authored
2  restsimple-api/src/main/java/org/sonatype/restsimple/api/Action.java
@@ -49,6 +49,8 @@ public Pet action(ActionContext<Pet> actionContext) throws ActionException {
49 49 }
50 50
51 51 }
  52 + * You can use the {@link TypedAction} for an implementation of an {@link Action}
  53 + *
52 54 * The de-serialization of the Request's body is always performed before the {@link Action#action} and the result can
53 55 * always be retrieved using {@link org.sonatype.restsimple.api.ActionContext#get()} The returned value of the
54 56 * {@link Action#action} will be serialized based on the information represented by the associated {@link ServiceHandler}.
33 restsimple-api/src/main/java/org/sonatype/restsimple/api/TypedAction.java
@@ -15,6 +15,39 @@
15 15 * Simple {@link Action} that delegate the HTTP method operation to proper method implementation of GET, POST, PUT and
16 16 * DELETE. By default all method are throwing an exception with the status code set to 405 (NOT SUPPORTED). Override the
17 17 * proper method.
  18 + * {@code
  19 + * public class PetstoreAction extends TypedAction<Pet, Pet> {
  20 + *
  21 + @Override
  22 + public Pet get(ActionContext<Pet> actionContext) {
  23 + String pathValue = actionContext.pathParams().get("pet");
  24 + Map<String, Collection<String>> headers = actionContext.headers();
  25 +
  26 + Pet pet = pets.get(pathValue);
  27 + return pet;
  28 + }
  29 +
  30 + @Override
  31 + public Pet post(ActionContext<Pet> actionContext) {
  32 + Map<String, Collection<String>> headers = actionContext.headers();
  33 + Map<String, Collection<String>> queryStrings = actionContext.paramsString();
  34 + Map<String, Collection<String>> matrixParams = actionContext.matrixString();
  35 +
  36 + String pathValue = actionContext.pathParams().get("pet");
  37 +
  38 + Pet pet = actionContext.get();
  39 + pets.put(pathValue, pet);
  40 + return pet;
  41 + }
  42 +
  43 + @Override
  44 + public Pet delete(ActionContext<Pet> actionContext) {
  45 + String pathValue = actionContext.pathParams().get("pet");
  46 +
  47 + return pets.remove(pathValue);
  48 + }
  49 + * }
  50 + * }
18 51 *
19 52 * @param <T>
20 53 * @param <V>

0 comments on commit f0c0e81

Please sign in to comment.
Something went wrong with that request. Please try again.