summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java77
1 files changed, 29 insertions, 48 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java
index 681702bf..04c1f2bc 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java
@@ -65,6 +65,31 @@ public class UsageListController extends RestrictedBaseController {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UsageListController.class);
+ private void addUsers2jsonArray(JSONArray ja,HashMap activeUsers,String httpSessionId)
+ {
+ List<UserRowBean> rows = UsageUtils.getActiveUsers(activeUsers);
+ for (UserRowBean userRowBean : rows)
+ ja.put(userRowBean2json(userRowBean,httpSessionId));
+ }
+
+ private JSONObject userRowBean2json(UserRowBean userRowBean,String httpSessionId)
+ {
+ JSONObject jo = new JSONObject();
+ jo.put("id", userRowBean.getId());
+ jo.put("lastName", userRowBean.getLastName());
+ jo.put("email", userRowBean.getEmail());
+ jo.put("lastAccess", userRowBean.getLastAccess());
+ jo.put("remaining", userRowBean.getRemaining());
+ jo.put("sessionId", userRowBean.getSessionId());
+ if (!httpSessionId.equals(userRowBean.getSessionId())) {
+ jo.put("delete", "yes");
+ } else {
+ jo.put("delete", "no");
+ }
+
+ return jo;
+ }
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@RequestMapping(value = { "/usage_list" }, method = RequestMethod.GET)
public ModelAndView usageList(HttpServletRequest request) {
@@ -76,24 +101,10 @@ public class UsageListController extends RestrictedBaseController {
activeUsers.put(httpSession.getId(), httpSession);
httpSession.getServletContext().setAttribute("activeUsers", activeUsers);
}
- List<UserRowBean> rows = UsageUtils.getActiveUsers(activeUsers);
+
JSONArray ja = new JSONArray();
try {
- for (UserRowBean userRowBean : rows) {
- JSONObject jo = new JSONObject();
- jo.put("id", userRowBean.getId());
- jo.put("lastName", userRowBean.getLastName());
- jo.put("email", userRowBean.getEmail());
- jo.put("lastAccess", userRowBean.getLastAccess());
- jo.put("remaining", userRowBean.getRemaining());
- jo.put("sessionId", userRowBean.getSessionId());
- if (!(httpSession.getId().equals(userRowBean.getSessionId()))) {
- jo.put("delete", "yes");
- } else {
- jo.put("delete", "no");
- }
- ja.put(jo);
- }
+ addUsers2jsonArray(ja,activeUsers,httpSession.getId());
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "usageList failed", e);
}
@@ -113,24 +124,9 @@ public class UsageListController extends RestrictedBaseController {
activeUsers.put(httpSession.getId(), httpSession);
httpSession.getServletContext().setAttribute("activeUsers", activeUsers);
}
- List<UserRowBean> rows = UsageUtils.getActiveUsers(activeUsers);
JSONArray ja = new JSONArray();
try {
- for (UserRowBean userRowBean : rows) {
- JSONObject jo = new JSONObject();
- jo.put("id", userRowBean.getId());
- jo.put("lastName", userRowBean.getLastName());
- jo.put("email", userRowBean.getEmail());
- jo.put("lastAccess", userRowBean.getLastAccess());
- jo.put("remaining", userRowBean.getRemaining());
- jo.put("sessionId", userRowBean.getSessionId());
- if (!(httpSession.getId().equals(userRowBean.getSessionId()))) {
- jo.put("delete", "yes");
- } else {
- jo.put("delete", "no");
- }
- ja.put(jo);
- }
+ addUsers2jsonArray(ja,activeUsers,httpSession.getId());
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getUsageList failed", e);
}
@@ -154,24 +150,9 @@ public class UsageListController extends RestrictedBaseController {
UsageUtils.getActiveUsersAfterDelete(activeUsers, data);
HttpSession httpSession = request.getSession();
- List<UserRowBean> rows = UsageUtils.getActiveUsers(activeUsers);
JSONArray ja = new JSONArray();
try {
- for (UserRowBean userRowBean : rows) {
- JSONObject jo = new JSONObject();
- jo.put("id", userRowBean.getId());
- jo.put("lastName", userRowBean.getLastName());
- jo.put("email", userRowBean.getEmail());
- jo.put("lastAccess", userRowBean.getLastAccess());
- jo.put("remaining", userRowBean.getRemaining());
- jo.put("sessionId", userRowBean.getSessionId());
- if (!(httpSession.getId().equals(userRowBean.getSessionId()))) {
- jo.put("delete", "yes");
- } else {
- jo.put("delete", "no");
- }
- ja.put(jo);
- }
+ addUsers2jsonArray(ja,activeUsers,httpSession.getId());
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "removeSession failed", e);
}