@Test public void testSetDataToPolicyRestAdapter() { logger.debug("testSetDataToPolicyRestAdapter: enter"); CreateDcaeMicroServiceController.setCommonClassDao(commonClassDao); JsonNode root = null; ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); PolicyRestAdapter policyData = null; try { root = JsonLoader.fromString(jsonString); policyData = mapper.readValue(root.get("policyData").get("policy").toString(), PolicyRestAdapter.class); } catch (Exception e) { logger.error("testSetDataToPolicyRestAdapter", e); } CreateDcaeMicroServiceController controller = new CreateDcaeMicroServiceController(); PolicyRestAdapter result = controller.setDataToPolicyRestAdapter(policyData, root); assertTrue(result != null && result.getJsonBody() != null && !result.getJsonBody().isEmpty()); logger.debug("result.getJsonBody() : " + result.getJsonBody()); logger.debug("testSetDataToPolicyRestAdapter: exit"); }
public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) { String jsonContent = null; try { LOGGER.info("policyJSON :" + (root.get(POLICYJSON)).toString()); String tempJson = root.get(POLICYJSON).toString(); JSONObject policyJson = new JSONObject(root.get(POLICYJSON).toString()); tempJson = decodeJsonVal(tempJson, policyJson); String dummyValue = "*empty-value*" + UUID.randomUUID().toString(); LOGGER.info("dummyValue:" + dummyValue); tempJson = StringUtils.replaceEach(tempJson, new String[] {"\"\""}, new String[] {"\"" + dummyValue + "\""}); ObjectMapper mapper = new ObjectMapper(); JsonNode tempJsonNode = mapper.readTree(tempJson); jsonContent = decodeContent(tempJsonNode).toString(); constructJson(policyData, jsonContent, dummyValue); } catch (Exception e) { LOGGER.error("Error while decoding microservice content", e); } if (policyData.getJsonBody() != null && jsonStringValues.size() > 0) { String contentBody = policyData.getJsonBody(); JSONObject contentJson = new JSONObject(contentBody); JSONObject content = contentJson.getJSONObject("content"); content = setOriginalJsonObject(content, jsonStringValues); contentJson.put("content", content); policyData.setJsonBody(StringEscapeUtils.unescapeJava(contentJson.toString())); } return policyData; }
CreateDcaeMicroServiceController extends RestrictedBaseController { public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) { String jsonContent = null; try { LOGGER.info("policyJSON :" + (root.get(POLICYJSON)).toString()); String tempJson = root.get(POLICYJSON).toString(); JSONObject policyJson = new JSONObject(root.get(POLICYJSON).toString()); tempJson = decodeJsonVal(tempJson, policyJson); String dummyValue = "*empty-value*" + UUID.randomUUID().toString(); LOGGER.info("dummyValue:" + dummyValue); tempJson = StringUtils.replaceEach(tempJson, new String[] {"\"\""}, new String[] {"\"" + dummyValue + "\""}); ObjectMapper mapper = new ObjectMapper(); JsonNode tempJsonNode = mapper.readTree(tempJson); jsonContent = decodeContent(tempJsonNode).toString(); constructJson(policyData, jsonContent, dummyValue); } catch (Exception e) { LOGGER.error("Error while decoding microservice content", e); } if (policyData.getJsonBody() != null && jsonStringValues.size() > 0) { String contentBody = policyData.getJsonBody(); JSONObject contentJson = new JSONObject(contentBody); JSONObject content = contentJson.getJSONObject("content"); content = setOriginalJsonObject(content, jsonStringValues); contentJson.put("content", content); policyData.setJsonBody(StringEscapeUtils.unescapeJava(contentJson.toString())); } return policyData; } }
CreateDcaeMicroServiceController extends RestrictedBaseController { public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) { String jsonContent = null; try { LOGGER.info("policyJSON :" + (root.get(POLICYJSON)).toString()); String tempJson = root.get(POLICYJSON).toString(); JSONObject policyJson = new JSONObject(root.get(POLICYJSON).toString()); tempJson = decodeJsonVal(tempJson, policyJson); String dummyValue = "*empty-value*" + UUID.randomUUID().toString(); LOGGER.info("dummyValue:" + dummyValue); tempJson = StringUtils.replaceEach(tempJson, new String[] {"\"\""}, new String[] {"\"" + dummyValue + "\""}); ObjectMapper mapper = new ObjectMapper(); JsonNode tempJsonNode = mapper.readTree(tempJson); jsonContent = decodeContent(tempJsonNode).toString(); constructJson(policyData, jsonContent, dummyValue); } catch (Exception e) { LOGGER.error("Error while decoding microservice content", e); } if (policyData.getJsonBody() != null && jsonStringValues.size() > 0) { String contentBody = policyData.getJsonBody(); JSONObject contentJson = new JSONObject(contentBody); JSONObject content = contentJson.getJSONObject("content"); content = setOriginalJsonObject(content, jsonStringValues); contentJson.put("content", content); policyData.setJsonBody(StringEscapeUtils.unescapeJava(contentJson.toString())); } return policyData; } @Autowired private  CreateDcaeMicroServiceController(CommonClassDao commonClassDao);  CreateDcaeMicroServiceController(); }
CreateDcaeMicroServiceController extends RestrictedBaseController { public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) { String jsonContent = null; try { LOGGER.info("policyJSON :" + (root.get(POLICYJSON)).toString()); String tempJson = root.get(POLICYJSON).toString(); JSONObject policyJson = new JSONObject(root.get(POLICYJSON).toString()); tempJson = decodeJsonVal(tempJson, policyJson); String dummyValue = "*empty-value*" + UUID.randomUUID().toString(); LOGGER.info("dummyValue:" + dummyValue); tempJson = StringUtils.replaceEach(tempJson, new String[] {"\"\""}, new String[] {"\"" + dummyValue + "\""}); ObjectMapper mapper = new ObjectMapper(); JsonNode tempJsonNode = mapper.readTree(tempJson); jsonContent = decodeContent(tempJsonNode).toString(); constructJson(policyData, jsonContent, dummyValue); } catch (Exception e) { LOGGER.error("Error while decoding microservice content", e); } if (policyData.getJsonBody() != null && jsonStringValues.size() > 0) { String contentBody = policyData.getJsonBody(); JSONObject contentJson = new JSONObject(contentBody); JSONObject content = contentJson.getJSONObject("content"); content = setOriginalJsonObject(content, jsonStringValues); contentJson.put("content", content); policyData.setJsonBody(StringEscapeUtils.unescapeJava(contentJson.toString())); } return policyData; } @Autowired private  CreateDcaeMicroServiceController(CommonClassDao commonClassDao);  CreateDcaeMicroServiceController(); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root); boolean checkPattern(String patternString); void constructRule(StringBuilder sb, String jsonNode, Map<String, String> sigRules2); void parseData(JsonNode jsonNode, String string); String removeNullAttributes(String cleanJson); JsonArray removeNull(JsonArray array); JsonObject removeNull(JsonObject obj); String cleanUpJson(String json); JSONObject decodeContent(JsonNode jsonNode); @RequestMapping( value = {"/policyController/getDCAEMSTemplateData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getDCAEMSTemplateData(HttpServletRequest request, HttpServletResponse response); JSONObject convertToArrayElement(JSONObject json, String keyValue); Set<String> getManyTrueProperties(String referAttributes); @RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_DCAEPriorityValues"}, method = {org.springframework.web.bind.annotation.RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getDCAEPriorityValuesData(HttpServletRequest request, HttpServletResponse response); void prePopulateDCAEMSPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity); Map<String, String> convert(String str, String split); @SuppressWarnings("unchecked") void readFile(PolicyRestAdapter policyAdapter, PolicyEntity entity); @SuppressWarnings({"rawtypes", "unchecked"}) void readRecursivlyJSONContent(Map<String, ?> map, Map<String, Object> data); String getPolicyScope(String value); Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap); @RequestMapping( value = {"/ms_dictionary/set_MSModelData"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) void SetMSModelData(HttpServletRequest request, HttpServletResponse response); void cleanUp(String path); void checkZipDirectory(String zipDirectory); Map<String, String> getAttributesListRefMap(); Map<String, LinkedList<String>> getArrayTextList(); Map<String, String> getSigRules(); void setSigRules(Map<String, String> sigRules); }
CreateDcaeMicroServiceController extends RestrictedBaseController { public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) { String jsonContent = null; try { LOGGER.info("policyJSON :" + (root.get(POLICYJSON)).toString()); String tempJson = root.get(POLICYJSON).toString(); JSONObject policyJson = new JSONObject(root.get(POLICYJSON).toString()); tempJson = decodeJsonVal(tempJson, policyJson); String dummyValue = "*empty-value*" + UUID.randomUUID().toString(); LOGGER.info("dummyValue:" + dummyValue); tempJson = StringUtils.replaceEach(tempJson, new String[] {"\"\""}, new String[] {"\"" + dummyValue + "\""}); ObjectMapper mapper = new ObjectMapper(); JsonNode tempJsonNode = mapper.readTree(tempJson); jsonContent = decodeContent(tempJsonNode).toString(); constructJson(policyData, jsonContent, dummyValue); } catch (Exception e) { LOGGER.error("Error while decoding microservice content", e); } if (policyData.getJsonBody() != null && jsonStringValues.size() > 0) { String contentBody = policyData.getJsonBody(); JSONObject contentJson = new JSONObject(contentBody); JSONObject content = contentJson.getJSONObject("content"); content = setOriginalJsonObject(content, jsonStringValues); contentJson.put("content", content); policyData.setJsonBody(StringEscapeUtils.unescapeJava(contentJson.toString())); } return policyData; } @Autowired private  CreateDcaeMicroServiceController(CommonClassDao commonClassDao);  CreateDcaeMicroServiceController(); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root); boolean checkPattern(String patternString); void constructRule(StringBuilder sb, String jsonNode, Map<String, String> sigRules2); void parseData(JsonNode jsonNode, String string); String removeNullAttributes(String cleanJson); JsonArray removeNull(JsonArray array); JsonObject removeNull(JsonObject obj); String cleanUpJson(String json); JSONObject decodeContent(JsonNode jsonNode); @RequestMapping( value = {"/policyController/getDCAEMSTemplateData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getDCAEMSTemplateData(HttpServletRequest request, HttpServletResponse response); JSONObject convertToArrayElement(JSONObject json, String keyValue); Set<String> getManyTrueProperties(String referAttributes); @RequestMapping( value = {"/policyController/getModelServiceVersioneData.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView getModelServiceVersionData(HttpServletRequest request, HttpServletResponse response); @RequestMapping( value = {"/get_DCAEPriorityValues"}, method = {org.springframework.web.bind.annotation.RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getDCAEPriorityValuesData(HttpServletRequest request, HttpServletResponse response); void prePopulateDCAEMSPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity); Map<String, String> convert(String str, String split); @SuppressWarnings("unchecked") void readFile(PolicyRestAdapter policyAdapter, PolicyEntity entity); @SuppressWarnings({"rawtypes", "unchecked"}) void readRecursivlyJSONContent(Map<String, ?> map, Map<String, Object> data); String getPolicyScope(String value); Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap); @RequestMapping( value = {"/ms_dictionary/set_MSModelData"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) void SetMSModelData(HttpServletRequest request, HttpServletResponse response); void cleanUp(String path); void checkZipDirectory(String zipDirectory); Map<String, String> getAttributesListRefMap(); Map<String, LinkedList<String>> getArrayTextList(); Map<String, String> getSigRules(); void setSigRules(Map<String, String> sigRules); static final String DATATYPE; static final String PROPERTIES; static final String TYPE; static final String STRING; static final String INTEGER; static final String LIST; static final String DEFAULT; static final String REQUIRED; static final String MATCHABLE; static final String MANYFALSE; }