Skip to content

Instantly share code, notes, and snippets.

@docwhat
Created March 5, 2011 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save docwhat/856596 to your computer and use it in GitHub Desktop.
Save docwhat/856596 to your computer and use it in GitHub Desktop.
@HEAD
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response HEAD(@PathParam("token") String token,
@DefaultValue("0") @FormParam("id") Number id)
throws JsonGenerationException, JsonMappingException, IOException {
EditSession session = AppState.INSTANCE.getEditSession(token);
Number change_id = session.getChangeId();
boolean has_changed = change_id != id;
logger.debug("--EditToken (HEAD)");
logger.debug("Session: " + token);
logger.debug("Has Changed: " + has_changed);
if (has_changed) {
Map<String, String> response = new LinkedHashMap<String, String>();
response.put("id", change_id.toString());
response.put("text", session.getText());
return Response.ok(response, MediaType.APPLICATION_JSON).build();
} else {
return Response.notModified().build();
}
}
@docwhat
Copy link
Author

docwhat commented Mar 5, 2011

I'm trying to return this as the data of the ok() response: {"id": 2, "text": "the long text string...."}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment