Posts

Showing posts from December, 2019

Good Practice to get response in webscript

Body requestBodyObject = JsonUtility.buildRequestBodyObject(jsonRequest); Map<String,Object> mapOfParams = requestBodyObject.getBody(); String noderef = JavaUtility.extractParameterFromMap(mapOfParams,"noderef"); NodeRef fileNodeRef = new NodeRef(noderef); public static String extractParameterFromMap(Map<String,Object> mapOfParams,String paramName) { String paramValue = ""; if(mapOfParams.containsKey(paramName)){ paramValue = (String)mapOfParams.get(paramName); } return paramValue; } public class JsonUtility { public static Body buildRequestBodyObject(String jsonRequest){ Gson gson = new GsonBuilder().create(); return gson.fromJson(jsonRequest, Body.class); } } =============================================================================== public class Response { private ResponseContainer response; public ResponseContainer getResponse() { return response; } public void setResponse