agave-common/common-api/src/main/java/org/iplantc/service/common/representation/AgaveRepresentation.java
/**
	 * Formats the response both successful and unsuccessful calls into a 
	 * JSON wrapper object with attributes status, message, and result 
	 * where result contains the JSON output of the call.
	 *
	 * @param status the status of the api operation
	 * @param message the message in the response wrapper
	 * @param jsonNode the api operation response payload
	 */
Formats the response both successful and unsuccessful calls into a
JSON wrapper object with attributes status, message, and result
where result contains the JSON output of the call.

@param status the status of the api operation
@param message the message in the response wrapper
@param jsonNode the api operation response payload
Formats the response both successful and unsuccessful calls into a JSON wrapper object with attributes status message and result where result contains the JSON output of the call . @param status the status of the api operation @param message the message in the response wrapper @param jsonNode the api operation response payload
protected String formatResponse(String status, String message, JsonNode jsonNode) {
		try
		{
			DefaultPrettyPrinter pp = new DefaultPrettyPrinter();
            ObjectMapper mapper = new ObjectMapper();
			if (isNaked()) 
			{
			    if (Response.getCurrent().getStatus() == Status.SUCCESS_NO_CONTENT || jsonNode == null) {
			       return null;
			    } else {
			    	if (isPrettyPrint()) {
	    			    return mapper.writer(pp).writeValueAsString(filterOutput(jsonNode));
	    			} else {
	    				return filterOutput(jsonNode).toString();
	    			}
			    }
			}
			else 
			{
    			ObjectNode jsonWrapper = mapper.createObjectNode()
    				.put("status", status)
    				.put("message", message)
    				.put("version", Settings.SERVICE_VERSION);
    			if (jsonNode != null) {
    				jsonWrapper.set("result", filterOutput(jsonNode));
    			}
    			if (isPrettyPrint()) {
    			    return mapper.writer(pp).writeValueAsString(jsonWrapper);
    			} else {
    				return jsonWrapper.toString();
    			}
			}
		} 
		catch (Exception e)
		{
		    if (isNaked()) {
				if (jsonNode != null) {
					return jsonNode.toString();
				} else {
					return "";
				}
			}
		    else
		    {
    			status = status.replaceAll("\"", "\\\"");
    			if (message == null) {
    				message = "";
    			} else {
    				message = message.replaceAll("\"", "\\\"");
    			}
    			StringBuilder builder = new StringBuilder();
    			builder.append("{\"status\":\"").append(status).append("\",");
    			builder.append("\"message\":\"").append(message).append("\",");
    			builder.append("\"version\":\"").append(Settings.SERVICE_VERSION).append("\",");
				if (jsonNode != null) {
					builder.append("\"result\":").append(jsonNode).append("}");
				} else {
					builder.append("\"result\": null}");
				}
				return builder.toString();
		    }
		}
	}
protected String formatResponse ( String status , String message , JsonNode jsonNode ) { try { DefaultPrettyPrinter pp = new DefaultPrettyPrinter ( ) ; ObjectMapper mapper = new ObjectMapper ( ) ; if ( isNaked ( ) ) { if ( Response . getCurrent ( ) . getStatus ( ) == Status . SUCCESS_NO_CONTENT || jsonNode == null ) { return null ; } else { if ( isPrettyPrint ( ) ) { return mapper . writer ( pp ) . writeValueAsString ( filterOutput ( jsonNode ) ) ; } else { return filterOutput ( jsonNode ) . toString ( ) ; } } } else { ObjectNode jsonWrapper = mapper . createObjectNode ( ) . put ( "status" , status ) . put ( "message" , message ) . put ( "version" , Settings . SERVICE_VERSION ) ; if ( jsonNode != null ) { jsonWrapper . set ( "result" , filterOutput ( jsonNode ) ) ; } if ( isPrettyPrint ( ) ) { return mapper . writer ( pp ) . writeValueAsString ( jsonWrapper ) ; } else { return jsonWrapper . toString ( ) ; } } } catch ( Exception e ) { if ( isNaked ( ) ) { if ( jsonNode != null ) { return jsonNode . toString ( ) ; } else { return "" ; } } else { status = status . replaceAll ( "\"" , "\\\"" ) ; if ( message == null ) { message = "" ; } else { message = message . replaceAll ( "\"" , "\\\"" ) ; } StringBuilder builder = new StringBuilder ( ) ; builder . append ( "{\"status\":\"" ) . append ( status ) . append ( "\"," ) ; builder . append ( "\"message\":\"" ) . append ( message ) . append ( "\"," ) ; builder . append ( "\"version\":\"" ) . append ( Settings . SERVICE_VERSION ) . append ( "\"," ) ; if ( jsonNode != null ) { builder . append ( "\"result\":" ) . append ( jsonNode ) . append ( "}" ) ; } else { builder . append ( "\"result\": null}" ) ; } return builder . toString ( ) ; } } }
Formats the response both successful and unsuccessful calls into a
 JSON wrapper object with attributes status, message, and result
 where result contains the JSON output of the call.
Formats the response both successful and unsuccessful calls into a JSON wrapper object with attributes status message and result where result contains the JSON output of the call .