summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java23
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/CacheAdminController.java31
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FnMenuController.java34
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java14
4 files changed, 52 insertions, 50 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java
index 5058c064..a18cdc1c 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/SwingWorker.java
@@ -53,7 +53,6 @@ import javax.swing.SwingUtilities;
*/
public abstract class SwingWorker {
private Object value; // see getValue(), setValue()
- private Thread thread;
/**
* Class to maintain reference to current worker thread
@@ -136,21 +135,17 @@ public abstract class SwingWorker {
* and then exit.
*/
public SwingWorker() {
- final Runnable doFinished = new Runnable() {
- public void run() { finished(); }
- };
-
- Runnable doConstruct = new Runnable() {
- public void run() {
- try {
- setValue(construct());
- }
- finally {
- threadVar.clear();
- }
+ final Runnable doFinished = () -> finished();
- SwingUtilities.invokeLater(doFinished);
+ Runnable doConstruct = () -> {
+ try {
+ setValue(construct());
}
+ finally {
+ threadVar.clear();
+ }
+
+ SwingUtilities.invokeLater(doFinished);
};
Thread t = new Thread(doConstruct);
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/CacheAdminController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/CacheAdminController.java
index 34ad676e..9809b78a 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/CacheAdminController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/CacheAdminController.java
@@ -37,6 +37,8 @@
*/
package org.onap.portalapp.controller.core;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
@@ -71,6 +73,8 @@ import com.fasterxml.jackson.databind.SerializationFeature;
public class CacheAdminController extends RestrictedBaseController {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CacheAdminController.class);
+ private static final String CACHE_NAME = "cacheName";
+ private static final String APPLICATION_JSON = "application/json";
private JCSAdminBean jcsAdminBean = new JCSAdminBean();
@@ -94,9 +98,9 @@ public class CacheAdminController extends RestrictedBaseController {
@RequestMapping(value = { "/jcs_admin/clearRegion" }, method = RequestMethod.GET)
public void clearRegion(HttpServletRequest request, HttpServletResponse response) throws IOException {
- String cacheName = request.getParameter("cacheName");
+ String cacheName = request.getParameter(CACHE_NAME);
clearCacheRegion(cacheName);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
PrintWriter out = response.getWriter();
out.write(getRegions().toString());
}
@@ -104,7 +108,7 @@ public class CacheAdminController extends RestrictedBaseController {
@RequestMapping(value = { "/jcs_admin/clearAll" }, method = RequestMethod.GET)
public void clearAll(HttpServletResponse response) throws IOException {
clearAllRegions();
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
PrintWriter out = response.getWriter();
out.write(getRegions().toString());
}
@@ -112,16 +116,16 @@ public class CacheAdminController extends RestrictedBaseController {
@RequestMapping(value = { "/jcs_admin/clearItem" }, method = RequestMethod.GET)
public void clearItem(HttpServletRequest request, HttpServletResponse response) throws IOException {
String keyName = request.getParameter("keyName");
- String cacheName = request.getParameter("cacheName");
+ String cacheName = request.getParameter(CACHE_NAME);
clearCacheRegionItem(cacheName, keyName);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
PrintWriter out = response.getWriter();
out.write(getRegions().toString());
}
@RequestMapping(value = { "/jcs_admin/showItemDetails" }, method = RequestMethod.GET)
public void showItemDetails(HttpServletRequest request, HttpServletResponse response) throws IOException {
- String cacheName = request.getParameter("cacheName");
+ String cacheName = request.getParameter(CACHE_NAME);
String keyName = request.getParameter("keyName");
String details = null;
try {
@@ -131,20 +135,20 @@ public class CacheAdminController extends RestrictedBaseController {
logger.error(EELFLoggerDelegate.errorLogger, "showItemDetails failed for cache name " + cacheName, e);
}
JSONObject j = new JSONObject(details);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
PrintWriter out = response.getWriter();
out.write(j.toString());
}
@RequestMapping(value = { "/jcs_admin/showRegionDetails" }, method = RequestMethod.GET)
public void showRegionDetails(HttpServletRequest request, HttpServletResponse response) {
- String cacheName = request.getParameter("cacheName");
+ String cacheName = request.getParameter(CACHE_NAME);
ObjectMapper mapper = new ObjectMapper();
try {
String details = getRegionStats(cacheName);
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(details));
JSONObject j = new JSONObject(msg);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
PrintWriter out = response.getWriter();
out.write(j.toString());
} catch (Exception e) {
@@ -163,9 +167,9 @@ public class CacheAdminController extends RestrictedBaseController {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
for (CacheRegionInfo cri : regions) {
- if (cri.getCache().getCacheName() != null && !cri.getCache().getCacheName().equals("[object Object]")) {
+ if (cri.getCache().getCacheName() != null && !"[object Object]".equals(cri.getCache().getCacheName())) {
JSONObject jo = new JSONObject();
- jo.put("cacheName", cri.getCache().getCacheName());
+ jo.put(CACHE_NAME, cri.getCache().getCacheName());
jo.put("size", cri.getCache().getSize());
jo.put("byteCount", cri.getByteCount());
jo.put("status", cri.getStatus());
@@ -187,11 +191,10 @@ public class CacheAdminController extends RestrictedBaseController {
private String getRegionStats(String cacheName) throws CacheException {
JCS cache = JCS.getInstance(cacheName);
- String stats = cache.getStats();
- return stats;
+ return cache.getStats();
}
- private String getItemDetails(String cacheName, String keyName) throws Exception {
+ private String getItemDetails(String cacheName, String keyName) throws CacheException,JsonProcessingException {
JCS cache = JCS.getInstance(cacheName);
ICacheElement element = cache.getCacheElement(keyName);
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FnMenuController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FnMenuController.java
index e4c862fd..8f49b640 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FnMenuController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FnMenuController.java
@@ -74,35 +74,35 @@ public class FnMenuController extends RestrictedBaseController {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnMenuController.class);
+ private static final String UTF8 = "UTF-8";
+
@Autowired
FnMenuService service;
@Autowired
FunctionalMenuListService functionalMenuListService;
- private String viewName;
-
@RequestMapping(value = { "/admin_fn_menu/get_parent_list" }, method = RequestMethod.GET)
- public void getParentList(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void getParentList(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException {
ObjectMapper mapper = new ObjectMapper();
try {
response.getWriter().write(mapper.writeValueAsString(service.getParentList()));
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getParentListFailed", e);
- response.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
out.write("An error occurred in the getParentList () ");
}
}
@RequestMapping(value = { "/admin_fn_menu/get_function_cd_list" }, method = RequestMethod.GET)
- public void getFunctionCDList(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void getFunctionCDList(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException {
ObjectMapper mapper = new ObjectMapper();
try {
response.getWriter().write(mapper.writeValueAsString(functionalMenuListService.getFunctionCDList(request)));
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getFunctionCDList", e);
- response.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
out.write("An error occurred in the getFunctionCDList ()");
}
@@ -153,7 +153,8 @@ public class FnMenuController extends RestrictedBaseController {
}
@RequestMapping(value = { "/admin_fn_menu/updateFnMenu" }, method = RequestMethod.POST)
- public ModelAndView updateFnMenu(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ModelAndView updateFnMenu(HttpServletRequest request, HttpServletResponse response)
+ throws java.io.IOException, java.io.UnsupportedEncodingException {
try {
ObjectMapper mapper = new ObjectMapper();
@@ -166,9 +167,9 @@ public class FnMenuController extends RestrictedBaseController {
request.getSession().removeAttribute(SystemProperties.LEFT_MENU_CHILDREND);
request.getSession().removeAttribute(SystemProperties.LEFT_MENU_PARENT);
- 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(service.getMenuItem(fnMenuItem.getId()));
@@ -179,8 +180,8 @@ public class FnMenuController extends RestrictedBaseController {
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "updateFnMenu failed", e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
out.write("An error occurred in the updateFnMenu () ");
}
@@ -189,7 +190,8 @@ public class FnMenuController extends RestrictedBaseController {
}
@RequestMapping(value = { "/admin_fn_menu/removeMenuItem" }, method = RequestMethod.POST)
- public ModelAndView removeFnMenu(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ModelAndView removeFnMenu(HttpServletRequest request, HttpServletResponse response)
+ throws java.io.IOException, java.io.UnsupportedEncodingException {
try {
ObjectMapper mapper = new ObjectMapper();
@@ -198,9 +200,9 @@ public class FnMenuController extends RestrictedBaseController {
Menu fnMenuItem = mapper.readValue(root.get("fnMenuItem").toString(), Menu.class);
Menu fnMenuItemRow = service.getMenuItemRow(fnMenuItem.getId());
service.removeMenuItem(fnMenuItemRow);
- 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(service.getMenuItem(fnMenuItem.getId()));
out.write(responseString);
@@ -209,8 +211,8 @@ public class FnMenuController extends RestrictedBaseController {
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "removeFnMenu failed", e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
out.write("An error occurred in the removeFnMenu ()");
}
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java
index 5ca764c1..bedd9c41 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java
@@ -74,6 +74,8 @@ public class MenuListController extends RestrictedBaseController {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MenuListController.class);
+ private static final String APPLICATION_JSON = "application/json";
+
@Autowired
private FnMenuService fnMenuService;
@Autowired
@@ -110,7 +112,7 @@ public class MenuListController extends RestrictedBaseController {
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(parentList),
mapper.writeValueAsString(childItemList), userName);
JSONObject j = new JSONObject(msg);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
response.getWriter().write(j.toString());
logger.debug(EELFLoggerDelegate.debugLogger, "getMenu ends");
} catch (Exception e) {
@@ -132,12 +134,12 @@ public class MenuListController extends RestrictedBaseController {
try {
String appName = (String) session
.getAttribute(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME));
- if (appName != null && appName.equals("app_display_name")) {
+ if (appName != null && "app_display_name".equals(appName)) {
appName = "";
}
JsonMessage msg = new JsonMessage(appName);
JSONObject j = new JSONObject(msg);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
response.getWriter().write(j.toString());
logger.debug(EELFLoggerDelegate.debugLogger, "getAppName ends");
} catch (Exception e) {
@@ -194,7 +196,7 @@ public class MenuListController extends RestrictedBaseController {
String contextId = null;
if (request.getCookies() != null) {
for (Cookie ck : request.getCookies()) {
- if (ck.getName().equalsIgnoreCase("EPService"))
+ if ("EPService".equalsIgnoreCase(ck.getName()))
contextId = ck.getValue();
}
}
@@ -207,7 +209,7 @@ public class MenuListController extends RestrictedBaseController {
model.put(sharedContext.getCkey(), sharedContext.getCvalue());
}
JSONObject j = new JSONObject(model);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
response.getWriter().write(j.toString());
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getUserInfo failed", e);
@@ -248,7 +250,7 @@ public class MenuListController extends RestrictedBaseController {
isAppCentralized = true;
map.put("isAppCentralized", Boolean.toString(isAppCentralized));
JSONObject j = new JSONObject(map);
- response.setContentType("application/json");
+ response.setContentType(APPLICATION_JSON);
response.getWriter().write(j.toString());
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "Failed to serialize JSON", e);