X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Futil%2FDictionaryUtils.java;h=ec27e0304f6ef159d128aa833cce7b06d4af92b2;hp=e88efa93194671b08e112ea9bf6990942def6419;hb=1e61676b77dd09659027b8984f050df7e8538526;hpb=f18fbfc026de9cf02126f57844c37abfee607394 diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java index e88efa931..ec27e0304 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/DictionaryUtils.java @@ -23,14 +23,17 @@ package org.onap.policy.pap.xacml.rest.util; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; @@ -80,8 +83,7 @@ public class DictionaryUtils { } public boolean isRequestFromAPI(HttpServletRequest request) { - return request.getParameter(apiflag) != null - && "api".equalsIgnoreCase(request.getParameter(apiflag)); + return request.getParameter(apiflag) != null && "api".equalsIgnoreCase(request.getParameter(apiflag)); } public String appendKey(List objects, String key1, String appendValue) { @@ -134,8 +136,7 @@ public class DictionaryUtils { } public Category getCategory() { - return (Category) commonClassDao.getDataById(Category.class, "shortName", "resource") - .get(0); + return (Category) commonClassDao.getDataById(Category.class, "shortName", "resource").get(0); } public ModelAndView getResultForApi(String inResponseString) { @@ -148,8 +149,7 @@ public class DictionaryUtils { return result; } - public void setResponseData(HttpServletResponse response, String key, String responseString) - throws IOException { + public void setResponseData(HttpServletResponse response, String key, String responseString) throws IOException { response.setCharacterEncoding(utf8); response.setContentType(applicationJsonContentType); @@ -166,13 +166,11 @@ public class DictionaryUtils { } @SuppressWarnings("rawtypes") - public void getDataByEntity(HttpServletResponse response, String key, String value, - Class className) { + public void getDataByEntity(HttpServletResponse response, String key, String value, Class className) { try { Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); - model.put(key, - mapper.writeValueAsString(commonClassDao.getDataByColumn(className, value))); + model.put(key, mapper.writeValueAsString(commonClassDao.getDataByColumn(className, value))); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); JSONObject j = new JSONObject(msg); response.getWriter().write(j.toString()); @@ -206,8 +204,7 @@ public class DictionaryUtils { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - commonClassDao - .delete(mapper.readValue(root.get("data").toString(), className)); + commonClassDao.delete(mapper.readValue(root.get("data").toString(), className)); String responseString = mapper.writeValueAsString(commonClassDao.getData(className)); setResponseData(response, key, responseString); } catch (Exception e) {