Created
March 5, 2011 18:46
-
-
Save docwhat/856596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to return this as the data of the
ok()
response:{"id": 2, "text": "the long text string...."}