From: Manoop Talasila Date: Tue, 9 Oct 2018 19:27:44 +0000 (+0000) Subject: Merge "test cases for the remaining lines of equal method" X-Git-Tag: 2.3.0~5 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=27ee88a33231af6410b3c1e49bba83c556914a30;hp=0a8d7bcce19974bf63c024a030d3a5494f61d283;p=portal.git Merge "test cases for the remaining lines of equal method" --- diff --git a/deliveries/.env b/deliveries/.env index 3b2fa140..d1cc7d61 100644 --- a/deliveries/.env +++ b/deliveries/.env @@ -22,6 +22,13 @@ PORTAL_TAG=casablanca # Name of directory in apps container (NOT host) WEBAPPS_DIR=/opt/apache-tomcat-8.0.37/webapps +TOMCAT_DIR=/opt/apache-tomcat-8.0.37 + +# Certs +TOMCAT_KEY=keystoreONAP.keystore +TOMCAT_TRUST=truststoreONAPall.jks +CERT_PWD=changeit + # Required settings with default values. # Export shell environment variables on ALL hosts. diff --git a/deliveries/Apps_Users_OnBoarding_Script.sql b/deliveries/Apps_Users_OnBoarding_Script.sql index 74017a7a..583238f0 100644 --- a/deliveries/Apps_Users_OnBoarding_Script.sql +++ b/deliveries/Apps_Users_OnBoarding_Script.sql @@ -15,6 +15,15 @@ INSERT INTO `fn_app` (`app_id`, `app_name`, `app_image_url`, `app_description`, (8, 'CLI', 'images/cache/portal-345993588_92550.png', NULL, NULL, 'http://portal.api.simpledemo.onap.org:8080/', NULL, NULL, '', '', NULL, '', 'Y', 'Y', NULL, '', '', '', '', 1,'N',NULL), (9, 'MSB', 'images/cache/portal-345993588_92550.png', NULL, NULL, 'http://msb-iag:80/iui/microservices/index.html', NULL, NULL, '', '', NULL, '', 'Y', 'Y', NULL, '', '', '', '', 2,'N',NULL); +-- aaf centralize + +update fn_app set auth_central = 'Y' , auth_namespace = 'org.onap.portal' where app_id = 1; +update fn_app set auth_central = 'Y' , auth_namespace = 'org.onap.sdc' where app_id = 4; +update fn_app set auth_central = 'Y' , auth_namespace = 'org.onap.policy' where app_id = 5; +update fn_app set auth_central = 'Y' , auth_namespace = 'org.onap.vid' where app_id = 6; +update fn_app set auth_central = 'Y' , auth_namespace = 'org.onap.aai' where app_id = 7; + + -- insert SDC users user id2-8 Insert into fn_user (USER_ID, ORG_ID, MANAGER_ID,FIRST_NAME,MIDDLE_NAME,LAST_NAME,PHONE,FAX,CELLULAR,EMAIL,ADDRESS_ID,ALERT_METHOD_CD,HRID,ORG_USER_ID,ORG_CODE,LOGIN_ID,LOGIN_PWD,LAST_LOGIN_DATE,ACTIVE_YN,CREATED_ID,CREATED_DATE,MODIFIED_ID,MODIFIED_DATE,IS_INTERNAL_YN,ADDRESS_LINE_1,ADDRESS_LINE_2,CITY,STATE_CD,ZIP_CODE,COUNTRY_CD,LOCATION_CLLI,ORG_MANAGER_USERID,COMPANY,DEPARTMENT_NAME,JOB_TITLE,TIMEZONE,DEPARTMENT,BUSINESS_UNIT,BUSINESS_UNIT_NAME,COST_CENTER,FIN_LOC_CODE,SILO_STATUS) values (2,NULL,NULL,'Jimmy',NULL,'Hendrix',NULL,NULL,NULL,'admin@onap.org',NULL,NULL,NULL,'jh0003',NULL,'jh0003','4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=','2016-10-20 15:11:16','Y',NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16','N',NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/deliveries/Dockerfile.portal b/deliveries/Dockerfile.portal index 81eeb655..9b9f5489 100644 --- a/deliveries/Dockerfile.portal +++ b/deliveries/Dockerfile.portal @@ -11,6 +11,7 @@ ARG PORTAL_WAR=build/ecompportal-be-os.war ARG FE_DIR=build/public ARG HTTP_PROXY ARG HTTPS_PROXY +# ARG PORTAL_CERT=truststoreONAPall.jks # Just variables, never passed in ARG TOMCAT=apache-tomcat-8.0.37 @@ -31,6 +32,7 @@ RUN rm ${TOMCATTAR} # Remove manager and sample apps RUN rm -fr ${TOMCAT}/webapps/[a-z]* RUN mkdir -p /opt +COPY ${SERVERXML} ${TOMCAT}/conf RUN mv ${TOMCAT} /opt WORKDIR ${TOMCATHOME}/webapps diff --git a/deliveries/build_portalapps_dockers.sh b/deliveries/build_portalapps_dockers.sh index f7510acc..5092b407 100755 --- a/deliveries/build_portalapps_dockers.sh +++ b/deliveries/build_portalapps_dockers.sh @@ -125,13 +125,14 @@ cp $BASEDIR/ecomp-portal-DB-common/*.cql ${DELIVDIR} # SDK app cp $BASEDIR/sdk/ecomp-sdk/epsdk-app-common/db-scripts/*.cql ${DELIVDIR} - +# Build Docker Images echo "Build portal docker image" PORTAL_DOCKER_CMD=" docker build -t ${EP_IMG_NAME}:${PORTAL_TAG} ${PROXY_ARGS} --build-arg FE_DIR=$BUILD_REL/public --build-arg PORTAL_WAR=$BUILD_REL/portal-be-os.war + --build-arg SERVERXML=${DELIVDIR}/server.xml -f $PORTAL_DOCKERFILE . " $PORTAL_DOCKER_CMD diff --git a/deliveries/docker-compose.yml b/deliveries/docker-compose.yml index bba42aac..77538542 100644 --- a/deliveries/docker-compose.yml +++ b/deliveries/docker-compose.yml @@ -99,6 +99,7 @@ services: - 8989:8080 - 8010:8009 - 8006:8005 + - 8443:8443 links: - portal-db - portal-wms @@ -116,7 +117,9 @@ services: - ${PROPS_DIR}/ONAPPORTAL/music.properties:${WEBAPPS_DIR}/ONAPPORTAL/WEB-INF/classes/music.properties - ${PROPS_DIR}/ONAPPORTAL/openid-connect.properties:${WEBAPPS_DIR}/ONAPPORTAL/WEB-INF/classes/openid-connect.properties - ${PROPS_DIR}/ONAPPORTAL/logback.xml:${WEBAPPS_DIR}/ONAPPORTAL/WEB-INF/classes/logback.xml - - ${LOGS_DIR}:/opt/apache-tomcat-8.0.37/logs + - ./${TOMCAT_TRUST}:${TOMCAT_DIR}/${TOMCAT_TRUST} + - ./${TOMCAT_KEY}:${TOMCAT_DIR}/${TOMCAT_KEY} + - ${LOGS_DIR}:${TOMCAT_DIR}/logs command: - /start-apache-tomcat.sh # see comments in .env file @@ -128,6 +131,10 @@ services: driver: json-file environment: - CATALINA_OPTS=-Xmx1536m -Xms1536m + - javax.net.ssl.keyStore=${TOMCAT_DIR}/${TOMCAT_TRUST} + - javax.net.ssl.keyStorePassword=${CERT_PWD} + - javax.net.ssl.trustStore=${TOMCAT_DIR}/${TOMCAT_TRUST} + - javax.net.ssl.trustStorePassword=${CERT_PWD} portal-sdk: image: ${SDK_IMG_NAME}:${PORTAL_TAG} ports: @@ -146,7 +153,7 @@ services: - ${PROPS_DIR}/ONAPPORTALSDK/portal.properties:${WEBAPPS_DIR}/ONAPPORTALSDK/WEB-INF/classes/portal.properties - ${PROPS_DIR}/ONAPPORTALSDK/music.properties:${WEBAPPS_DIR}/ONAPPORTALSDK/WEB-INF/classes/music.properties - ${PROPS_DIR}/ONAPPORTALSDK/logback.xml:${WEBAPPS_DIR}/ONAPPORTALSDK/WEB-INF/classes/logback.xml - - ${LOGS_DIR}:/opt/apache-tomcat-8.0.37/logs + - ${LOGS_DIR}:${TOMCAT_DIR}/logs command: - /start-apache-tomcat.sh logging: diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index 4197d232..a77b9589 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -867,23 +867,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic ObjectMapper mapper = new ObjectMapper(); String addNewRole = ""; ExternalAccessRole extRole = new ExternalAccessRole(); - List role = null; - String addDesc = null; - Map extSystemUpdateRole = new LinkedHashMap<>(); - if (app.getId().equals(PortalConstants.PORTAL_APP_ID)) { - role = getPortalAppRoleInfo(addRole.getId()); - } else { - role = getPartnerAppRoleInfo(addRole.getId(), app); - } - extSystemUpdateRole.put(ID, String.valueOf(role.get(0).getId())); - extSystemUpdateRole.put(ROLE_NAME, String.valueOf(addRole.getName())); - extSystemUpdateRole.put(ACTIVE, String.valueOf(role.get(0).getActive())); - extSystemUpdateRole.put(PRIORITY, String.valueOf(role.get(0).getPriority())); - extSystemUpdateRole.put(APP_ID, String.valueOf(role.get(0).getAppId())); - extSystemUpdateRole.put(APP_ROLE_ID, String.valueOf(role.get(0).getAppRoleId())); - addDesc = mapper.writeValueAsString(extSystemUpdateRole); extRole.setName(app.getNameSpace() + "." + addRole.getName().replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_")); - extRole.setDescription(addDesc); + extRole.setDescription(String.valueOf(addRole.getName())); addNewRole = mapper.writeValueAsString(extRole); return addNewRole; } @@ -897,7 +882,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic * @throws Exception */ @SuppressWarnings("unchecked") - @Transactional(rollbackFor = Exception.class) + @Transactional(rollbackFor = Exception.class) public boolean addRoleInEcompDB(Role addRoleInDB, EPApp app) throws Exception { boolean result = false; EPRole epRole = null; @@ -2738,7 +2723,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic applicationRolesList = getAppRoles(app.getId()); List applicationRoleIdList = new ArrayList<>(); for (EPRole applicationRole : applicationRolesList) { - applicationRoleIdList.add(applicationRole.getName()); + applicationRoleIdList.add(applicationRole.getName().replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_")); } List roleListToBeAddInEcompDB = new ArrayList<>(); @@ -2915,30 +2900,27 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic throws IOException { List externalRoleDetailsList = new ArrayList<>(); ExternalRoleDescription ApplicationRole = new ExternalRoleDescription(); - ExternalAccessPerms externalAccessPerms = new ExternalAccessPerms(); + ExternalAccessPerms externalAccessPerms = new ExternalAccessPerms(); List functionCodelist = new ArrayList<>(); + Map curRolesMap = getCurrentRolesInDB(app); + for (int i = 0; i < extRole.length(); i++) { ExternalRoleDetails externalRoleDetail = new ExternalRoleDetails(); EPAppRoleFunction ePAppRoleFunction = new EPAppRoleFunction(); JSONObject Role = (JSONObject) extRole.get(i); - if (!extRole.getJSONObject(i).has(EXTERNAL_AUTH_ROLE_DESCRIPTION)) { - ApplicationRole.setActive("true"); - ApplicationRole.setAppId(IS_NULL_STRING); - ApplicationRole.setPriority(IS_NULL_STRING); - ApplicationRole.setAppRoleId(IS_NULL_STRING); - String roleName = extRole.getJSONObject(i).getString(ROLE_NAME); - ApplicationRole.setName(roleName.substring(app.getNameSpace().length() + 1)); - } else { + String roleName = extRole.getJSONObject(i).getString(ROLE_NAME); + ApplicationRole.setName(roleName.substring(app.getNameSpace().length() + 1)); + if (extRole.getJSONObject(i).has(EXTERNAL_AUTH_ROLE_DESCRIPTION)) { String desc = extRole.getJSONObject(i).getString(EXTERNAL_AUTH_ROLE_DESCRIPTION); - ApplicationRole = mapper.readValue(desc, ExternalRoleDescription.class); + ApplicationRole.setName(desc); } - SortedSet externalAccessPermsOfRole = new TreeSet<>(); if (extRole.getJSONObject(i).has(EXTERNAL_AUTH_PERMS)) { JSONArray extPerm = (JSONArray) Role.get(EXTERNAL_AUTH_PERMS); for (int j = 0; j < extPerm.length(); j++) { JSONObject perms = extPerm.getJSONObject(j); - boolean isNamespaceMatching = EcompPortalUtils.checkNameSpaceMatching(perms.getString("type"), app.getNameSpace()); + boolean isNamespaceMatching = EcompPortalUtils.checkNameSpaceMatching(perms.getString("type"), + app.getNameSpace()); if (isNamespaceMatching) { externalAccessPerms = new ExternalAccessPerms(perms.getString("type"), perms.getString("instance"), perms.getString("action")); @@ -2949,46 +2931,33 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } } - - if (ApplicationRole.getActive().equals(IS_NULL_STRING)) { - externalRoleDetail.setActive(false); - } else { - externalRoleDetail.setActive(Boolean.parseBoolean(ApplicationRole.getActive())); - } + externalRoleDetail.setActive(true); externalRoleDetail.setName(ApplicationRole.getName()); - - if (ApplicationRole.getAppId().equals(IS_NULL_STRING) && app.getId() == 1) { + if (app.getId() == 1) { externalRoleDetail.setAppId(null); - } else if (ApplicationRole.getAppId().equals(IS_NULL_STRING)) { - externalRoleDetail.setAppId(app.getId()); - } else { - externalRoleDetail.setAppId(Long.parseLong(ApplicationRole.getAppId())); - } - - if (ApplicationRole.getPriority().equals(IS_NULL_STRING)) { - externalRoleDetail.setPriority(null); } else { - externalRoleDetail.setPriority(Integer.parseInt(ApplicationRole.getPriority())); - } - - if (ApplicationRole.getAppRoleId().equals(IS_NULL_STRING) && app.getId() == 1) { - externalRoleDetail.setAppRoleId(null); + externalRoleDetail.setAppId(app.getId()); } - + // get role functions from DB + EPRole currRole = curRolesMap.get(ApplicationRole.getName() + .replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_")); + Long roleId = null; + if (currRole != null) + roleId = currRole.getId(); // get role functions from DB final Map roleFunctionsMap = new HashMap<>(); - if (!ApplicationRole.getId().equals(IS_NULL_STRING)) { - final Map appRoleFuncsParams = new HashMap<>(); + final Map appRoleFuncsParams = new HashMap<>(); + if (roleId != null) { appRoleFuncsParams.put("appId", app.getId()); - appRoleFuncsParams.put("roleId", Long.valueOf(ApplicationRole.getId())); - List appRoleFunctions = dataAccessService.executeNamedQuery("getAppRoleFunctionOnRoleIdandAppId", appRoleFuncsParams, null); + appRoleFuncsParams.put("roleId", roleId); + List appRoleFunctions = dataAccessService + .executeNamedQuery("getAppRoleFunctionOnRoleIdandAppId", appRoleFuncsParams, null); if (!appRoleFunctions.isEmpty()) { for (EPAppRoleFunction roleFunc : appRoleFunctions) { roleFunctionsMap.put(roleFunc.getCode(), roleFunc); } } } - if (!externalAccessPermsOfRole.isEmpty()) { // Adding functions to role for (ExternalAccessPerms externalpermission : externalAccessPermsOfRole) { @@ -3000,22 +2969,24 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic EPAppRoleFunction checkRoleFunctionPipeExits = roleFunctionsMap.get(funcCode); if (checkRoleFunctionPipeExits == null) { try { - final Map appFuncsParams = new HashMap<>(); + final Map appFuncsParams = new HashMap<>(); appFuncsParams.put("appId", String.valueOf(app.getId())); appFuncsParams.put("functionCd", externalpermission.getInstance()); logger.debug(EELFLoggerDelegate.debugLogger, "SyncApplicationRolesWithEcompDB: Adding function to the role: {}", externalpermission.getInstance()); List roleFunction = null; - roleFunction = dataAccessService.executeNamedQuery("getAppFunctionOnCodeAndAppId", appFuncsParams, null); + roleFunction = dataAccessService.executeNamedQuery("getAppFunctionOnCodeAndAppId", + appFuncsParams, null); if (roleFunction.isEmpty()) { appFuncsParams.put("functionCd", funcCode); - roleFunction = dataAccessService.executeNamedQuery("getAppFunctionOnCodeAndAppId", appFuncsParams, null); + roleFunction = dataAccessService.executeNamedQuery("getAppFunctionOnCodeAndAppId", + appFuncsParams, null); } if (!roleFunction.isEmpty()) { EPAppRoleFunction apRoleFunction = new EPAppRoleFunction(); apRoleFunction.setAppId(app.getId()); - apRoleFunction.setRoleId(Long.parseLong(ApplicationRole.getId())); + apRoleFunction.setRoleId(roleId); apRoleFunction.setCode(roleFunction.get(0).getCode()); dataAccessService.saveDomainObject(apRoleFunction, null); } @@ -3089,7 +3060,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic */ private EPRole convertExternalRoleDetailstoEpRole(ExternalRoleDetails externalRoleDetails) { EPRole role = new EPRole(); - role.setActive(externalRoleDetails.isActive()); + role.setActive(true); role.setAppId(externalRoleDetails.getAppId()); role.setAppRoleId(externalRoleDetails.getAppRoleId()); role.setName(externalRoleDetails.getName()); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java index a192ad94..c766106d 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java @@ -39,9 +39,9 @@ package org.onap.portalapp.portal.service; import java.util.ArrayList; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import org.onap.portalapp.portal.service.SearchService; +import org.onap.portalapp.portal.service.SearchServiceImpl; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.transport.UserWithNameSurnameTitle; @@ -74,10 +74,8 @@ public class SearchServiceImpl implements SearchService { public String searchUsersInPhoneBook(String searchString) { String orgUserId = null; List tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " "); - Pattern pattern = Pattern.compile(EcompPortalUtils.SEARCH_USERS_REGEX); for (int i = 0; i < tokens.size(); i++) { // find orgUserId if possible and remove it from tokens - Matcher matcher = pattern.matcher(tokens.get(i)); - if (matcher.matches()) { + if (tokens.get(i).matches(".*\\d+.*")) { orgUserId = tokens.get(i); tokens.remove(i); } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java index a4b6cc24..f8d1116b 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java @@ -58,7 +58,6 @@ import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum; import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; -import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; import org.springframework.http.HttpHeaders; @@ -80,9 +79,6 @@ public class EcompPortalUtils { // It is a regular expression used for while creating a External Central Auth Role public static final String EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS = "([^A-Z^a-z^0-9^\\.^%^(^)^=^:])"; - // regex for alphanumeric , dashes and underscore - public static final String SEARCH_USERS_REGEX = "(^[a-zA-Z0-9_-]*$)"; - /** * @param orgUserId * User ID to validate @@ -90,7 +86,7 @@ public class EcompPortalUtils { * otherwise */ public static boolean legitimateUserId(String orgUserId) { - return orgUserId.matches("^[a-zA-Z0-9]+$"); + return orgUserId.matches("^[a-zA-Z0-9/_/-/@]+$"); } /** diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/MusicCookieCsrfTokenRepository.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/MusicCookieCsrfTokenRepository.java index 75c66162..988b97a5 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/MusicCookieCsrfTokenRepository.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/MusicCookieCsrfTokenRepository.java @@ -1,17 +1,39 @@ -/* - * Copyright 2012-2016 the original author or authors. +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Unless otherwise specified, all software contained herein is licensed + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * 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 + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * */ package org.onap.portalapp.portal.utils; @@ -35,8 +57,7 @@ public final class MusicCookieCsrfTokenRepository implements CsrfTokenRepository static final String CSRF_PARAMETER_NAME = "_csrf"; static final String EP_SERVICE = "EPService"; CookieCsrfTokenRepository cookieRepo = null; - private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicService.class); - + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicCookieCsrfTokenRepository.class); public MusicCookieCsrfTokenRepository() { } @@ -64,12 +85,14 @@ public final class MusicCookieCsrfTokenRepository implements CsrfTokenRepository if(cookieRepoToken==null){ // if cookieRepo does not has the token, check the cassandra for the values stored by other tomcats try { // todo this part of the code needs to be replaced with out depending on EPService cookie String sessionId = getSessionIdFromCookie(request); + if(sessionId == null) + return null; String token = MusicService.getAttribute(CSRF_COOKIE_NAME, sessionId); if (token==null || !StringUtils.hasLength(token)) return null; cookieRepoToken = new DefaultCsrfToken(CSRF_HEADER_NAME, CSRF_PARAMETER_NAME , token); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Error while calling csrf saveToken" , e); + logger.error(EELFLoggerDelegate.errorLogger, "Error while calling csrf loadToken" , e); } } return cookieRepoToken; diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml index becfe7c2..e4b81448 100644 --- a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml @@ -1306,9 +1306,12 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y where a.user_id =:userId and b.app_id = c.app_id and a.app_id = c.role_app_id and b.enabled = 'Y' and c.role_id = d.role_id and d.active_yn='Y' and a.role_id = d.role_id and e.app_id = c.app_id ) A left outer join - (select distinct - c.AFFECTED_RECORD_ID, c.AUDIT_DATE - from FN_AUDIT_LOG c + (select FN_AUDIT_LOG.AFFECTED_RECORD_ID, max(FN_AUDIT_LOG.AUDIT_DATE) AS AUDIT_DATE + from FN_APP LEFT JOIN FN_AUDIT_LOG + on FN_APP.APP_ID = FN_AUDIT_LOG.AFFECTED_RECORD_ID + where FN_APP.ENABLED = 'Y' and FN_AUDIT_LOG.user_id=:userId + and (audit_date) BETWEEN (CURDATE() - INTERVAL 90 DAY) and CURDATE() + group by FN_AUDIT_LOG.AFFECTED_RECORD_ID )B on A.app_id = B.Affected_record_id order by AUDIT_DATE DESC; @@ -1349,9 +1352,12 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y ) A left outer join - (select distinct - c.AFFECTED_RECORD_ID, c.AUDIT_DATE - from FN_AUDIT_LOG c + (select FN_AUDIT_LOG.AFFECTED_RECORD_ID, max(FN_AUDIT_LOG.AUDIT_DATE) AS AUDIT_DATE + from FN_APP LEFT JOIN FN_AUDIT_LOG + on FN_APP.APP_ID = FN_AUDIT_LOG.AFFECTED_RECORD_ID + where FN_APP.ENABLED = 'Y' and FN_AUDIT_LOG.user_id=:userId + and (audit_date) BETWEEN (CURDATE() - INTERVAL 90 DAY) and CURDATE() + group by FN_AUDIT_LOG.AFFECTED_RECORD_ID )B on A.app_id = B.Affected_record_id order by AUDIT_DATE DESC; diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPRoleTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPRoleTest.java index d081b801..f99c80bc 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPRoleTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPRoleTest.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright © 2018 IBM. + * ================================================================================ * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -51,58 +53,68 @@ import org.onap.portalsdk.core.restful.domain.EcompRoleFunction; public class EPRoleTest { - - @Test - public void testEpRole() { - EPRole role=new EPRole(); - role.setActive(true); - role.setAppId(1l); - role.setAppRoleId(2l); - role.setId(3l); - role.setName("TEST_ADMIN"); - SortedSet childRoles = new TreeSet(); - EPRole child=new EPRole(); - child.setActive(true); - child.setAppId(1l); - child.setAppRoleId(3l); - child.setId(6l); - child.setName("TEST_USER"); - childRoles.add(child); - role.setChildRoles(childRoles); - SortedSet parentRoles = new TreeSet(); - EPRole parent=new EPRole(); - parent.setActive(true); - parent.setAppId(1l); - parent.setAppRoleId(3l); - parent.setId(6l); - parent.setName("TEST_USER"); - parentRoles.add(parent); - role.setParentRoles(parentRoles); - - SortedSet rolefunction = new TreeSet(); - RoleFunction function=new RoleFunction(); - function.setAction("Test");; - function.setCode("code"); - rolefunction.add(function); - role.setRoleFunctions(rolefunction); - role.setPriority(5); - role.setAppRoleId(3l); - assertEquals(3l, role.getAppRoleId().longValue()); - assertNotNull(role.getChildRoles()); - assertNotNull(role.getParentRoles()); - assertNotNull(role.getRoleFunctions()); - role.compareTo(role); - assertEquals(1l, role.getAppId().longValue()); - assertEquals("TEST_ADMIN",role.getName()); - role.removeChildRole(6l); - role.removeParentRole(6l); - assertEquals(role.toString(), "[Id = 3, name = TEST_ADMIN]"); - role.removeRoleFunction("code"); - role.addChildRole(child); - role.addParentRole(parent); - role.addRoleFunction(function); - - } - + + @Test + public void testEpRole() { + EPRole role=new EPRole(); + role.setActive(true); + role.setAppId(1l); + role.setAppRoleId(2l); + role.setId(3l); + role.setName("TEST_ADMIN"); + SortedSet childRoles = new TreeSet(); + EPRole child=new EPRole(); + child.setActive(true); + child.setAppId(1l); + child.setAppRoleId(3l); + child.setId(6l); + child.setName("TEST_USER"); + childRoles.add(child); + role.setChildRoles(childRoles); + SortedSet parentRoles = new TreeSet(); + EPRole parent=new EPRole(); + parent.setActive(true); + parent.setAppId(1l); + parent.setAppRoleId(3l); + parent.setId(6l); + parent.setName("TEST_USER"); + parentRoles.add(parent); + role.setParentRoles(parentRoles); + + SortedSet rolefunction = new TreeSet(); + RoleFunction function=new RoleFunction(); + function.setAction("Test");; + function.setCode("code"); + rolefunction.add(function); + role.setRoleFunctions(rolefunction); + role.setPriority(5); + role.setAppRoleId(3l); + assertEquals(3l, role.getAppRoleId().longValue()); + assertNotNull(role.getChildRoles()); + assertNotNull(role.getParentRoles()); + assertNotNull(role.getRoleFunctions()); + role.compareTo(role); + assertEquals(1l, role.getAppId().longValue()); + assertEquals("TEST_ADMIN",role.getName()); + role.removeChildRole(6l); + role.removeParentRole(6l); + assertEquals(role.toString(), "[Id = 3, name = TEST_ADMIN]"); + role.removeRoleFunction("code"); + role.addChildRole(child); + role.addParentRole(parent); + role.addRoleFunction(function); + + parent.setAppId(null); + child.setAppId((long) 1234); + assertEquals(parent.compareTo(child), -1); + + child.setAppId(null); + parent.setAppId((long) 1234); + assertEquals(parent.compareTo(child), 1); + + + + } + } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserTest.java index bc4c6f38..c856b5a3 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserTest.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright © 2018 IBM. + * ================================================================================ * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -37,7 +39,7 @@ */ package org.onap.portalapp.portal.domain; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import java.util.Date; @@ -46,106 +48,111 @@ import org.onap.portalapp.portal.domain.EPUser; public class EPUserTest { - public EPUser mockEPUser(){ - - EPUser epUser = new EPUser(); - - epUser.setId((long)1); - epUser.setManagerId((long) 1234); - epUser.setFirstName("test"); - epUser.setLastName("test"); - epUser.setMiddleInitial("test"); - epUser.setPhone("test"); - epUser.setFax("test"); - epUser.setCellular("test"); - epUser.setEmail("test"); - epUser.setAddressId((long) 123); - epUser.setAlertMethodCd("test"); - epUser.setHrid("test"); - epUser.setOrgUserId("test"); - epUser.setOrgCode("test"); - epUser.setAddress1("test"); - epUser.setAddress2("test"); - epUser.setCity("test"); - epUser.setState("test"); - epUser.setZipCode("test"); - epUser.setCountry("test"); - epUser.setOrgManagerUserId("test"); - epUser.setLocationClli("test"); - epUser.setBusinessCountryCode("test"); - epUser.setBusinessCountryName("test"); - epUser.setBusinessUnit("test"); - epUser.setBusinessUnitName("test"); - epUser.setDepartment("test"); - epUser.setDepartmentName("test"); - epUser.setCompanyCode("test"); - epUser.setCompany("test"); - epUser.setZipCodeSuffix("test"); - epUser.setJobTitle("test"); - epUser.setCommandChain("test"); - epUser.setSiloStatus("test"); - epUser.setCostCenter("test"); - epUser.setFinancialLocCode("test"); - epUser.setLoginId("test"); - epUser.setLoginPwd("test"); - epUser.setLastLoginDate(new Date()); - epUser.setActive(false); - epUser.setInternal(false); - epUser.setSelectedProfileId((long) 12345); - epUser.setTimeZoneId((long) 12345); - epUser.setOnline(false); - epUser.setChatId("test"); - return epUser; - - } - - @Test - public void userTest(){ - EPUser user = mockEPUser(); - - assertEquals(user.getId(), new Long(1)); - assertEquals(user.getManagerId(), new Long(1234)); - assertEquals(user.getFirstName(), "test"); - assertEquals(user.getLastName(), "test"); - assertEquals(user.getMiddleInitial(), "test"); - assertEquals(user.getPhone(), "test"); - assertEquals(user.getFax(), "test"); - assertEquals(user.getCellular(), "test"); - assertEquals(user.getEmail(), "test"); - assertEquals(user.getAddressId(), new Long(123) ); - assertEquals(user.getAlertMethodCd(), "test"); - assertEquals(user.getHrid(), "test"); - assertEquals(user.getOrgUserId(), "test"); - assertEquals(user.getOrgCode(), "test"); - assertEquals(user.getAddress1(), "test"); - assertEquals(user.getAddress2(), "test"); - assertEquals(user.getState(), "test"); - assertEquals(user.getZipCode(), "test"); - assertEquals(user.getCountry(), "test"); - assertEquals(user.getOrgManagerUserId(), "test"); - assertEquals(user.getLocationClli(), "test"); - assertEquals(user.getBusinessCountryCode(), "test"); - assertEquals(user.getBusinessCountryName(), "test"); - assertEquals(user.getBusinessUnit(), "test"); - assertEquals(user.getBusinessUnitName(), "test"); - assertEquals(user.getDepartment(), "test"); - assertEquals(user.getDepartmentName(), "test"); - assertEquals(user.getCompanyCode(), "test"); - assertEquals(user.getCompany(), "test"); - assertEquals(user.getZipCodeSuffix(), "test"); - assertEquals(user.getJobTitle(), "test"); - assertEquals(user.getCommandChain(), "test"); - assertEquals(user.getSiloStatus(), "test"); - assertEquals(user.getFinancialLocCode(), "test"); - assertEquals(user.getLoginId(), "test"); - assertEquals(user.getLoginPwd(), "test"); - assertEquals(user.getActive(), false); - assertEquals(user.getInternal(), false); - assertEquals(user.getSelectedProfileId(), new Long (12345)); - assertEquals(user.getTimeZoneId(), new Long (12345)); - assertEquals(user.getChatId(), "test"); - - //assertEquals(user.toString(), "EPUser [orgId=null, managerId=1234, firstName=test, middleInitial=test, lastName=test, phone=test, fax=test, cellular=test, email=test, addressId=123, alertMethodCd=test, hrid=test, orgUserId=test, orgCode=test, address1=test, address2=test, city=test, state=test, zipCode=test, country=test, orgManagerUserId=test, locationClli=test, businessCountryCode=test, businessCountryName=test, businessUnit=test, businessUnitName=test, department=test, departmentName=test, companyCode=test, company=test, zipCodeSuffix=test, jobTitle=test, commandChain=test, siloStatus=test, costCenter=test, financialLocCode=test, loginId=test, loginPwd=test, lastLoginDate=Tue Sep 05 11:04:49 EDT 2017, active=false, internal=false, selectedProfileId=12345, timeZoneId=12345, online=false, chatId=test, isGuest=false, userApps=[], pseudoRoles=[]]"); - } - + public EPUser mockEPUser(){ + + EPUser epUser = new EPUser(); + + epUser.setId((long)1); + epUser.setManagerId((long) 1234); + epUser.setFirstName("test"); + epUser.setLastName("test"); + epUser.setMiddleInitial("test"); + epUser.setPhone("test"); + epUser.setFax("test"); + epUser.setCellular("test"); + epUser.setEmail("test"); + epUser.setAddressId((long) 123); + epUser.setAlertMethodCd("test"); + epUser.setHrid("test"); + epUser.setOrgUserId("test"); + epUser.setOrgCode("test"); + epUser.setAddress1("test"); + epUser.setAddress2("test"); + epUser.setCity("test"); + epUser.setState("test"); + epUser.setZipCode("test"); + epUser.setCountry("test"); + epUser.setOrgManagerUserId("test"); + epUser.setLocationClli("test"); + epUser.setBusinessCountryCode("test"); + epUser.setBusinessCountryName("test"); + epUser.setBusinessUnit("test"); + epUser.setBusinessUnitName("test"); + epUser.setDepartment("test"); + epUser.setDepartmentName("test"); + epUser.setCompanyCode("test"); + epUser.setCompany("test"); + epUser.setZipCodeSuffix("test"); + epUser.setJobTitle("test"); + epUser.setCommandChain("test"); + epUser.setSiloStatus("test"); + epUser.setCostCenter("test"); + epUser.setFinancialLocCode("test"); + epUser.setLoginId("test"); + epUser.setLoginPwd("test"); + epUser.setLastLoginDate(new Date()); + epUser.setActive(false); + epUser.setInternal(false); + epUser.setSelectedProfileId((long) 12345); + epUser.setTimeZoneId((long) 12345); + epUser.setOnline(false); + epUser.setChatId("test"); + return epUser; + + } + + @Test + public void userTest(){ + EPUser user = mockEPUser(); + + assertEquals(user.getId(), new Long(1)); + assertEquals(user.getManagerId(), new Long(1234)); + assertEquals(user.getFirstName(), "test"); + assertEquals(user.getLastName(), "test"); + assertEquals(user.getMiddleInitial(), "test"); + assertEquals(user.getPhone(), "test"); + assertEquals(user.getFax(), "test"); + assertEquals(user.getCellular(), "test"); + assertEquals(user.getEmail(), "test"); + assertEquals(user.getAddressId(), new Long(123) ); + assertEquals(user.getAlertMethodCd(), "test"); + assertEquals(user.getHrid(), "test"); + assertEquals(user.getOrgUserId(), "test"); + assertEquals(user.getOrgCode(), "test"); + assertEquals(user.getAddress1(), "test"); + assertEquals(user.getAddress2(), "test"); + assertEquals(user.getState(), "test"); + assertEquals(user.getZipCode(), "test"); + assertEquals(user.getCountry(), "test"); + assertEquals(user.getOrgManagerUserId(), "test"); + assertEquals(user.getLocationClli(), "test"); + assertEquals(user.getBusinessCountryCode(), "test"); + assertEquals(user.getBusinessCountryName(), "test"); + assertEquals(user.getBusinessUnit(), "test"); + assertEquals(user.getBusinessUnitName(), "test"); + assertEquals(user.getDepartment(), "test"); + assertEquals(user.getDepartmentName(), "test"); + assertEquals(user.getCompanyCode(), "test"); + assertEquals(user.getCompany(), "test"); + assertEquals(user.getZipCodeSuffix(), "test"); + assertEquals(user.getJobTitle(), "test"); + assertEquals(user.getCommandChain(), "test"); + assertEquals(user.getSiloStatus(), "test"); + assertEquals(user.getFinancialLocCode(), "test"); + assertEquals(user.getLoginId(), "test"); + assertEquals(user.getLoginPwd(), "test"); + assertEquals(user.getActive(), false); + assertEquals(user.getInternal(), false); + assertEquals(user.getSelectedProfileId(), new Long (12345)); + assertEquals(user.getTimeZoneId(), new Long (12345)); + assertEquals(user.getChatId(), "test"); + + EPUser another = mockEPUser(); + assertTrue(user.compareTo(another) == 0); + another.setLastName("otherlastname"); + assertTrue(user.compareTo(another) == 5); + + //assertEquals(user.toString(), "EPUser [orgId=null, managerId=1234, firstName=test, middleInitial=test, lastName=test, phone=test, fax=test, cellular=test, email=test, addressId=123, alertMethodCd=test, hrid=test, orgUserId=test, orgCode=test, address1=test, address2=test, city=test, state=test, zipCode=test, country=test, orgManagerUserId=test, locationClli=test, businessCountryCode=test, businessCountryName=test, businessUnit=test, businessUnitName=test, department=test, departmentName=test, companyCode=test, company=test, zipCodeSuffix=test, jobTitle=test, commandChain=test, siloStatus=test, costCenter=test, financialLocCode=test, loginId=test, loginPwd=test, lastLoginDate=Tue Sep 05 11:04:49 EDT 2017, active=false, internal=false, selectedProfileId=12345, timeZoneId=12345, online=false, chatId=test, isGuest=false, userApps=[], pseudoRoles=[]]"); + } + } diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/PortalRestResponseTest.java similarity index 57% rename from ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java rename to ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/PortalRestResponseTest.java index a3255480..fc785be1 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/PortalRestResponseTest.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright © 2018 IBM. + * ================================================================================ * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -35,24 +37,38 @@ * * */ +package org.onap.portalapp.portal.model; -package org.onap.portalapp.portal.service; +import static org.junit.Assert.*; -import org.onap.portalapp.portal.domain.EPApp; +import org.junit.Before; +import org.junit.Test; +import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; +import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; -public interface AppsCacheService { - - /** - * returns an app by id from the cache - * @param appId - * @return corresponding App - */ - EPApp getApp(Long appId); - - /** - * returns the corresponding application endpoint - * @param appId - * @return if appId exists in cache, then return corresponding application endpoint, null otherwise. - */ - String getAppEndpoint(Long appId); +public class PortalRestResponseTest { + + PortalRestResponse portalRestResponse1 = new PortalRestResponse(); + PortalRestResponse portalRestResponse2 = new PortalRestResponse(); + + @Before + public void setup(){ + portalRestResponse1.setMessage("test"); + portalRestResponse1.setResponse(new String("testResponse")); + portalRestResponse1.setStatus(PortalRestStatusEnum.OK); + + portalRestResponse2.setMessage("test"); + portalRestResponse2.setResponse(new String("testResponse")); + portalRestResponse2.setStatus(PortalRestStatusEnum.OK); + } + + @Test + public void testHashCode(){ + assertEquals(portalRestResponse1.hashCode(), portalRestResponse2.hashCode()); + } + + @Test + public void testEquals(){ + assertTrue(portalRestResponse1.equals(portalRestResponse2)); + } } diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java index ee53eba0..e9c48251 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java @@ -161,9 +161,10 @@ public class ExternalAppConfig extends AppConfig implements Configurable { MDC.put(MDC_SERVICE_INSTANCE_ID, ""); MDC.put(MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.severity()); MDC.put(MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); - if("true".equalsIgnoreCase(remotecentralizedsystemaccess)){ - importFromExternalAuth(); - } + + // if("true".equalsIgnoreCase(remotecentralizedsystemaccess)){ + // importFromExternalAuth(); + // } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "init failed", e); } @@ -174,7 +175,10 @@ public class ExternalAppConfig extends AppConfig implements Configurable { * for all the centralized applications between AAF and ONAP, updates * fn_user and fn_user_role with user information from AAF. * + * This is being handled in AAF directly, so it has been deprecated + * */ + @Deprecated private void importFromExternalAuth() throws Exception { JSONArray aafAppRoles = new JSONArray(); JSONArray aafUserList = new JSONArray(); diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java deleted file mode 100644 index e6306c9c..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * 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 - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ -package org.onap.portalapp.portal.service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.onap.portalapp.portal.domain.EPApp; -import org.onap.portalapp.portal.logging.aop.EPMetricsLog; -import org.onap.portalapp.portal.service.AppsCacheService; -import org.onap.portalapp.portal.service.EPAppService; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; - -@Service("appsCacheService") -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPMetricsLog -public class AppsCacheServiceImple implements AppsCacheService { - @Autowired - EPAppService appsService; - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsCacheServiceImple.class); - - private static long updateTime = 0; - private static final int cacheUpdateIntervalInSeconds = 10; - - private static volatile Map appsMap; - - @PostConstruct - public void init() { - this.refreshAppsMap(); - } - - private Map refreshAppsMap() { - long now = System.currentTimeMillis(); - - if(noNeedToUpdate(now)) - return null; - - synchronized (this) { - if(noNeedToUpdate(now)) - return null; - List allApps = appsService.getAppsFullList(); - Map newAppsMap = new HashMap(); - for (EPApp app : allApps) { - newAppsMap.put(app.getId(), app); - } - // Switch cache with the new one. - appsMap = newAppsMap; - updateTime = now; - } - - return appsMap; - } - - private boolean noNeedToUpdate(long now) { - long secondsPassed = (now - updateTime)/1000; - if(secondsPassed < cacheUpdateIntervalInSeconds){ - logger.debug(EELFLoggerDelegate.debugLogger, "no need to refresh yet, seconds since last refresh: " + secondsPassed + ", refresh interval (sec) = " + cacheUpdateIntervalInSeconds); - return true; // no need to update cache - } - return false; // its time to update - } - - @Override - public String getAppEndpoint(Long appId) { - refreshAppsMap(); - EPApp app = appsMap.get(appId); - if(app != null) - return app.getAppRestEndpoint(); - return null; - } - - @Override - public EPApp getApp(Long appId) { - refreshAppsMap(); - EPApp app = appsMap.get(appId); - if(app != null) - return app; - return null; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java index 48f6d298..0e9932e0 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -39,12 +39,10 @@ package org.onap.portalapp.portal.service; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; -import org.onap.portalapp.portal.service.SearchService; -import org.onap.portalapp.portal.service.SearchServiceImpl; -import org.onap.portalapp.portal.service.UserService; import org.onap.portalapp.portal.transport.UserWithNameSurnameTitle; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -75,22 +73,16 @@ public class SearchServiceImpl implements SearchService { return searchUsersInFnTable(searchString); } + @Override public String searchUsersInFnTable(String searchString) { - String orgUserId = null; List tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " "); - for (int i = 0; i < tokens.size(); i++) { // find userid if possible and remove it from tokens - if (tokens.get(i).matches(".*\\d+.*")) { - orgUserId = tokens.get(i); - tokens.remove(i); - } - } while (tokens.size() > 2) { // we use no more then first 2 tokens (userId is removed, see above) tokens.remove(tokens.size() - 1); } EPUser attrUser = new EPUser(); - attrUser.setOrgUserId(orgUserId); - List resultOfSearch = new ArrayList(), resultOfAdditionalSearch = null; + List resultOfSearch = new ArrayList(), resultOfAdditionalSearch = null, + resultOfSearchUserId = new ArrayList(); if (tokens.size() == 2) { attrUser.setFirstName(tokens.get(0)); attrUser.setLastName(tokens.get(1)); @@ -106,7 +98,9 @@ public class SearchServiceImpl implements SearchService { } } else if (tokens.size() == 1) { attrUser.setFirstName(tokens.get(0)); + attrUser.setOrgUserId(tokens.get(0)); resultOfSearch = this.searchUsersByName(attrUser); + resultOfSearchUserId = this.searchUsersByUserId(attrUser); resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0)); if (resultOfSearch.size() < maxSizeOfSearchResult) { attrUser.setFirstName(null); @@ -114,12 +108,12 @@ public class SearchServiceImpl implements SearchService { resultOfAdditionalSearch = this.searchUsersByName(attrUser); resultOfAdditionalSearch = this.removeWrongLastNames(resultOfAdditionalSearch, tokens.get(0)); } - } else if (orgUserId != null) { - resultOfSearch = this.searchUsersByUserId(attrUser); } if (resultOfAdditionalSearch != null) { resultOfSearch.addAll(resultOfAdditionalSearch); } + resultOfSearch.addAll(resultOfSearchUserId); + resultOfSearch.stream().distinct().collect(Collectors.toList()); resultOfSearch = this.cutSearchResultToMaximumSize(resultOfSearch); ObjectMapper mapper = new ObjectMapper(); String result = "[]"; @@ -131,7 +125,6 @@ public class SearchServiceImpl implements SearchService { return result; } - @SuppressWarnings("rawtypes") public List searchUsersByUserId(EPUser attrUser) { List foundUsers = new ArrayList(); diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java index b5ccfc02..fccd4ff8 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java @@ -159,9 +159,12 @@ public class UserServiceImpl implements UserService { List list = null; StringBuffer criteria = new StringBuffer(); - if (firstName != null) + if (firstName != null && lastName != null) + criteria.append(" where first_name = '").append(firstName).append("' and last_name = '") + .append(lastName).append("'"); + else if (firstName != null) criteria.append(" where first_name = '").append(firstName).append("'"); - if (lastName != null) + else if (lastName != null) criteria.append(" where last_name = '").append(lastName).append("'"); list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); return (list == null || list.size() == 0) ? null : list; diff --git a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/SearchServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/SearchServiceImplTest.java index 6b24e96d..04234059 100644 --- a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/SearchServiceImplTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/SearchServiceImplTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -37,7 +37,8 @@ */ package org.onap.portalapp.portal.service; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import java.util.ArrayList; import java.util.List; @@ -55,8 +56,6 @@ import org.mockito.MockitoAnnotations; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.framework.MockEPUser; import org.onap.portalapp.portal.framework.MockitoTestSuite; -import org.onap.portalapp.portal.service.SearchServiceImpl; -import org.onap.portalapp.portal.service.UserService; import org.onap.portalapp.portal.transport.UserWithNameSurnameTitle; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.powermock.api.mockito.PowerMockito; @@ -105,19 +104,18 @@ public class SearchServiceImplTest { PowerMockito.mockStatic(EcompPortalUtils.class); List list = new ArrayList<>(); String str = "Test"; - String str2 = "Test new"; - String str1 = "Test new1"; + String str1 = "Testnew"; list.add(str); list.add(str1); - list.add(str2); - Mockito.when(EcompPortalUtils.parsingByRegularExpression("Test", " ")).thenReturn(list); + Mockito.when(EcompPortalUtils.parsingByRegularExpression("Test Testnew", " ")).thenReturn(list); + @SuppressWarnings({ "unchecked", "rawtypes" }) List userList = new ArrayList(); EPUser user = mockUser.mockEPUser(); - user.setLastName("Test new"); + user.setLastName("Testnew"); userList.add(user); - Mockito.when( this.userService.getUserByFirstLastName("Test","Test new")).thenReturn(userList); - String result = searchServiceImpl.searchUsersInPhoneBook("Test"); - assertEquals("[{\"orgUserId\":\"guestT\",\"firstName\":\"test\",\"lastName\":\"Test new\",\"jobTitle\":null}]" , result); + Mockito.when( this.userService.getUserByFirstLastName("Test","Testnew")).thenReturn(userList); + String result = searchServiceImpl.searchUsersInPhoneBook("Test Testnew"); + assertEquals("[{\"orgUserId\":\"guestT\",\"firstName\":\"test\",\"lastName\":\"Testnew\",\"jobTitle\":null}]" , result); } diff --git a/ecomp-portal-FE-common/client/app/views/tabs/tabframe.html b/ecomp-portal-FE-common/client/app/views/tabs/tabframe.html index c7034edd..79dd0928 100644 --- a/ecomp-portal-FE-common/client/app/views/tabs/tabframe.html +++ b/ecomp-portal-FE-common/client/app/views/tabs/tabframe.html @@ -2,7 +2,7 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -32,9 +32,9 @@ limitations under the License. ============LICENSE_END============================================ - - + --> \ No newline at end of file +src='' onLoad="loadFrame();" +> + \ No newline at end of file diff --git a/ecomp-portal-FE-common/client/app/views/tabs/tabs.controller.js b/ecomp-portal-FE-common/client/app/views/tabs/tabs.controller.js index c4b31ef2..3e15144a 100644 --- a/ecomp-portal-FE-common/client/app/views/tabs/tabs.controller.js +++ b/ecomp-portal-FE-common/client/app/views/tabs/tabs.controller.js @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -77,6 +77,7 @@ } // Add tab to the end of the array var addTab = function (title, content) { + if($scope.tabs.length===tabLimit){ //alert confirmBoxService.showInformation('You have reached your maximum limit of tabs allowed.').then(isConfirmed => {}); @@ -279,11 +280,18 @@ restrict: "E", templateUrl: 'app/views/tabs/tabframe.html', link: function(scope, element) { - - //var iframeId = "#tabframe-" + scope.$parent.tab.title.split(' ').join('-'); + + var iframeId = "tabframe-" + scope.$parent.tab.title.split(' ').join('-'); + var iframeVal = scope.$parent.tab.content;// + "| trusted"; + if(iframeId != 'tabframe-Home') { + sessionStorage.setItem("currentTabFrameId",iframeId); + sessionStorage.setItem("currentTabFrameVal",iframeVal); + } + //console.log(document.getElementById(sessionStorage.getItem("currentTabFrameId"))); + // jQuery(iframeId).load(function() { - // alert("hello"); - // }); //.attr("src",'{{tab.content | trusted}}' ); //src='{{tab.content | trusted}}' + // alert("hello"); + // }); //.attr("src",'{{tab.content | trusted}}' ); //src='{{tab.content | trusted}}' // jQuery(iframeId).attr('src', '{{tab.content | trusted}}'); //element.childNodes[0].on('load', function() { @@ -350,3 +358,20 @@ function isCascadeFrame(ref) { window.location = "unKnownError"; } } + +function loadFrame() { + + var interval = setInterval(function() { + + if(sessionStorage.getItem("currentTabFrameId") == null && sessionStorage.getItem("currentTabFrameVal") == null) + clearInterval(interval); + else if(document.getElementById(sessionStorage.getItem("currentTabFrameId")).src != sessionStorage.getItem("currentTabFrameVal")) { + document.getElementById(sessionStorage.getItem("currentTabFrameId")).src = sessionStorage.getItem("currentTabFrameVal"); + sessionStorage.removeItem("currentTabFrameId"); + sessionStorage.removeItem("currentTabFrameVal"); + clearInterval(interval); + } + },1000); + + + } diff --git a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js index c2067cc1..fc7fd7c2 100644 --- a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js +++ b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.controller.js @@ -78,6 +78,10 @@ var warningMsg = "Passwords do not match, please try again."; confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;}); return; + } else if(/[^a-zA-Z0-9\-\@\_]/.test(this.newUser.loginId)){ + var warningMsg = "Login ID should not contain special characters except '@', '-', and '_'."; + confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;}); + return; } else { // check password length complexity. diff --git a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html index 874b2b5e..ff8d86ec 100644 --- a/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html +++ b/ecomp-portal-FE-os/client/src/directives/search-users/search-users.tpl.html @@ -2,7 +2,7 @@ ============LICENSE_START========================================== ONAP Portal =================================================================== - Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -36,126 +36,129 @@ -->
-
-
-
-
-
Enter first name, last name or User ID
- - - -
-
+
+
+
+
Enter first name, last name + or User ID
+ + + +
+
-
-
-
-
- - -
-
-
-
-
-
-
- -
- No match found. -
- -
- No users found -
-
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
No match found.
- -
-
-
-
*First Name
- +
+ No users found
+
+ + +
+
+
+
*First Name
+
-
-
Middle Name
- +
+
Middle Name
+
-
-
*Last Name
- +
+
*Last Name
+
-
-
*Email Address ID
- +
+
*Email Address ID
+
-
-
*Login ID
- +
+
*Login ID
+
-
-
*Login Password
- +
+
*Login Password
+
-
-
*Confirm Login Password
- +
+
*Confirm Login Password
+
-
- The passwords do not match. Try again. - -
-
The + passwords do not match. Try again. +
+
- User with same loginId already exists. Try again. - -
-
-
- + User + with same loginId already exists. Try again. +
+
+ Note: Login ID should not + contain special characters except '@', '-', and '_'. +
+
+
- +
-
- -
- +
+
+ +
diff --git a/ecomp-portal-widget-ms/widget-ms/pom.xml b/ecomp-portal-widget-ms/widget-ms/pom.xml index 7c5a40e6..91dc4fd6 100644 --- a/ecomp-portal-widget-ms/widget-ms/pom.xml +++ b/ecomp-portal-widget-ms/widget-ms/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -7,7 +8,7 @@ org.springframework.boot spring-boot-starter-parent 1.4.2.RELEASE - + org.onap.portal diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java index 7ae3c270..807067b2 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java @@ -37,8 +37,24 @@ public class RoleApp implements Serializable{ @JsonIgnore @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, mappedBy="widgetRoles") - private transient Set widgets; + private Set widgets; + /*@PreRemove + private void removeGroupsFromUsers() { + for (WidgetCatalog w : widgets) { + w.getWidgetRoles().remove(this); + } + }*/ + + /*@ManyToOne + @JoinColumn(name = "WIDGET_ID", nullable = false) + WidgetCatalog widgetCatalog;*/ + + //@JsonIgnore + //@ManyToMany(mappedBy = "widgetRoles") + //@ManyToMany(fetch = FetchType.EAGER, mappedBy = "widgetRoles") + //private Set widgets = new HashSet(); + public Long getRoleId() { return roleId; } diff --git a/pom.xml b/pom.xml index 3986bf4b..e7f3360b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ - + 4.0.0 org.onap.oparent oparent 1.2.0 - + org.onap.portal @@ -124,7 +125,7 @@ - +