summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web
diff options
context:
space:
mode:
authorChristopher Lott (cl778h) <clott@research.att.com>2017-09-07 08:52:41 -0400
committerChristopher Lott (cl778h) <clott@research.att.com>2017-09-07 08:54:52 -0400
commit8cd208ebaa33627daf05d8ffff7b28e53a7067d0 (patch)
tree0b07ec3c6305c46f34eae69d8fb6fa824aaae256 /ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web
parentb52d4cebc430a083ec1e6881c4f01dfe709ac726 (diff)
Adjust code for Sonar issues
Made non-functional updates to address static code analysis issues. Update license header with simple double-quote characters. Issue: PORTAL-72, PORTAL-90 Change-Id: Ic2c330daea07d721f0e6b350ebf03da97073f7ce Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/PeerBroadcastSocket.java26
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java192
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/AppUtils.java278
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/ControllerProperties.java38
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/FeedbackMessage.java88
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/JsonMessage.java32
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/MessagesList.java105
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java64
8 files changed, 375 insertions, 448 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/PeerBroadcastSocket.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/PeerBroadcastSocket.java
index e00e05b7..122f1333 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/PeerBroadcastSocket.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/PeerBroadcastSocket.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -56,14 +56,13 @@ public class PeerBroadcastSocket {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerBroadcastSocket.class);
- public static Map<String, Object> channelMap = new Hashtable<String, Object>();
- public Map<String, String> sessionMap = new Hashtable<String, String>();
- ObjectMapper mapper = new ObjectMapper();
+ private final static Map<String, Object> channelMap = new Hashtable<>();
+ private final Map<String, String> sessionMap = new Hashtable<>();
+ private final ObjectMapper mapper = new ObjectMapper();
@OnMessage
public void message(String message, Session session) {
try {
- // JSONObject jsonObject = new JSONObject(message);
@SuppressWarnings("unchecked")
Map<String, Object> jsonObject = mapper.readValue(message, Map.class);
try {
@@ -73,7 +72,7 @@ public class PeerBroadcastSocket {
sessionMap.put(session.getId(), from.toString());
}
} catch (Exception je) {
- logger.error(EELFLoggerDelegate.errorLogger, "Failed to read value" + je.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to read value", je);
}
try {
@@ -82,24 +81,23 @@ public class PeerBroadcastSocket {
return;
Object toSessionObj = channelMap.get(to);
if (toSessionObj != null) {
- Session toSession = null;
- toSession = (Session) toSessionObj;
+ Session toSession = (Session) toSessionObj;
toSession.getBasicRemote().sendText(message);
}
} catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Failed to send text" + ex.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to send text", ex);
}
} catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Failed" + ex.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed", ex);
}
}
@OnOpen
public void open(Session session) {
- logger.info(EELFLoggerDelegate.debugLogger, "Channel opened");
+ logger.debug(EELFLoggerDelegate.debugLogger, "Session opened {}", session);
}
@OnClose
@@ -111,12 +109,12 @@ public class PeerBroadcastSocket {
try {
((Session) sessObj).close();
} catch (IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Failed to close" + e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to close", e);
}
}
channelMap.remove(channel);
}
- logger.info(EELFLoggerDelegate.debugLogger, "Channel closed");
+ logger.debug(EELFLoggerDelegate.debugLogger, "Channel closed");
}
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java
index 76cb3b8f..f65a07cc 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -46,116 +46,92 @@ import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
import com.fasterxml.jackson.databind.ObjectMapper;
@ServerEndpoint("/webrtc")
public class WebRTCSocket {
-
-
- public static Map<String,Hashtable<String,Object[]>> channelMap = new Hashtable<String,Hashtable<String,Object[]>>();
- public Map<String,String> sessionMap = new Hashtable<String,String>();
- ObjectMapper mapper = new ObjectMapper();
-
-
- @OnMessage
- public void message(String message, Session session) {
- try {
- //JSONObject jsonObject = new JSONObject(message);
- @SuppressWarnings("unchecked")
- Map<String,Object> jsonObject = mapper.readValue(message, Map.class);
- try {
- Object isOpen = jsonObject.get("open");
- if(isOpen != null && (Boolean)isOpen == true) {
- String channel = (String) jsonObject.get("channel");
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WebRTCSocket.class);
+
+ private final static Map<String, Hashtable<String, Object[]>> channelMap = new Hashtable<String, Hashtable<String, Object[]>>();
+ private final Map<String, String> sessionMap = new Hashtable<String, String>();
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @OnMessage
+ public void message(String message, Session session) {
+ try {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> jsonObject = mapper.readValue(message, Map.class);
+ try {
+ Object isOpen = jsonObject.get("open");
+ if (isOpen != null && (Boolean) isOpen) {
+ String channel = (String) jsonObject.get("channel");
Object value = channelMap.get(channel);
- Hashtable<String,Object[]> sourceDestMap = null;
- if(value == null)
- sourceDestMap = new Hashtable<String,Object[]>();
- else
- sourceDestMap = (Hashtable<String,Object[]>) value;
-
- sourceDestMap.put(session.getId(), new Object[]{session});
- channelMap.put(channel, sourceDestMap);
- sessionMap.put(session.getId(), channel);
-
-
- }
- }
- catch (Exception je) {
- je.printStackTrace();
- }
-
- try{
-
- Object dataObj = jsonObject.get("data");
- if(dataObj == null)
- return;
- Map<String,Object> dataMapObj = ( Map<String,Object>)dataObj;
- //Object thisUserId = dataMapObj.get("userid");
- String channel = null;
- try{
- Object channelObj = dataMapObj.get("sessionid");
- if(channelObj != null)
- channel = (String) channelObj;
- else
- channel = (String) jsonObject.get("channel");
- }
- catch(Exception json) {
- json.printStackTrace();
- }
-
- /*
- JSONObject dataMapObj = (JSONObject)dataObj;
- Object thisUserId = dataMapObj.get("userid");
- String channel = (String) dataMapObj.get("sessionid");
- Hashtable<String,Object> sourceDestMap = sessionMap.get(channel);
-
- if(thisUserId != null && sourceDestMap.get((String)thisUserId) == null) {
- sourceDestMap.put((String)thisUserId, new Object[] {message, session});
- }
-
- for(String userId : sourceDestMap.keySet()){
- if(!userId.equals(thisUserId)) {
- Session otherSession = (Session) ((Object[])sourceDestMap.get(userId))[1];
- otherSession.getBasicRemote().sendText(message);
- }
- }
- */
-
- Hashtable<String,Object[]> sourceDestMap = channelMap.get(channel);
- if(sourceDestMap != null)
- for(String id : sourceDestMap.keySet()){
- if(!id.equals(session.getId())) {
- Session otherSession = (Session) ((Object[])sourceDestMap.get(id))[0];
- if(otherSession.isOpen())
- otherSession.getBasicRemote().sendText(mapper.writeValueAsString(dataObj));
- }
-
- }
- }
- catch (Exception je) {
- je.printStackTrace();
- }
-
- }
- catch (Exception je) {
- je.printStackTrace();
- }
- //System.out.println("Message received:" + message);
- }
-
- @OnOpen
- public void open(Session session) {
- // System.out.println("Channel opened");
- }
-
- @OnClose
- public void close(Session session) {
- String channel = sessionMap.get(session.getId());
- if (channel != null) {
- channelMap.remove(channel);
- }
- // System.out.println("Channel closed");
- }
+ Hashtable<String, Object[]> sourceDestMap;
+ if (value == null)
+ sourceDestMap = new Hashtable<>();
+ else
+ sourceDestMap = (Hashtable<String, Object[]>) value;
+
+ sourceDestMap.put(session.getId(), new Object[] { session });
+ channelMap.put(channel, sourceDestMap);
+ sessionMap.put(session.getId(), channel);
+
+ }
+ } catch (Exception je) {
+ logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je);
+ }
+
+ try {
+ Object dataObj = jsonObject.get("data");
+ if (dataObj == null)
+ return;
+ Map<String, Object> dataMapObj = (Map<String, Object>) dataObj;
+ String channel = null;
+ try {
+ Object channelObj = dataMapObj.get("sessionid");
+ if (channelObj != null)
+ channel = (String) channelObj;
+ else
+ channel = (String) jsonObject.get("channel");
+ } catch (Exception json) {
+ logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", json);
+ }
+
+
+ Hashtable<String, Object[]> sourceDestMap = channelMap.get(channel);
+ if (sourceDestMap != null)
+ for (String id : sourceDestMap.keySet()) {
+ if (!id.equals(session.getId())) {
+ Session otherSession = (Session) (sourceDestMap.get(id))[0];
+ if (otherSession.isOpen())
+ otherSession.getBasicRemote().sendText(mapper.writeValueAsString(dataObj));
+ }
+
+ }
+ } catch (Exception je) {
+ logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je);
+ }
+
+ } catch (Exception je) {
+ logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je);
+ }
+ }
+
+ @OnOpen
+ public void open(Session session) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Session opened {}", session);
+ }
+
+ @OnClose
+ public void close(Session session) {
+ String channel = sessionMap.get(session.getId());
+ if (channel != null) {
+ channelMap.remove(channel);
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "Channel closed");
+ }
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/AppUtils.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/AppUtils.java
index f6655399..135fb4cf 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/AppUtils.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/AppUtils.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -37,19 +37,8 @@
*/
package org.onap.portalsdk.core.web.support;
-import java.io.File;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -59,112 +48,99 @@ import org.hibernate.Session;
import org.onap.portalsdk.core.exception.SessionExpiredException;
import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.StringUtils;
-
public class AppUtils {
-
-
-
- private static DataAccessService dataAccessService;
-
- private static AbstractCacheManager cacheManager;
- private static boolean applicationLocked;
+ private static DataAccessService dataAccessService;
+
+ private static AbstractCacheManager cacheManager;
+
+ private static boolean applicationLocked;
- private static Hashtable feedback = new Hashtable();
-
- private static DataSource datasource;
+ private static DataSource datasource;
- public static DataSource getDatasource() {
+ public static DataSource getDatasource() {
return datasource;
}
-
- @Autowired
+
+ public AppUtils() {
+ super();
+ }
+
+ @Autowired
public void setDatasource(DataSource datasource) {
AppUtils.datasource = datasource;
}
-
- public AppUtils() {
- }
-
- public static HttpSession getSession(HttpServletRequest request) {
- HttpSession session = null;
- if (request != null) {
- session = request.getSession(false);
- if (session == null) {
- throw new SessionExpiredException();
- }
- } else {
- throw new SessionExpiredException();
- }
- return session;
- }
-
- public static List getLookupList(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter, String dbOrderBy) {
- return getLookupList(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
- } // getLookupList
-
- public static List getLookupList(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter, String dbOrderBy, Session session) {
- String cacheKey = dbTable + "|" + dbValueCol + "|" + dbLabelCol + "|" + dbFilter + "|" + dbOrderBy;
- List list = getLookupListFromCache(cacheKey);
- if (list == null) {
- list = getDataAccessService().getLookupList(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
- if (list != null) {
- addLookupListToCache(cacheKey, list);
- }
- } // if
- return list;
- } // getLookupList
-
- private static List getLookupListFromCache(String key) {
- return (List)getObjectFromCache(key);
- } // getLookupListFromCache
-
- public static Object getObjectFromCache(String key) {
- if (isCacheManagerAvailable()) {
- return getCacheManager().getObject(key);
- } else {
- return null;
- }
- } // getObjectFromCache
-
- private static void addLookupListToCache(String key, List list) {
- addObjectToCache(key, list);
- } // addLookupListToCache
-
- public static void addObjectToCache(String key, Object o) {
- if (isCacheManagerAvailable()) {
- getCacheManager().putObject(key, o);
- }
- } // addObjectToCache
-
- @Autowired
- public void setCacheManager(AbstractCacheManager cacheManager) {
+
+ public static HttpSession getSession(HttpServletRequest request) {
+ if (request != null) {
+ HttpSession session = request.getSession(false);
+ if (session == null)
+ throw new SessionExpiredException();
+ else
+ return session;
+ } else {
+ throw new SessionExpiredException();
+ }
+ }
+
+ public static List getLookupList(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter,
+ String dbOrderBy) {
+ return getLookupList(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
+ } // getLookupList
+
+ public static List getLookupList(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter,
+ String dbOrderBy, Session session) {
+ String cacheKey = dbTable + "|" + dbValueCol + "|" + dbLabelCol + "|" + dbFilter + "|" + dbOrderBy;
+ List list = getLookupListFromCache(cacheKey);
+ if (list == null) {
+ list = getDataAccessService().getLookupList(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
+ if (list != null) {
+ addLookupListToCache(cacheKey, list);
+ }
+ } // if
+ return list;
+ } // getLookupList
+
+ private static List getLookupListFromCache(String key) {
+ return (List) getObjectFromCache(key);
+ } // getLookupListFromCache
+
+ public static Object getObjectFromCache(String key) {
+ if (isCacheManagerAvailable()) {
+ return getCacheManager().getObject(key);
+ } else {
+ return null;
+ }
+ } // getObjectFromCache
+
+ private static void addLookupListToCache(String key, List list) {
+ addObjectToCache(key, list);
+ } // addLookupListToCache
+
+ public static void addObjectToCache(String key, Object o) {
+ if (isCacheManagerAvailable()) {
+ getCacheManager().putObject(key, o);
+ }
+ } // addObjectToCache
+
+ @Autowired
+ public void setCacheManager(AbstractCacheManager cacheManager) {
this.cacheManager = cacheManager;
}
public static AbstractCacheManager getCacheManager() {
- return cacheManager;
- }
-
- public static boolean isCacheManagerAvailable() {
- return (getCacheManager() != null);
- }
-
- public void setFeedback(Hashtable feedback) {
- this.feedback = feedback;
- }
-
- public static boolean isApplicationLocked() {
- return applicationLocked;
- }
+ return cacheManager;
+ }
+
+ public static boolean isCacheManagerAvailable() {
+ return getCacheManager() != null;
+ }
+
+ public static boolean isApplicationLocked() {
+ return applicationLocked;
+ }
public static DataAccessService getDataAccessService() {
return dataAccessService;
@@ -176,56 +152,50 @@ public class AppUtils {
}
public static void setApplicationLocked(boolean locked) {
- applicationLocked = locked;
- }
-
- public static String getLookupValueByLabel(String label, String dbTable, String dbValueCol, String dbLabelCol) {
- if (label == null || label.equals("")) {
- return "";
- }
-
- List<org.onap.portalsdk.core.domain.Lookup> lstResult = getLookupListNoCache(dbTable, dbValueCol, dbLabelCol, dbLabelCol + "='" + label.replaceAll("'", "''") + "'", "");
- if (lstResult == null) {
- return "";
- }
- if (lstResult.size() > 0) {
- return ((org.onap.portalsdk.core.domain.Lookup)lstResult.toArray()[0]).getValue();
- } else {
- return "";
- }
- }
-
- public static String getLookupValueByLabel(String label, List lookupList) {
- Iterator i = null;
-
- if (label == null || label.equalsIgnoreCase("")) {
- return "";
- }
-
- if (lookupList == null || lookupList.size() == 0) {
- return "";
- }
-
- i = lookupList.iterator();
- while (i.hasNext()) {
- org.onap.portalsdk.core.domain.Lookup lookup = (org.onap.portalsdk.core.domain.Lookup)i.next();
-
- if (lookup.getLabel().equals(label)) {
- return lookup.getValue();
- }
- }
-
- return "";
-}
- public static List getLookupListNoCache(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter, String dbOrderBy) {
- return getLookupListNoCache(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
- } // getLookupListNoCache
+ applicationLocked = locked;
+ }
+ public static String getLookupValueByLabel(String label, String dbTable, String dbValueCol, String dbLabelCol) {
+ if (label == null || label.equals("")) {
+ return "";
+ }
+
+ List<org.onap.portalsdk.core.domain.Lookup> lstResult = getLookupListNoCache(dbTable, dbValueCol, dbLabelCol,
+ dbLabelCol + "='" + label.replaceAll("'", "''") + "'", "");
+ if (lstResult == null) {
+ return "";
+ }
+ if (!lstResult.isEmpty()) {
+ return ((org.onap.portalsdk.core.domain.Lookup) lstResult.toArray()[0]).getValue();
+ } else {
+ return "";
+ }
+ }
- public static List getLookupListNoCache(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter, String dbOrderBy, Session session) {
- return getDataAccessService().getLookupList(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
- } // getLookupListNoCache
-
-
+ public static String getLookupValueByLabel(String label, List lookupList) {
+ if (label == null || "".equals(label))
+ return "";
+ if (lookupList == null || lookupList.size() == 0)
+ return "";
+
+ Iterator i = lookupList.iterator();
+ while (i.hasNext()) {
+ org.onap.portalsdk.core.domain.Lookup lookup = (org.onap.portalsdk.core.domain.Lookup) i.next();
+ if (lookup.getLabel().equals(label)) {
+ return lookup.getValue();
+ }
+ }
+ return "";
+ }
+
+ public static List getLookupListNoCache(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter,
+ String dbOrderBy) {
+ return getLookupListNoCache(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
+ }
-} // AppUtils
+ public static List getLookupListNoCache(String dbTable, String dbValueCol, String dbLabelCol, String dbFilter,
+ String dbOrderBy, Session session) {
+ return getDataAccessService().getLookupList(dbTable, dbValueCol, dbLabelCol, dbFilter, dbOrderBy, null);
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/ControllerProperties.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/ControllerProperties.java
index c1c2f24a..31b810db 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/ControllerProperties.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/ControllerProperties.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -39,21 +39,21 @@ package org.onap.portalsdk.core.web.support;
public interface ControllerProperties {
- static final String TASK_GET = "get";
- static final String TASK_DELETE = "delete";
- static final String TASK_SAVE = "save";
- static final String TASK_PROCESS = "process";
- static final String TASK_TOGGLE_ACTIVE = "toggleActive";
- static final String TASK_DOWNLOAD = "download";
- static final String TASK_POPUP = "popup";
- static final String TASK_LOOKUP = "lookup";
- static final String TASK_ADD_ROW = "addRow";
- static final String TASK_APPROVE = "approve";
- static final String TASK_REJECT = "reject";
- static final String TASK_RESET = "reset";
- static final String TASK_ASSIGN = "assign";
- static final String TASK_CUT = "cut";
- static final String TASK_COPY = "copy";
- static final String TASK_PASTE = "paste";
- static final String TASK_SELECT = "select";
+ static final String TASK_GET = "get";
+ static final String TASK_DELETE = "delete";
+ static final String TASK_SAVE = "save";
+ static final String TASK_PROCESS = "process";
+ static final String TASK_TOGGLE_ACTIVE = "toggleActive";
+ static final String TASK_DOWNLOAD = "download";
+ static final String TASK_POPUP = "popup";
+ static final String TASK_LOOKUP = "lookup";
+ static final String TASK_ADD_ROW = "addRow";
+ static final String TASK_APPROVE = "approve";
+ static final String TASK_REJECT = "reject";
+ static final String TASK_RESET = "reset";
+ static final String TASK_ASSIGN = "assign";
+ static final String TASK_CUT = "cut";
+ static final String TASK_COPY = "copy";
+ static final String TASK_PASTE = "paste";
+ static final String TASK_SELECT = "select";
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/FeedbackMessage.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/FeedbackMessage.java
index e2dadb50..013d153b 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/FeedbackMessage.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/FeedbackMessage.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -39,60 +39,60 @@ package org.onap.portalsdk.core.web.support;
public class FeedbackMessage {
- private String message;
- private int messageType;
- private boolean keyed;
+ private String message;
+ private int messageType;
+ private boolean keyed;
- public static final int MESSAGE_TYPE_ERROR = 10;
- public static final int MESSAGE_TYPE_WARNING = 20;
- public static final int MESSAGE_TYPE_INFO = 30;
- public static final int MESSAGE_TYPE_SUCCESS = 40;
+ public static final int MESSAGE_TYPE_ERROR = 10;
+ public static final int MESSAGE_TYPE_WARNING = 20;
+ public static final int MESSAGE_TYPE_INFO = 30;
+ public static final int MESSAGE_TYPE_SUCCESS = 40;
- public static final String DEFAULT_MESSAGE_SUCCESS = "Update successful.";
- public static final String DEFAULT_MESSAGE_ERROR = "An error occurred while processing the request: ";
+ public static final String DEFAULT_MESSAGE_SUCCESS = "Update successful.";
+ public static final String DEFAULT_MESSAGE_ERROR = "An error occurred while processing the request: ";
- public static final String DEFAULT_MESSAGE_SYSTEM_ADMINISTRATOR = "If the problem persists, please contact your Administrator.";
+ public static final String DEFAULT_MESSAGE_SYSTEM_ADMINISTRATOR = "If the problem persists, please contact your Administrator.";
- public FeedbackMessage() {
- }
+ public FeedbackMessage() {
+ this(null);
+ }
- public FeedbackMessage(String message) {
- this(message, MESSAGE_TYPE_ERROR);
- }
+ public FeedbackMessage(String message) {
+ this(message, MESSAGE_TYPE_ERROR);
+ }
- public FeedbackMessage(String message, int messageType) {
- this(message, messageType, false);
- }
+ public FeedbackMessage(String message, int messageType) {
+ this(message, messageType, false);
+ }
- public FeedbackMessage(String message, int messageType, boolean keyed) {
- this.message = message;
- this.messageType = messageType;
- this.keyed = keyed;
- }
+ public FeedbackMessage(String message, int messageType, boolean keyed) {
+ this.message = message;
+ this.messageType = messageType;
+ this.keyed = keyed;
+ }
- public String getMessage() {
- return message;
- }
+ public String getMessage() {
+ return message;
+ }
- public int getMessageType() {
- return messageType;
- }
+ public int getMessageType() {
+ return messageType;
+ }
- public boolean isKeyed() {
- return keyed;
- }
+ public boolean isKeyed() {
+ return keyed;
+ }
- public void setMessage(String message) {
- this.message = message;
- }
+ public void setMessage(String message) {
+ this.message = message;
+ }
- public void setMessageType(int messageType) {
- this.messageType = messageType;
- }
-
- public void setKeyed(boolean keyed) {
- this.keyed = keyed;
- }
+ public void setMessageType(int messageType) {
+ this.messageType = messageType;
+ }
+ public void setKeyed(boolean keyed) {
+ this.keyed = keyed;
+ }
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/JsonMessage.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/JsonMessage.java
index 9b7a65ca..ce4cab3a 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/JsonMessage.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/JsonMessage.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -40,6 +40,7 @@ package org.onap.portalsdk.core.web.support;
import java.io.PrintWriter;
import java.io.StringWriter;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.onboarding.crossapi.PortalAPIResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -47,26 +48,30 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonMessage {
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonMessage.class);
+
private String data;
private String data2;
private String data3;
+
public JsonMessage(String data) {
super();
this.data = data;
}
- public JsonMessage(String data,String data2) {
+
+ public JsonMessage(String data, String data2) {
super();
this.data = data;
this.data2 = data2;
}
- public JsonMessage(String data,String data2,String data3) {
+ public JsonMessage(String data, String data2, String data3) {
super();
this.data = data;
this.data2 = data2;
this.data3 = data3;
}
-
+
public String getData() {
return data;
}
@@ -74,20 +79,23 @@ public class JsonMessage {
public void setData(String data) {
this.data = data;
}
+
public String getData2() {
return data2;
}
+
public void setData2(String data2) {
this.data2 = data2;
}
+
public String getData3() {
return data3;
}
+
public void setData3(String data3) {
this.data3 = data3;
}
-
-
+
/**
* Builds JSON object with status + message response body.
*
@@ -107,15 +115,16 @@ public class JsonMessage {
try {
json = new ObjectMapper().writeValueAsString(response);
} catch (JsonProcessingException ex) {
- // Truly should never, ever happen
+ // Truly should never happen
+ logger.error(EELFLoggerDelegate.errorLogger, "buildJsonResponse failed", ex);
json = "{ \"status\": \"error\",\"message\":\"" + ex.toString() + "\" }";
}
return json;
}
/**
- * Builds JSON object with status of error and message containing stack
- * trace for the specified throwable.
+ * Builds JSON object with status of error and message containing stack trace
+ * for the specified throwable.
*
* @param t
* Throwable with stack trace to use as message
@@ -131,6 +140,5 @@ public class JsonMessage {
t.printStackTrace(pw);
return buildJsonResponse(false, sw.toString());
}
-
-
+
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/MessagesList.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/MessagesList.java
index a3ab7896..a1d3e276 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/MessagesList.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/MessagesList.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -37,74 +37,73 @@
*/
package org.onap.portalsdk.core.web.support;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
public class MessagesList {
- private boolean successMessageDisplayed = true;
- private boolean includeCauseInCustomExceptions = false;
+ private boolean successMessageDisplayed = true;
+ private boolean includeCauseInCustomExceptions = false;
- private List successMessages;
- private List exceptionMessages;
+ private List successMessages;
+ private List exceptionMessages;
- public MessagesList() {
- setExceptionMessages(new ArrayList());
- setSuccessMessages(new ArrayList());
- }
+ public MessagesList() {
+ setExceptionMessages(new ArrayList());
+ setSuccessMessages(new ArrayList());
+ }
- public MessagesList(boolean displaySuccess) {
- this();
- setSuccessMessageDisplayed(displaySuccess);
- }
+ public MessagesList(boolean displaySuccess) {
+ this();
+ setSuccessMessageDisplayed(displaySuccess);
+ }
- public List getExceptionMessages() {
- return exceptionMessages;
- }
+ public List getExceptionMessages() {
+ return exceptionMessages;
+ }
- public List getSuccessMessages() {
- return successMessages;
- }
+ public List getSuccessMessages() {
+ return successMessages;
+ }
- public boolean isSuccessMessageDisplayed() {
- return successMessageDisplayed;
- }
+ public boolean isSuccessMessageDisplayed() {
+ return successMessageDisplayed;
+ }
- public boolean isIncludeCauseInCustomExceptions() {
- return includeCauseInCustomExceptions;
- }
+ public boolean isIncludeCauseInCustomExceptions() {
+ return includeCauseInCustomExceptions;
+ }
+ public void setExceptionMessages(List exceptionMessages) {
+ this.exceptionMessages = exceptionMessages;
+ }
- public void setExceptionMessages(List exceptionMessages) {
- this.exceptionMessages = exceptionMessages;
- }
+ public void setSuccessMessages(List successMessages) {
+ this.successMessages = successMessages;
+ }
- public void setSuccessMessages(List successMessages) {
- this.successMessages = successMessages;
- }
+ public void setSuccessMessageDisplayed(boolean successMessageDisplayed) {
+ this.successMessageDisplayed = successMessageDisplayed;
+ }
- public void setSuccessMessageDisplayed(boolean successMessageDisplayed) {
- this.successMessageDisplayed = successMessageDisplayed;
- }
+ public void setIncludeCauseInCustomExceptions(boolean includeCauseInCustomExceptions) {
+ this.includeCauseInCustomExceptions = includeCauseInCustomExceptions;
+ }
- public void setIncludeCauseInCustomExceptions(boolean includeCauseInCustomExceptions) {
- this.includeCauseInCustomExceptions = includeCauseInCustomExceptions;
- }
+ public void addSuccessMessage(FeedbackMessage message) {
+ getSuccessMessages().add(message);
+ }
+ public void addExceptionMessage(FeedbackMessage message) {
+ getExceptionMessages().add(message);
+ }
- public void addSuccessMessage(FeedbackMessage message) {
- getSuccessMessages().add(message);
- }
+ public boolean hasExceptionMessages() {
+ return !getExceptionMessages().isEmpty();
+ }
- public void addExceptionMessage(FeedbackMessage message) {
- getExceptionMessages().add(message);
- }
-
- public boolean hasExceptionMessages() {
- return!getExceptionMessages().isEmpty();
- }
-
- public boolean hasSuccessMessages() {
- return!getSuccessMessages().isEmpty();
- }
+ public boolean hasSuccessMessages() {
+ return !getSuccessMessages().isEmpty();
+ }
}
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java
index 98e437d9..5395521b 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java
@@ -6,7 +6,7 @@
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
+ * under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -19,7 +19,7 @@
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -44,6 +44,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
@@ -61,9 +62,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.menu.MenuBuilder;
import org.onap.portalsdk.core.restful.domain.EcompRole;
import org.onap.portalsdk.core.restful.domain.EcompUser;
-import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.springframework.beans.factory.annotation.Autowired;
@SuppressWarnings("rawtypes")
public class UserUtils {
@@ -72,10 +71,8 @@ public class UserUtils {
public static final String KEY_USER_ROLES_CACHE = "userRoles";
- private static DataAccessService dataAccessService;
-
public static void setUserSession(HttpServletRequest request, User user, Set applicationMenuData,
- Set businessDirectMenuData, String loginMethod , List<RoleFunction> roleFunctionList) {
+ Set businessDirectMenuData, String loginMethod, List<RoleFunction> roleFunctionList) {
HttpSession session = request.getSession(true);
UserUtils.clearUserSession(request); // let's clear the current user
@@ -97,7 +94,7 @@ public class UserUtils {
try {
licenseVarificationFlag = (Integer) context.getAttribute("licenseVerification");
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.debugLogger, "Error while get license varification " + e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "setUserSession failed on license verification", e);
}
String displayName = "";
if (SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME) != null)
@@ -146,14 +143,12 @@ public class UserUtils {
@SuppressWarnings("unchecked")
public static Set getRoleFunctions(HttpServletRequest request) {
- HashSet roleFunctions = null;
-// HashSet<RoleFunction> rolefun = null;
HttpSession session = request.getSession();
- roleFunctions = (HashSet) session
+ HashSet roleFunctions = (HashSet) session
.getAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME));
if (roleFunctions == null) {
- HashMap roles = getRoles(request);
+ Map roles = getRoles(request);
roleFunctions = new HashSet();
Iterator i = roles.keySet().iterator();
@@ -175,12 +170,10 @@ public class UserUtils {
return roleFunctions;
}
- public static HashMap getRoles(HttpServletRequest request) {
- HashMap roles = null;
-
+ public static Map getRoles(HttpServletRequest request) {
// HttpSession session = request.getSession();
HttpSession session = AppUtils.getSession(request);
- roles = (HashMap) session.getAttribute(SystemProperties.getProperty(SystemProperties.ROLES_ATTRIBUTE_NAME));
+ Map roles = (Map) session.getAttribute(SystemProperties.getProperty(SystemProperties.ROLES_ATTRIBUTE_NAME));
// if roles are not already cached, let's grab them from the user
// session
@@ -208,7 +201,7 @@ public class UserUtils {
}
@SuppressWarnings("unchecked")
- public static HashMap getAllUserRoles(User user) {
+ public static Map getAllUserRoles(User user) {
HashMap roles = new HashMap();
Iterator i = user.getRoles().iterator();
@@ -228,9 +221,9 @@ public class UserUtils {
}
@SuppressWarnings("unchecked")
- private static void addChildRoles(Role role, HashMap roles) {
+ private static void addChildRoles(Role role, Map roles) {
Set childRoles = role.getChildRoles();
- if (childRoles != null && childRoles.size() > 0) {
+ if (childRoles != null && !childRoles.isEmpty()) {
Iterator j = childRoles.iterator();
while (j.hasNext()) {
Role childRole = (Role) j.next();
@@ -243,8 +236,6 @@ public class UserUtils {
}
-
-
public static boolean hasRole(HttpServletRequest request, String roleKey) {
return getRoles(request).keySet().contains(new Long(roleKey));
}
@@ -268,27 +259,15 @@ public class UserUtils {
.getAttribute(SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_ATTRIBUTE_NAME));
}
- public static DataAccessService getDataAccessService() {
- return dataAccessService;
- }
-
- @Autowired
- public void setDataAccessService(DataAccessService dataAccessService) {
- UserUtils.dataAccessService = dataAccessService;
- }
-
public static int getUserId(HttpServletRequest request) {
return getUserIdAsLong(request).intValue();
}
public static Long getUserIdAsLong(HttpServletRequest request) {
Long userId = new Long(SystemProperties.getProperty(SystemProperties.APPLICATION_USER_ID));
-
- if (request != null) {
- if (getUserSession(request) != null) {
+ if (request != null && getUserSession(request) != null)
userId = getUserSession(request).getId();
- }
- }
+
return userId;
}
@@ -313,8 +292,7 @@ public class UserUtils {
}
/**
- * Gets the full URL of the request by joining the request and any query
- * string.
+ * Gets the full URL of the request by joining the request and any query string.
*
* @param request
* @return Full URL of the request including query parameters
@@ -334,8 +312,8 @@ public class UserUtils {
}
/**
- * Gets or generates a request ID by searching for header X-ECOMP-RequestID.
- * If not found, generates a new random UUID.
+ * Gets or generates a request ID by searching for header X-ECOMP-RequestID. If
+ * not found, generates a new random UUID.
*
* @param request
* @return Request ID for the specified request
@@ -346,7 +324,7 @@ public class UserUtils {
String requestId = "";
try {
while (headerNames.hasMoreElements()) {
- String headerName = (String) headerNames.nextElement();
+ String headerName = headerNames.nextElement();
if (logger.isTraceEnabled())
logger.trace(EELFLoggerDelegate.debugLogger, "getRequestId: header {} = {}", headerName,
request.getHeader(headerName));
@@ -386,7 +364,7 @@ public class UserUtils {
userJson.setOrgId(user.getOrgId());
userJson.setPhone(user.getPhone());
userJson.setOrgUserId(user.getOrgUserId());
- Set<EcompRole> ecompRoles = new TreeSet<EcompRole>();
+ Set<EcompRole> ecompRoles = new TreeSet<>();
for (Role role : user.getRoles()) {
ecompRoles.add(convertToEcompRole(role));
}
@@ -408,6 +386,4 @@ public class UserUtils {
return ecompRole;
}
- }
-
-
+}