diff options
author | Christopher Lott (cl778h) <clott@research.att.com> | 2017-09-07 08:52:41 -0400 |
---|---|---|
committer | Christopher Lott (cl778h) <clott@research.att.com> | 2017-09-07 08:54:52 -0400 |
commit | 8cd208ebaa33627daf05d8ffff7b28e53a7067d0 (patch) | |
tree | 0b07ec3c6305c46f34eae69d8fb6fa824aaae256 /ecomp-sdk/epsdk-fw | |
parent | b52d4cebc430a083ec1e6881c4f01dfe709ac726 (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-fw')
23 files changed, 165 insertions, 159 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java index 182d2675..2fd141a0 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalRestAPIService.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java index aa11aafe..3f6614a4 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/IPortalUebAPIService.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java index 6ae2cdd8..6e55c9e3 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalAPIResponse.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 * @@ -51,10 +51,10 @@ public class PortalAPIResponse { * Optional if status is ok */ private String message; - + public PortalAPIResponse(boolean isOk, String msg) { - status = (isOk? "ok" : "error"); - message = msg; + status = isOk ? "ok" : "error"; + message = msg; } public String getStatus() { diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java index 869500f2..83dc9c43 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxy.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 * @@ -88,11 +88,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; @WebServlet(urlPatterns = { PortalApiConstants.API_PREFIX + "/*" }) public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPIService { + private static final long serialVersionUID = 1L; - private static final String contentTypeAppJson = "application/json"; + private static final String APPLICATION_JSON = "application/json"; - private final Log logger = LogFactory.getLog(getClass()); + private static final Log logger = LogFactory.getLog(PortalRestAPIProxy.class); /** * Mapper for JSON to object etc. @@ -163,8 +164,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer requestBody = mapper.writeValueAsString(bodyMap); responseJson = RestWebServiceClient.getInstance().postPortalContent(storeAnalyticsContextPath, userId, credential, null, credential, credential, "application/json", requestBody, true); - if (logger.isDebugEnabled()) - logger.debug("doPost: postPortalContent returns " + responseJson); + logger.debug("doPost: postPortalContent returns " + responseJson); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception ex) { logger.error("doPost: " + storeAnalyticsContextPath + " caught exception", ex); @@ -172,7 +172,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } - writeAndFlush(response, contentTypeAppJson, responseJson); + writeAndFlush(response, APPLICATION_JSON, responseJson); return; } // post analytics @@ -186,10 +186,9 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer return; } if (!secure) { - if (logger.isDebugEnabled()) - logger.debug("doPost: isAppAuthenticated answered false"); + logger.debug("doPost: isAppAuthenticated answered false"); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - writeAndFlush(response, contentTypeAppJson, buildJsonResponse(false, "Not authorized")); + writeAndFlush(response, APPLICATION_JSON, buildJsonResponse(false, "Not authorized")); return; } @@ -212,8 +211,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (requestUri.endsWith("/updateSessionTimeOuts")) { if (updateSessionTimeOuts(requestBody)) { - if (logger.isDebugEnabled()) - logger.debug("doPost: updated session timeouts"); + logger.debug("doPost: updated session timeouts"); response.setStatus(HttpServletResponse.SC_OK); } else { String msg = "Failed to update session time outs"; @@ -227,8 +225,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer portalJSessionId = ""; } if (timeoutSession(portalJSessionId)) { - if (logger.isDebugEnabled()) - logger.debug("doPost: timed out session"); + logger.debug("doPost: timed out session"); response.setStatus(HttpServletResponse.SC_OK); } else { String msg = "Failed to timeout session"; @@ -242,8 +239,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer try { EcompUser user = mapper.readValue(requestBody, EcompUser.class); pushUser(user); - if (logger.isDebugEnabled()) - logger.debug("doPost: pushUser: success"); + logger.debug("doPost: pushUser: success"); responseJson = buildJsonResponse(true, null); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception ex) { @@ -258,8 +254,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer try { EcompUser user = mapper.readValue(requestBody, EcompUser.class); editUser(loginId, user); - if (logger.isDebugEnabled()) - logger.debug("doPost: editUser: success"); + logger.debug("doPost: editUser: success"); responseJson = buildJsonResponse(true, null); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception ex) { @@ -277,8 +272,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer }; List<EcompRole> roles = mapper.readValue(requestBody, typeRef); pushUserRole(loginId, roles); - if (logger.isDebugEnabled()) - logger.debug("doPost: pushUserRole: success"); + logger.debug("doPost: pushUserRole: success"); responseJson = buildJsonResponse(true, null); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception ex) { @@ -298,7 +292,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer responseJson = buildJsonResponse(ex); } - writeAndFlush(response, contentTypeAppJson, responseJson); + writeAndFlush(response, APPLICATION_JSON, responseJson); } @@ -310,17 +304,16 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer // Should never happen due to checks in init() logger.error("doGet: no service class instance"); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - writeAndFlush(response, contentTypeAppJson, + writeAndFlush(response, APPLICATION_JSON, buildJsonResponse(false, "Misconfigured - no instance of service class")); return; } String requestUri = request.getRequestURI(); - String responseString = ""; - String contentType = contentTypeAppJson; - + String contentType = APPLICATION_JSON; String webAnalyticsContextPath = "/analytics"; if (requestUri.endsWith(PortalApiConstants.API_PREFIX + webAnalyticsContextPath)) { + String responseString; String userId; try { userId = getUserId(request); @@ -360,7 +353,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer } catch (PortalAPIException ex) { logger.error("doGet: isAppAuthenticated threw exception", ex); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - writeAndFlush(response, contentTypeAppJson, buildJsonResponse(false, "Failed to authenticate request")); + writeAndFlush(response, APPLICATION_JSON, buildJsonResponse(false, "Failed to authenticate request")); return; } @@ -368,16 +361,14 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (logger.isDebugEnabled()) logger.debug("doGet: isAppAuthenticated answered false"); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - writeAndFlush(response, contentTypeAppJson, buildJsonResponse(false, "Not authorized")); + writeAndFlush(response, APPLICATION_JSON, buildJsonResponse(false, "Not authorized")); return; } String responseJson = null; try { // Ignore any request body in a GET. - // String requestBody = readRequestBody(request); - if (logger.isDebugEnabled()) - logger.debug("doGet: URI = " + requestUri); + logger.debug("doGet: URI = " + requestUri); /* * 1. /roles <-- get roles @@ -392,8 +383,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer if (requestUri.endsWith("/sessionTimeOuts")) { responseJson = getSessionTimeOuts(); if (responseJson != null && responseJson.length() > 0) { - if (logger.isDebugEnabled()) - logger.debug("doGet: got session timeouts"); + logger.debug("doGet: got session timeouts"); response.setStatus(HttpServletResponse.SC_OK); } else { String msg = "Failed to get session time outs"; @@ -467,7 +457,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); responseJson = buildJsonResponse(ex); } - writeAndFlush(response, contentTypeAppJson, responseJson); + writeAndFlush(response, APPLICATION_JSON, responseJson); } public String getSessionTimeOuts() { @@ -567,7 +557,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer try { bufferedReader.close(); } catch (IOException ex) { - throw ex; + logger.error("readRequestBody", ex); } } } @@ -595,6 +585,7 @@ public class PortalRestAPIProxy extends HttpServlet implements IPortalRestAPISer json = mapper.writeValueAsString(response); } catch (JsonProcessingException ex) { // Truly should never, ever happen + logger.error("buildJsonResponse", ex); json = "{ \"status\": \"error\",\"message\":\"" + ex.toString() + "\" }"; } return json; diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java index 1f9bfd07..fb2e6f86 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/SessionCommunicationService.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 * @@ -47,7 +47,7 @@ import org.apache.commons.logging.LogFactory; public class SessionCommunicationService { - protected static final Log logger = LogFactory.getLog(SessionCommunicationService.class); + private static final Log logger = LogFactory.getLog(SessionCommunicationService.class); /** * Calls the ECOMP Portal to retrieve the session slot check interval. @@ -87,13 +87,12 @@ public class SessionCommunicationService { logger.debug("getSessionSlotCheckInterval: Response Code : " + responseCode); } - StringBuffer response = new StringBuffer(); + StringBuilder response = new StringBuilder(); try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"))) { String inputLine; while ((inputLine = in.readLine()) != null) response.append(inputLine); - } - catch (Exception ex) { + } catch (Exception ex) { logger.error("getSessionSlotCheckInterval failed to read stream", ex); } return response.toString(); @@ -124,7 +123,6 @@ public class SessionCommunicationService { String uebKey, String sessionTimeoutMap) { try { - String url = ecompRestURL + "/extendSessionTimeOuts"; URL obj = new URL(url); @@ -145,16 +143,14 @@ public class SessionCommunicationService { con.getOutputStream().flush(); con.getOutputStream().close(); - // con.set - int responseCode = con.getResponseCode(); if (logger.isDebugEnabled()) { logger.debug("requestPortalSessionTimeoutExtension: Sending 'GET' request to URL : " + url); logger.debug("requestPortalSessionTimeoutExtension: Response Code : " + responseCode); } - StringBuffer response = new StringBuffer(); - try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { + StringBuilder response = new StringBuilder(); + try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; while ((inputLine = in.readLine()) != null) { response.append(inputLine); diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.java index a1109abe..3f7b8905 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/CipherUtilException.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.java index ccfb95b2..0f572073 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/exception/PortalAPIException.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java index f700f261..664ce41d 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutBindingListener.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,7 +56,7 @@ public class PortalTimeoutBindingListener implements HttpSessionBindingListener, @Override public void valueBound(HttpSessionBindingEvent event) { final HttpSession session = event.getSession(); - PortalTimeoutHandler.sessionMap.put((String) session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID), + PortalTimeoutHandler.getSessionMap().put((String) session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID), session); } @@ -65,7 +65,7 @@ public class PortalTimeoutBindingListener implements HttpSessionBindingListener, final HttpSession session = event.getSession(); String portalJSessionId = (String) session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID); logger.debug(portalJSessionId + " getting removed"); - PortalTimeoutHandler.sessionMap.remove(portalJSessionId); + PortalTimeoutHandler.getSessionMap().remove(portalJSessionId); } } diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java index 649fb747..3cc1eb98 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/PortalTimeoutHandler.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 * @@ -60,6 +60,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; */ public class PortalTimeoutHandler { + private static final Map<String, HttpSession> sessionMap = new Hashtable<String, HttpSession>(); + private static final Log logger = LogFactory.getLog(PortalTimeoutHandler.class); + private static ObjectMapper mapper = new ObjectMapper(); + private static PortalTimeoutHandler timeoutHandler; + protected static final SessionCommInf sessionComm = new SessionComm(); public interface SessionCommInf { @@ -69,13 +74,13 @@ public class PortalTimeoutHandler { } public static class SessionComm implements SessionCommInf { + + @Override public Integer fetchSessionSlotCheckInterval(String... params) { - String ecompRestURL = params[0]; String userName = params[1]; String pwd = params[2]; String uebKey = params[3]; - String sessionSlot = SessionCommunicationService.getSessionSlotCheckInterval(ecompRestURL, userName, pwd, uebKey); if (sessionSlot == null) @@ -83,25 +88,22 @@ public class PortalTimeoutHandler { return Integer.parseInt(sessionSlot); } + @Override public void extendSessionTimeOuts(String... params) { - String ecompRestURL = params[0]; String userName = params[1]; String pwd = params[2]; String uebKey = params[3]; String sessionTimeoutMap = params[4]; - SessionCommunicationService.requestPortalSessionTimeoutExtension(ecompRestURL, userName, pwd, uebKey, sessionTimeoutMap); } } - public static final Map<String, HttpSession> sessionMap = new Hashtable<String, HttpSession>(); - public static final Integer repeatInterval = 15 * 60; // 15 minutes - protected static final Log logger = LogFactory.getLog(PortalTimeoutHandler.class); - static ObjectMapper mapper = new ObjectMapper(); - private static PortalTimeoutHandler timeoutHandler; - + public static Map<String, HttpSession> getSessionMap() { + return sessionMap; + } + public static PortalTimeoutHandler getInstance() { if (timeoutHandler == null) timeoutHandler = new PortalTimeoutHandler(); @@ -141,9 +143,6 @@ public class PortalTimeoutHandler { // and with session replication the listener will fire in all tomcat // instances session.setAttribute(PortalApiConstants.PORTAL_JSESSION_BIND, new PortalTimeoutBindingListener()); - // sessionMap.put((String)session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID), - // session); - } /** @@ -166,7 +165,6 @@ public class PortalTimeoutHandler { try { logger.info(" Session getting destroyed - id: " + session.getId()); session.removeAttribute(PortalApiConstants.PORTAL_JSESSION_BIND); - // sessionMap.remove((String)session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID)); } catch (Exception e) { logger.error("sessionDestroyed failed", e); } @@ -204,21 +202,17 @@ public class PortalTimeoutHandler { public static String gatherSessionExtensions() { logger.debug("Session Management: gatherSessionExtensions"); - Map<String, PortalTimeoutVO> sessionTimeoutMap = new Hashtable<String, PortalTimeoutVO>(); + Map<String, PortalTimeoutVO> sessionTimeoutMap = new Hashtable<>(); String jsonMap = ""; for (String jSessionKey : sessionMap.keySet()) { try { - // get the expirytime in seconds + // get the expiry time in seconds HttpSession session = sessionMap.get(jSessionKey); Long lastAccessedTimeMilliSec = session.getLastAccessedTime(); Long maxIntervalMilliSec = session.getMaxInactiveInterval() * 1000L; - // Long currentTimeMilliSec = - // Calendar.getInstance().getTimeInMillis() ; - // (maxIntervalMilliSec - (currentTimeMilliSec - - // lastAccessedTimeMilliSec) + ; Calendar instance = Calendar.getInstance(); instance.setTimeInMillis(session.getLastAccessedTime()); logger.debug("Session Management: Last Accessed time for " + jSessionKey + ": " + instance.getTime()); @@ -237,9 +231,7 @@ public class PortalTimeoutHandler { } } - return jsonMap; - } /** @@ -251,10 +243,7 @@ public class PortalTimeoutHandler { */ public static boolean updateSessionExtensions(String sessionTimeoutMapStr) { logger.debug("Session Management: updateSessionExtensions"); - // Map<String,Object> sessionTimeoutMap = - // mapper.readValue(sessionTimeoutMapStr, Map.class); Map<String, PortalTimeoutVO> sessionTimeoutMap = null; - try { TypeReference<Hashtable<String, PortalTimeoutVO>> typeRef = new TypeReference<Hashtable<String, PortalTimeoutVO>>() { }; @@ -284,9 +273,6 @@ public class PortalTimeoutHandler { session.setMaxInactiveInterval((int) (maxTimeoutTimeMilliSec - lastAccessedTimeMilliSec) / 1000); logger.debug("Session Management: extended session for :" + session.getId() + " to :" + (int) (maxTimeoutTimeMilliSec / 1000)); - // System.out.println("!!!!!!!!!extended session for :" + - // session.getId() + " to :" + - // (int)(maxTimeoutTimeMilliSec/1000)); } } catch (Exception e) { logger.error("updateSessionExtensions failed to update session timeouts", e); @@ -381,7 +367,7 @@ public class PortalTimeoutHandler { - (lastAccessedTimeMilliSec - previousToLastAccessTime) <= portalSessionSlotCheckinMilliSec) { String jSessionKey = (String) session.getAttribute(PortalApiConstants.PORTAL_JSESSION_ID); - Map<String, PortalTimeoutVO> sessionTimeoutMap = new Hashtable<String, PortalTimeoutVO>(); + Map<String, PortalTimeoutVO> sessionTimeoutMap = new Hashtable<>(); Long sessionTimOutMilliSec = maxIntervalMilliSec + lastAccessedTimeMilliSec; sessionTimeoutMap.put(PortalTimeoutHandler.portalJSessionId(jSessionKey), diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.java index 8599a67c..3b422c3e 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserContextListener.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 * @@ -50,19 +50,21 @@ import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; @WebListener public class UserContextListener implements ServletContextListener { + @Override public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); // // create a map to store references to all the active // sessions and bind it to context scope. // - HashMap<String, HttpSession> activeUsers = new HashMap<String, HttpSession>(); + HashMap<String, HttpSession> activeUsers = new HashMap<>(); context.setAttribute(PortalApiConstants.ACTIVE_USERS_NAME, activeUsers); } /** * Needed for the ServletContextListener interface. */ + @Override public void contextDestroyed(ServletContextEvent event) { // To overcome the problem with losing the session references // during server restarts, put code here to serialize the diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserSessionListener.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserSessionListener.java index 95b2d44e..bf1732a0 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserSessionListener.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/listener/UserSessionListener.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 * @@ -60,7 +60,7 @@ public class UserSessionListener implements HttpSessionListener { private Log logger = LogFactory.getLog(getClass()); - public static Map<String, HttpSession> activeSessions = new Hashtable<String, HttpSession>(); + private static Map<String, HttpSession> activeSessions = new Hashtable<>(); public void init(ServletConfig config) { } @@ -68,6 +68,7 @@ public class UserSessionListener implements HttpSessionListener { /** * Adds sessions to the context-scoped HashMap when they begin. */ + @Override public void sessionCreated(HttpSessionEvent event) { HttpSession session = event.getSession(); ServletContext context = session.getServletContext(); @@ -85,6 +86,7 @@ public class UserSessionListener implements HttpSessionListener { * Removes sessions from the context-scoped HashMap when they expire or are * invalidated. */ + @Override public void sessionDestroyed(HttpSessionEvent event) { try { HttpSession session = event.getSession(); diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FavoritesClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FavoritesClient.java index 92ea75a8..6c1a63c3 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FavoritesClient.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FavoritesClient.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java index 7fc98c67..cd5d510f 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/FunctionalMenuClient.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java index 7c9f72a1..1533db79 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/rest/RestWebServiceClient.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 * @@ -365,7 +365,7 @@ public class RestWebServiceClient { con.getOutputStream().close(); int responseCode = con.getResponseCode(); - logger.debug("Response Code : " + responseCode); + logger.debug("RestWebServiceClient.post: response code " + responseCode); final String response = readAndCloseStream(con.getInputStream()); return response; } @@ -461,7 +461,7 @@ public class RestWebServiceClient { throws IOException { if (logger.isDebugEnabled()) - logger.debug("RestWebServiceClient.post to URL " + url); + logger.debug("RestWebServiceClient.delete to URL " + url); if (appName == null || appName.trim().length() == 0) appName = "Unknown"; if (requestId == null || requestId.trim().length() == 0) @@ -505,14 +505,13 @@ public class RestWebServiceClient { con.getOutputStream().close(); int responseCode = con.getResponseCode(); - logger.debug("Response Code : " + responseCode); + logger.debug("RestWebServiceClient.delete: response code " + responseCode); final String response = readAndCloseStream(con.getInputStream()); return response; } /** - * Reads content of string to a StringBuffer, decoded as UTF-8, and returns as - * string. + * Reads content of stream, decodes as UTF-8, and returns as string. * * @param inputStream * Stream to read @@ -520,17 +519,15 @@ public class RestWebServiceClient { * @throws IOException */ private String readAndCloseStream(InputStream inputStream) throws IOException { - StringBuffer sb = new StringBuffer(); - InputStreamReader in = null; - char[] buf = new char[8196]; - int bytes; - try { - in = new InputStreamReader(inputStream, "UTF-8"); + StringBuilder sb = new StringBuilder(); + try (InputStreamReader in = new InputStreamReader(inputStream, "UTF-8")) { + char[] buf = new char[8196]; + int bytes; while ((bytes = in.read(buf)) > 0) sb.append(new String(buf, 0, bytes)); - } finally { - if (in != null) - in.close(); + } + catch (Exception ex) { + logger.error("readAndCloseStream", ex); } return sb.toString(); } diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.java index f3125f03..ce70c717 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/CipherUtil.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 * @@ -145,14 +145,14 @@ public class CipherUtil { public static void main(String[] args) throws CipherUtilException { - String password = "Welcome123"; + String testValue = "Welcome123"; String encrypted; String decrypted; if (args.length != 2) { System.out.println("Default password testing... "); - System.out.println("Plain password: " + password); - encrypted = encrypt(password); + System.out.println("Plain password: " + testValue); + encrypted = encrypt(testValue); System.out.println("Encrypted password: " + encrypted); decrypted = decrypt(encrypted); System.out.println("Decrypted password: " + decrypted); diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java index 1419851a..eb931f5c 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiConstants.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java index 3d5ddae8..7f67818e 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/PortalApiProperties.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 * diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOFilter.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOFilter.java index 00afecaf..855786ba 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOFilter.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOFilter.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,18 +56,19 @@ public class SSOFilter implements Filter { private final Log logger = LogFactory.getLog(getClass()); + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, ServletException { try { if (PortalRestAPIProxy.getPortalRestApiServiceImpl().getUserId((HttpServletRequest) request) == null) { - String redirectURL = SSOUtil.getECOMPSSORedirectURL(((HttpServletRequest) request), - ((HttpServletResponse) response), - (((HttpServletRequest) request).getRequestURI() + String redirectURL = SSOUtil.getECOMPSSORedirectURL((HttpServletRequest) request, + (HttpServletResponse) response, + ((HttpServletRequest) request).getRequestURI() .substring(((HttpServletRequest) request).getContextPath().length() + 1) + (((HttpServletRequest) request).getQueryString() != null ? ("?" + ((HttpServletRequest) request).getQueryString()) - : ""))); + : "")); ((HttpServletResponse) response).sendRedirect(redirectURL); @@ -83,12 +84,14 @@ public class SSOFilter implements Filter { } + @Override public void destroy() { - + logger.trace("destroy called"); } + @Override public void init(FilterConfig arg0) throws ServletException { - // TODO Auto-generated method stub - + logger.trace("init called"); } + } diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.java index 9a5428f4..2d491cfa 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/SSOUtil.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 * @@ -69,7 +69,7 @@ public class SSOUtil { try { encodedAppURL = URLEncoder.encode(appURL, "UTF-8"); } catch (UnsupportedEncodingException ex) { - logger.error("getECOMPSSORedirectURL: Failed to encode app URL " + appURL); + logger.error("getECOMPSSORedirectURL: Failed to encode app URL " + appURL, ex); } String portalURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL); if (portalURL == null || portalURL.length() == 0) { diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompRole.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompRole.java index 5d757de7..5def2d43 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompRole.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompRole.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 * @@ -43,7 +43,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * This bean holds the information for a role in the role and user management * REST API. */ - @JsonIgnoreProperties(ignoreUnknown = true) public class EcompRole implements Comparable<EcompRole> { diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompUser.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompUser.java index 7c9ab8b3..fc097be5 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompUser.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/EcompUser.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 * @@ -210,4 +210,16 @@ public class EcompUser implements Comparable<EcompUser> { return this.loginId.compareTo(o.loginId); } + @Override + public boolean equals(Object other) { + if (this == other) + return true; + if (other == null) + return false; + if (!(other instanceof EcompUser)) + return false; + EcompUser castOther = (EcompUser) other; + return this.loginId.equals(castOther.getLoginId()); + } + } diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.java index ee075cf4..75cd3657 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/PortalTimeoutVO.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 * @@ -43,13 +43,12 @@ public class PortalTimeoutVO implements Comparable<PortalTimeoutVO> { private Long sessionTimOutMilliSec; public PortalTimeoutVO() { - + super(); } - public PortalTimeoutVO(String _jSessionId, Long _sessionTimOutMilliSec) { - setjSessionId(_jSessionId); - setSessionTimOutMilliSec(_sessionTimOutMilliSec); - + public PortalTimeoutVO(final String jSessionId, final Long sessionTimOutMilliSec) { + this.jSessionId = jSessionId; + this.sessionTimOutMilliSec = sessionTimOutMilliSec; } public String getjSessionId() { @@ -73,4 +72,16 @@ public class PortalTimeoutVO implements Comparable<PortalTimeoutVO> { return sessionTimOutMilliSec.compareTo(o.sessionTimOutMilliSec); } -}
\ No newline at end of file + @Override + public boolean equals(Object other) { + if (this == other) + return true; + if (other == null) + return false; + if (!(other instanceof PortalTimeoutVO)) + return false; + PortalTimeoutVO castOther = (PortalTimeoutVO) other; + return this.getSessionTimOutMilliSec() == castOther.getSessionTimOutMilliSec(); + } + +} diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/SharedContext.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/SharedContext.java index c8087e7b..7abde95d 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/SharedContext.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/restful/domain/SharedContext.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,8 +40,7 @@ package org.onap.portalsdk.core.restful.domain; import java.util.Objects; /** - * Bean that represents shared-context data transferred in JSON objects. This is - * a minimum example: + * Model for shared-context data. This is a minimum example: * * <PRE> * { @@ -56,10 +55,18 @@ public class SharedContext { // Response field indicates nothing else is present private String response; // Required fields when data is present - private String context_id, ckey, cvalue; + private String context_id; + private String ckey; + private String cvalue; private Long id, create_time; // Additional database fields from the DomainVO object. - private String created, modified, createdId, modifiedId, auditUserId, auditTrail, rowNum; + private String created; + private String modified; + private String createdId; + private String modifiedId; + private String auditUserId; + private String auditTrail; + private String rowNum; /** * Gets the response field. |