}
protected ExtensionResponse tryAppendRexsterAttributesIfJson(final ExtensionResponse extResponse,
final ExtensionMethod methodToCall,
final String mediaType) {
ExtensionResponse newExtensionResponse = extResponse;
if (mediaType.equals(MediaType.APPLICATION_JSON)
&& methodToCall.getExtensionDefinition().tryIncludeRexsterAttributes()) {
final Object obj = extResponse.getJerseyResponse().getEntity();
if (obj instanceof JSONObject) {
final JSONObject entity = (JSONObject) obj;
if (entity != null) {
try {
entity.put(Tokens.VERSION, Tokens.REXSTER_VERSION);
entity.put(Tokens.QUERY_TIME, this.sh.stopWatch());
} catch (JSONException jsonException) {
// nothing bad happening here
logger.error("Couldn't add Rexster attributes to response for an extension.");
}
newExtensionResponse = new ExtensionResponse(
Response.fromResponse(extResponse.getJerseyResponse()).entity(entity).build());
}
}
}