summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorburdziak <olaf.burdziakowski@nokia.com>2019-03-18 13:33:40 +0100
committerburdziak <olaf.burdziakowski@nokia.com>2019-03-18 13:33:40 +0100
commit20c3adbd42446e088a44469f57123778286e0b97 (patch)
tree404b999624bb62853635c5fe8f34f1de979158fa
parent1ded3bb69c5e91cd879d83e13d2b3295710cdb4f (diff)
Solve sonar issues
Change-Id: I5da7e2eebd496086d72bb6a96b229e34ac8a004e Issue-ID: PORTAL-523 Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/PostSearchController.java31
1 files changed, 17 insertions, 14 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/PostSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/PostSearchController.java
index d5137c2c..a8c3a5d6 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/PostSearchController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/PostSearchController.java
@@ -78,6 +78,9 @@ public class PostSearchController extends RestrictedBaseController {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PostSearchController.class);
+ private static final String POST_SEARCH_BEAN = "postSearchBean";
+ private static final String UTF8 = "UTF-8";
+
@SuppressWarnings("rawtypes")
private static List sortByList = null;
@@ -91,13 +94,13 @@ public class PostSearchController extends RestrictedBaseController {
private ProfileService profileService;
@RequestMapping(value = { "/post_search" }, method = RequestMethod.GET)
- public ModelAndView welcome(@ModelAttribute("postSearchBean") PostSearchBean postSearchBean) {
+ public ModelAndView welcome(@ModelAttribute(POST_SEARCH_BEAN) PostSearchBean postSearchBean) {
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
try {
- postSearchBean = new PostSearchBean();
- model.put("profileList", mapper.writeValueAsString(postSearchBean.getSearchResult()));
- model.put("postSearchBean", mapper.writeValueAsString(postSearchBean));
+ PostSearchBean postSearchBeanLocal = new PostSearchBean();
+ model.put("profileList", mapper.writeValueAsString(postSearchBeanLocal.getSearchResult()));
+ model.put(POST_SEARCH_BEAN, mapper.writeValueAsString(postSearchBeanLocal));
model.put("existingUsers", mapper.writeValueAsString(getExistingUsers()));
model.put("sortByList", mapper.writeValueAsString(getSortByList()));
} catch (Exception ex) {
@@ -109,13 +112,13 @@ public class PostSearchController extends RestrictedBaseController {
@RequestMapping(value = { "/post_search_sample" }, method = RequestMethod.GET)
public void getPostSearchProfile(HttpServletResponse response,
- @ModelAttribute("postSearchBean") PostSearchBean postSearchBean) {
+ @ModelAttribute(POST_SEARCH_BEAN) PostSearchBean postSearchBean) {
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
try {
- postSearchBean = new PostSearchBean();
- model.put("profileList", mapper.writeValueAsString(postSearchBean.getSearchResult()));
- model.put("postSearchBean", mapper.writeValueAsString(postSearchBean));
+ PostSearchBean postSearchBeanLocal = new PostSearchBean();
+ model.put("profileList", mapper.writeValueAsString(postSearchBeanLocal.getSearchResult()));
+ model.put(POST_SEARCH_BEAN, mapper.writeValueAsString(postSearchBeanLocal));
model.put("existingUsers", mapper.writeValueAsString(getExistingUsers()));
model.put("sortByList", mapper.writeValueAsString(getSortByList()));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -152,14 +155,14 @@ public class PostSearchController extends RestrictedBaseController {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- PostSearchBean postSearchBean = mapper.readValue(root.get("postSearchBean").toString(),
+ PostSearchBean postSearchBean = mapper.readValue(root.get(POST_SEARCH_BEAN).toString(),
PostSearchBean.class);
postSearchBean.setSearchResult(loadSearchResultData(request, postSearchBean));
- response.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(postSearchBean);
@@ -201,7 +204,7 @@ public class PostSearchController extends RestrictedBaseController {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
JsonNode root = mapper.readTree(request.getReader());
- PostSearchBean postSearch = mapper.readValue(root.get("postSearchBean").toString(), PostSearchBean.class);
+ PostSearchBean postSearch = mapper.readValue(root.get(POST_SEARCH_BEAN).toString(), PostSearchBean.class);
String errorMsg = "{}";
try {
postSearchService.process(request, postSearch);
@@ -212,9 +215,9 @@ public class PostSearchController extends RestrictedBaseController {
"Exception occurred while performing PostSearchController.process. Details:", e);
}
logger.info(EELFLoggerDelegate.auditLogger, "Import new user from webphone ");
- response.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
String postSearchString = mapper.writeValueAsString(postSearch);