From: Sunder Tattavarada Date: Tue, 7 Jul 2020 17:16:42 +0000 (+0000) Subject: Merge "added annotations" X-Git-Tag: 3.4.0~45 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=d856cbc5d725836a07776b0f20f06bbbda7b5412;hp=3504c843a1322c3a43b9cfe750fdaedfad83c4a8;p=portal.git Merge "added annotations" --- diff --git a/3.2.1-container-portal-docker.yaml b/3.2.1-container-portal-docker.yaml new file mode 100644 index 00000000..8872a0a6 --- /dev/null +++ b/3.2.1-container-portal-docker.yaml @@ -0,0 +1,7 @@ +distribution_type: container +container_release_tag: 3.2.1 +project: portal +ref: b310e558488c48cadc251a3d87b1f10f044c2499 +containers: + - name: portal-app + version: 3.2.0-STAGING-latest diff --git a/deliveries/.env b/deliveries/.env index 614aeb0c..333eb9eb 100644 --- a/deliveries/.env +++ b/deliveries/.env @@ -38,11 +38,11 @@ CLI_IMG_NAME=onap/cli # This is the first portion of the Docker image tag # that is published to the ONAP registry. -PORTAL_VERSION=3.2.0 +PORTAL_VERSION=3.3.0 # This is used during builds and in docker-compose; # it is never published to the ONAP registry. -PORTAL_TAG=elalto +PORTAL_TAG=guilin # Name of directory in apps container (NOT host) WEBAPPS_DIR=/opt/apache-tomcat-8.0.37/webapps diff --git a/deliveries/build_portalapps_dockers.sh b/deliveries/build_portalapps_dockers.sh index fdaf9a15..d2349b8e 100755 --- a/deliveries/build_portalapps_dockers.sh +++ b/deliveries/build_portalapps_dockers.sh @@ -76,7 +76,7 @@ else if [ "$SDK_DOCKERFILE" != "skip" ] && [ "SDK_APP_DIR" != "skip" ]; then echo "Build Portal-SDK app" cd $BASEDIR/$SDK_APP_DIR - ${MVN} ${MVN_EXTRA_SDK} clean package + ${MVN} ${MVN_EXTRA_SDK} clean package -Dskiptests=true fi echo "Java build complete." diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 4ada1c3b..42617c22 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -28,6 +28,12 @@ This release contains an Angular upgrade, bug fixes and security enhancements. * Fixed Sonar reported critical issues. **Known Issues** + * User management pages do not work properly. We will be addressing this in the Guilin release. So, the work around is: + + 1. If we try to add user role by navigating directly to an application, like A&AI, we are unable to add roles. + 2. However, With Portal admin privileges a user (in this case Demo user) can navigate to User screen and select Portal/Default from the drop down. + 3. Then update user roles for A&AI and other applications in the popup. + 4. We validated that this operation is correctly updating the role in AAF. **Security Notes** @@ -67,11 +73,11 @@ Quick Links: **Other** * Below are the docker images released as part of Portal Platform project: - * onap/portal-app:3.2.0 - * onap/portal-db:3.2.0 - * onap/portal-sdk:3.0.0 - * onap/portal-wms:3.2.0 - * portal/sdk java artifacts - (Release branch: “release-3.0.0”) + * onap/portal-app:3.2.3 + * onap/portal-db:3.2.3 + * onap/portal-sdk:3.2.0 + * onap/portal-wms:3.2.3 + * portal/sdk java artifacts - (Release branch: “release-3.2.0”; Jar Version: "3.0.0") Version: 2.6.0 -------------- diff --git a/ecomp-portal-BE-common/pom.xml b/ecomp-portal-BE-common/pom.xml index 19d32431..85cf8757 100644 --- a/ecomp-portal-BE-common/pom.xml +++ b/ecomp-portal-BE-common/pom.xml @@ -5,7 +5,7 @@ org.onap.portal onap-portal-parent - 3.3.0 + 3.4.0 portal-be-common @@ -184,17 +184,7 @@ jaxb-api 2.4.0-b180830.0359 - - org.springframework.boot - spring-boot-starter - 1.3.1.RELEASE - - - org.slf4j - log4j-over-slf4j - - - + org.hibernate @@ -284,23 +274,23 @@ org.apache.cxf cxf-rt-rs-client - 3.3.3 + 3.3.4 com.fasterxml.jackson.core jackson-annotations - 2.8.10 + 2.10.0 com.fasterxml.jackson.core jackson-core - 2.8.10 + 2.10.0 com.fasterxml.jackson.core jackson-databind - 2.8.11.4 + 2.10.0 postgresql @@ -740,8 +730,6 @@ jersey-servlet - - org.projectlombok diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/controller/sessionmgt/SessionCommunicationController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/controller/sessionmgt/SessionCommunicationController.java index d36cf6cb..15539912 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/controller/sessionmgt/SessionCommunicationController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/controller/sessionmgt/SessionCommunicationController.java @@ -51,9 +51,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import io.swagger.annotations.ApiOperation; @@ -75,14 +76,14 @@ public class SessionCommunicationController extends EPRestrictedRESTfulBaseCont @ApiOperation(value = "Gets session slot-check interval, a duration in milliseconds.", response = Integer.class) - @RequestMapping(value={"/getSessionSlotCheckInterval"}, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value={"/getSessionSlotCheckInterval"}, produces = "application/json") public Integer getSessionSlotCheckInterval(HttpServletRequest request, HttpServletResponse response) throws Exception { return manageService.fetchSessionSlotCheckInterval(); } @ApiOperation(value = "Extends session timeout values for all on-boarded applications.", response = Boolean.class) - @RequestMapping(value={"/extendSessionTimeOuts"}, method = RequestMethod.POST) + @PostMapping(value={"/extendSessionTimeOuts"}) public Boolean extendSessionTimeOuts(HttpServletRequest request, HttpServletResponse response, @RequestParam String sessionMap) { manageService.extendSessionTimeOuts(sessionMap); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java index 7b42d52d..12deabe3 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java @@ -4,12 +4,14 @@ * =================================================================== * Copyright © 2018 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright (c) 2020 IBM + * =================================================================== * * 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 @@ -42,7 +44,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.onap.music.eelf.logging.EELFLoggerDelegate; import org.onap.music.exceptions.MusicLockingException; -import org.onap.music.exceptions.MusicServiceException; import org.onap.portalapp.music.service.MusicService; import org.onap.portalapp.music.util.MusicUtil; import org.springframework.session.Session; @@ -56,12 +57,11 @@ public class MusicSessionRepositoryHandler { public Session get(String id) { if(musicCache){ - // todo need to add the clean up for "sessions" map if musicCache is enabled + // need to add the clean up for "sessions" map if musicCache is enabled return this.sessions.get(id); }else{ try { - Session session = MusicService.getMetaAttribute(id); - return session; + return MusicService.getMetaAttribute(id); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "get failed with id " + id, e); return null; @@ -73,7 +73,7 @@ public class MusicSessionRepositoryHandler { public void remove(String id) { if(musicCache){ - // todo need to add the clean up for "sessions" map if musicCache is enabled + // need to add the clean up for "sessions" map if musicCache is enabled sessions.remove(id); }else{ try { @@ -88,7 +88,7 @@ public class MusicSessionRepositoryHandler { public void put(String id, MusicSession musicSession) { if(musicCache){ - // todo need to add the clean up for "sessions" map if musicCache is enabled + //need to add the clean up for "sessions" map if musicCache is enabled sessions.put(id, musicSession); }else{ try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppCatalogController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppCatalogController.java index 557e4dc3..714d3aba 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppCatalogController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppCatalogController.java @@ -59,9 +59,10 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; + @RestController @org.springframework.context.annotation.Configuration @@ -90,7 +91,7 @@ public class AppCatalogController extends EPRestrictedBaseController { * @throws IOException If sendError fails * @return List of items suitable for display */ - @RequestMapping(value = { "/portalApi/appCatalog" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/appCatalog" }, produces = "application/json") public List getAppCatalog(HttpServletRequest request, HttpServletResponse response) throws IOException { EPUser user = EPUserUtils.getUserSession(request); @@ -125,7 +126,7 @@ public class AppCatalogController extends EPRestrictedBaseController { * @return FieldsValidator * @throws IOException If sendError fails */ - @RequestMapping(value = { "/portalApi/appCatalog" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { "/portalApi/appCatalog" }, produces = "application/json") public FieldsValidator putAppCatalogSelection(HttpServletRequest request, @RequestBody AppCatalogPersonalization persRequest, HttpServletResponse response) throws IOException { FieldsValidator result = new FieldsValidator(); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java index 8f456fde..0bf75fbe 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java @@ -61,8 +61,9 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; @RestController @RequestMapping("/portalApi/contactus") @@ -94,7 +95,7 @@ public class AppContactUsController extends EPRestrictedBaseController { * @param request HttpServletRequest * @return PortalRestResponse */ - @RequestMapping(value = "/feedback", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/feedback", produces = "application/json") public PortalRestResponse getPortalDetails(HttpServletRequest request) { PortalRestResponse portalRestResponse; try { @@ -123,7 +124,7 @@ public class AppContactUsController extends EPRestrictedBaseController { * @param request HttpServletRequest * @return PortalRestResponse> */ - @RequestMapping(value = "/list", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/list", produces = "application/json") public PortalRestResponse> getAppContactUsList(HttpServletRequest request) { PortalRestResponse> portalRestResponse; try { @@ -145,7 +146,7 @@ public class AppContactUsController extends EPRestrictedBaseController { * @param request HttpServletRequest * @return PortalRestResponse> */ - @RequestMapping(value = "/allapps", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/allapps", produces = "application/json") public PortalRestResponse> getAppsAndContacts(HttpServletRequest request) { PortalRestResponse> portalRestResponse; try { @@ -167,7 +168,7 @@ public class AppContactUsController extends EPRestrictedBaseController { * @param request HttpServletRequest * @return PortalRestResponse> */ - @RequestMapping(value = "/functions", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/functions", produces = "application/json") public PortalRestResponse> getAppCategoryFunctions(HttpServletRequest request) { PortalRestResponse> portalRestResponse; try { @@ -190,7 +191,7 @@ public class AppContactUsController extends EPRestrictedBaseController { * @param contactUs AppContactUsItem * @return PortalRestResponse */ - @RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/save", produces = "application/json") public PortalRestResponse save(@RequestBody AppContactUsItem contactUs) { if (contactUs == null || contactUs.getAppName() == null) { @@ -210,7 +211,7 @@ public class AppContactUsController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, saveAppContactUs, ""); } - @RequestMapping(value = "/saveAll", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/saveAll", produces = "application/json") public PortalRestResponse save(@RequestBody List contactUsList) { if (contactUsList == null) { @@ -237,7 +238,7 @@ public class AppContactUsController extends EPRestrictedBaseController { * @param id app ID * @return PortalRestResponse */ - @RequestMapping(value = "/delete/{appid}", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/delete/{appid}", produces = "application/json") public PortalRestResponse delete(@PathVariable("appid") Long id) { String saveAppContactUs = FAILURE; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java index c34311c3..99b4fcee 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsController.java @@ -86,6 +86,10 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.HttpClientErrorException; @@ -121,7 +125,7 @@ public class AppsController extends EPRestrictedBaseController { * HttpServletResponse * @return List */ - @RequestMapping(value = { "/portalApi/userApps" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/userApps" }, produces = "application/json") public List getUserApps(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List ecompApps = null; @@ -152,7 +156,7 @@ public class AppsController extends EPRestrictedBaseController { * @throws IOException * if sendError fails */ - @RequestMapping(value = { "/portalApi/persUserApps" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/persUserApps" }, produces = "application/json") public List getPersUserApps(HttpServletRequest request, HttpServletResponse response) throws IOException { EPUser user = EPUserUtils.getUserSession(request); List ecompApps = null; @@ -185,7 +189,7 @@ public class AppsController extends EPRestrictedBaseController { * HttpServletResponse * @return List */ - @RequestMapping(value = { "/portalApi/adminApps" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/adminApps" }, produces = "application/json") public List getAdminApps(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List adminApps = null; @@ -214,8 +218,8 @@ public class AppsController extends EPRestrictedBaseController { * HttpServletResponse * @return List */ - @RequestMapping(value = { - "/portalApi/appsForSuperAdminAndAccountAdmin" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/appsForSuperAdminAndAccountAdmin" }, produces = "application/json") public List getAppsForSuperAdminAndAccountAdmin(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -246,7 +250,7 @@ public class AppsController extends EPRestrictedBaseController { * @return JSON with left menu */ @SuppressWarnings({ "rawtypes", "unchecked" }) - @RequestMapping(value = { "/portalApi/leftmenuItems" }, method = RequestMethod.GET, produces = "application/json;charset=UTF-8") + @GetMapping(value = { "/portalApi/leftmenuItems" }, produces = "application/json;charset=UTF-8") public String getLeftMenuItems(HttpServletRequest request, HttpServletResponse response) { String menuList = null; Set menuSet = (Set) AppUtils.getSession(request) @@ -266,8 +270,8 @@ public class AppsController extends EPRestrictedBaseController { return menuList; } - @RequestMapping(value = { - PORTAL_API_USER_APPS_ORDER_BY_SORT_PREF }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + PORTAL_API_USER_APPS_ORDER_BY_SORT_PREF }, produces = "application/json") public List getUserAppsOrderBySortPref(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List ecompApps = null; @@ -322,8 +326,8 @@ public class AppsController extends EPRestrictedBaseController { * sort pref * @return FieldsValidator */ - @RequestMapping(value = { - "/portalApi/saveUserAppsSortingManual" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/saveUserAppsSortingManual" }, produces = "application/json") public FieldsValidator putUserAppsSortingManual(HttpServletRequest request, @RequestBody List epAppsManualPref, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -346,8 +350,8 @@ public class AppsController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { - "/portalApi/saveUserWidgetsSortManual" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/saveUserWidgetsSortManual" }, produces = "application/json") public FieldsValidator putUserWidgetsSortManual(HttpServletRequest request, @RequestBody List saveManualWidgetSData, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -370,8 +374,8 @@ public class AppsController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { - "/portalApi/updateWidgetsSortPref" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/updateWidgetsSortPref" }, produces = "application/json") public FieldsValidator putUserWidgetsSortPref(HttpServletRequest request, @RequestBody List delManualWidgetData, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -406,8 +410,8 @@ public class AppsController extends EPRestrictedBaseController { * data to delete * @return FieldsValidator */ - @RequestMapping(value = { - "/portalApi/UpdateUserAppsSortManual" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/UpdateUserAppsSortManual" }, produces = "application/json") public FieldsValidator deleteUserAppSortManual(HttpServletRequest request, @RequestBody EPDeleteAppsManualSortPref delManualAppData, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -425,8 +429,8 @@ public class AppsController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { - "/portalApi/saveUserAppsSortingPreference" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/saveUserAppsSortingPreference" }, produces = "application/json") public FieldsValidator putUserAppsSortingPreference(HttpServletRequest request, @RequestBody EPAppsSortPreference userAppsValue, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -444,8 +448,8 @@ public class AppsController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { - "/portalApi/userAppsSortTypePreference" }, method = RequestMethod.GET, produces = "application/String") + @GetMapping(value = { + "/portalApi/userAppsSortTypePreference" }, produces = "application/String") public String getUserAppsSortTypePreference(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); String userSortPreference = null; @@ -476,7 +480,7 @@ public class AppsController extends EPRestrictedBaseController { * HTTP servlet response * @return List */ - @RequestMapping(value = { "/portalApi/accountAdmins" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/accountAdmins" }, produces = "application/json") public List getAppsAdministrators(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List admins = null; @@ -494,7 +498,7 @@ public class AppsController extends EPRestrictedBaseController { return admins; } - @RequestMapping(value = { "/portalApi/availableApps" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/availableApps" }, produces = "application/json") public List getApps(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List apps = null; @@ -522,8 +526,8 @@ public class AppsController extends EPRestrictedBaseController { * HTTP servlet response * @return List of applications */ - @RequestMapping(value = { - "/portalApi/allAvailableApps" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/allAvailableApps" }, produces = "application/json") public List getAllApps(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List apps = null; @@ -549,7 +553,7 @@ public class AppsController extends EPRestrictedBaseController { * HTTP servlet response * @return List of applications */ - @RequestMapping(value = { "/portalApi/appsFullList" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/appsFullList" }, produces = "application/json") public List getAppsFullList(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List ecompApps = null; @@ -570,7 +574,7 @@ public class AppsController extends EPRestrictedBaseController { * HTTP servlet response * @return UserRoles */ - @RequestMapping(value = { "/portalApi/userProfile" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/userProfile" }, produces = "application/json") public UserRoles getUserProfile(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); UserRoles userAndRoles = null; @@ -597,8 +601,7 @@ public class AppsController extends EPRestrictedBaseController { * application ID * @return List */ - @RequestMapping(value = { "/portalApi/appRoles/{appId}" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/appRoles/{appId}" }, produces = "application/json") public List getAppRoles(HttpServletRequest request, @PathVariable("appId") Long appId, HttpServletResponse response) { List roleList = null; @@ -627,8 +630,7 @@ public class AppsController extends EPRestrictedBaseController { * @param response * @return EPApp object */ - @RequestMapping(value = { "/portalApi/singleAppInfo" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/singleAppInfo" }, produces = "application/json") public EPApp getSingleAppInfo(HttpServletRequest request, HttpServletResponse response) { EPApp app = null; EPUser user = EPUserUtils.getUserSession(request); @@ -657,8 +659,7 @@ public class AppsController extends EPRestrictedBaseController { * @param response * @return EPApp object */ - @RequestMapping(value = { "/portalApi/singleAppInfoById" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/singleAppInfoById" }, produces = "application/json") public EPApp getSingleAppInfoById(HttpServletRequest request, HttpServletResponse response) { EPApp app = null; EPUser user = EPUserUtils.getUserSession(request); @@ -666,7 +667,7 @@ public class AppsController extends EPRestrictedBaseController { String appId = request.getParameter("appParam"); app = appService.getApp(Long.valueOf(appId)); if(!EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { - app.setCentralAuth(false); + app.setRolesInAAF(false); } if (user != null && (adminRolesService.isAccountAdminOfApplication(user, app) || (adminRolesService.isSuperAdmin(user) && app.getId().equals(PortalConstants.PORTAL_APP_ID)))) @@ -690,7 +691,7 @@ public class AppsController extends EPRestrictedBaseController { * HTTP servlet response * @return List */ - @RequestMapping(value = { PORTAL_API_ONBOARDING_APPS }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { PORTAL_API_ONBOARDING_APPS }, produces = "application/json") public List getOnboardingApps(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List onboardingApps = null; @@ -720,7 +721,7 @@ public class AppsController extends EPRestrictedBaseController { /** * * @param request - * HTTP servlet request + * HTTP servlet request‰ * @param response * HTTP servlet response * @param modifiedOnboardingApp @@ -728,12 +729,12 @@ public class AppsController extends EPRestrictedBaseController { * @return FieldsValidator * @throws Exception */ - @RequestMapping(value = { PORTAL_API_ONBOARDING_APPS }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { PORTAL_API_ONBOARDING_APPS }, produces = "application/json") public FieldsValidator putOnboardingApp(HttpServletRequest request, @RequestBody OnboardingApp modifiedOnboardingApp, HttpServletResponse response) { FieldsValidator fieldsValidator = null; EPUser user = null; - EPApp oldEPApp = appService.getApp(modifiedOnboardingApp.id); + EPApp oldEPApp = appService.getApp(modifiedOnboardingApp.getId()); try { user = EPUserUtils.getUserSession(request); @@ -745,7 +746,7 @@ public class AppsController extends EPRestrictedBaseController { response.getStatus()); return fieldsValidator; } else { - if((oldEPApp.getCentralAuth() && modifiedOnboardingApp.isCentralAuth && !oldEPApp.getNameSpace().equalsIgnoreCase(modifiedOnboardingApp.nameSpace) && modifiedOnboardingApp.nameSpace!= null ) || (!oldEPApp.getCentralAuth() && modifiedOnboardingApp.isCentralAuth && modifiedOnboardingApp.nameSpace!= null)) + if((oldEPApp.getRolesInAAF() && modifiedOnboardingApp.getRolesInAAF() && !oldEPApp.getNameSpace().equalsIgnoreCase(modifiedOnboardingApp.getNameSpace()) && modifiedOnboardingApp.getNameSpace()!= null ) || (!oldEPApp.getRolesInAAF() && modifiedOnboardingApp.getRolesInAAF() && modifiedOnboardingApp.getNameSpace() != null)) { checkIfNameSpaceIsValid(modifiedOnboardingApp, fieldsValidator, response); } @@ -784,7 +785,7 @@ public class AppsController extends EPRestrictedBaseController { * app to add * @return FieldsValidator */ - @RequestMapping(value = { PORTAL_API_ONBOARDING_APPS }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { PORTAL_API_ONBOARDING_APPS }, produces = "application/json") public FieldsValidator postOnboardingApp(HttpServletRequest request, @RequestBody OnboardingApp newOnboardingApp, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -794,7 +795,7 @@ public class AppsController extends EPRestrictedBaseController { EcompPortalUtils.setBadPermissions(user, response, "postOnboardingApps"); } else { newOnboardingApp.normalize(); - if(newOnboardingApp.isCentralAuth != null && newOnboardingApp.isCentralAuth) + if(newOnboardingApp.getRolesInAAF() != null && newOnboardingApp.getRolesInAAF()) checkIfNameSpaceIsValid(newOnboardingApp, fieldsValidator, response); fieldsValidator = appService.addOnboardingApp(newOnboardingApp, user); response.setStatus(fieldsValidator.httpStatusCode.intValue()); @@ -845,8 +846,7 @@ public class AppsController extends EPRestrictedBaseController { * ID of app to delete * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/onboardingApps/{appId}" }, method = { - RequestMethod.DELETE }, produces = "application/json") + @DeleteMapping(value = { "/portalApi/onboardingApps/{appId}" }, produces = "application/json") public FieldsValidator deleteOnboardingApp(HttpServletRequest request, @PathVariable("appId") Long appId, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -883,7 +883,7 @@ public class AppsController extends EPRestrictedBaseController { * Application ID * @return Bytes with the app thumbnail image; null if not available. */ - @RequestMapping(value = { "/portalApi/appThumbnail/{appId}" }, method = { RequestMethod.GET }) + @GetMapping(value = { "/portalApi/appThumbnail/{appId}" }) public HttpEntity getAppThumbnail(HttpServletRequest request, @PathVariable("appId") Long appId, HttpServletResponse response) { EPApp app = appService.getApp(appId); @@ -911,7 +911,7 @@ public class AppsController extends EPRestrictedBaseController { private void checkIfNameSpaceIsValid(OnboardingApp modifiedOnboardingApp, FieldsValidator fieldsValidator, HttpServletResponse response) throws InvalidApplicationException { try { - ResponseEntity res = appService.checkIfNameSpaceIsValid(modifiedOnboardingApp.nameSpace); + ResponseEntity res = appService.checkIfNameSpaceIsValid(modifiedOnboardingApp.getNameSpace()); } catch (HttpClientErrorException e) { logger.error(EELFLoggerDelegate.errorLogger, "checkIfNameSpaceExists failed", e); EPLogUtil.logExternalAuthAccessAlarm(logger, e.getStatusCode()); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequest.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequest.java index d5438f41..a88728a0 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequest.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequest.java @@ -65,7 +65,9 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @@ -126,7 +128,7 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl * @return PortalRestResponse with success or failure */ @ApiOperation(value = "Creates a new user as a Portal administrator.", response = PortalRestResponse.class) - @RequestMapping(value = "/portalAdmin", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/portalAdmin", produces = "application/json") @ResponseBody public PortalRestResponse postPortalAdmin(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody EPUser epUser) { @@ -200,13 +202,13 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl * @return OnboardingApp objects */ @ApiOperation(value = "Gets the specified application that is on-boarded in Portal.", response = OnboardingApp.class) - @RequestMapping(value = {ONBOARD_APP + "/{appId}"}, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = {ONBOARD_APP + "/{appId}"}, produces = "application/json") @ResponseBody public OnboardingApp getOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId) { EPApp epApp = appService.getApp(appId); OnboardingApp obApp = new OnboardingApp(); - epApp.setAppPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD); //to hide password from get request + epApp.setAppBasicAuthPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD); //to hide password from get request appService.createOnboardingFromApp(epApp, obApp); EcompPortalUtils.logAndSerializeObject(logger, "getOnboardAppExternal", RESPONSE, obApp); return obApp; @@ -234,7 +236,7 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl * @return PortalRestResponse */ @ApiOperation(value = "Adds a new application to Portal.", response = PortalRestResponse.class) - @RequestMapping(value = {ONBOARD_APP}, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = {ONBOARD_APP}, produces = "application/json") @ResponseBody public PortalRestResponse postOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody OnboardingApp newOnboardApp) { @@ -250,7 +252,7 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl return portalResponse; } // Validate fields - if (newOnboardApp.id != null) { + if (newOnboardApp.getId() != null) { portalResponse.setStatus(PortalRestStatusEnum.ERROR); portalResponse.setMessage("Unexpected field: id"); return portalResponse; @@ -264,10 +266,10 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl try { List userList; - userList = userService.getUserByUserId(newOnboardApp.myLoginsAppOwner); + userList = userService.getUserByUserId(newOnboardApp.getMyLoginsAppOwner()); if (userList == null || userList.size() != 1) { portalResponse.setStatus(PortalRestStatusEnum.ERROR); - portalResponse.setMessage("Failed to find user: " + newOnboardApp.myLoginsAppOwner); + portalResponse.setMessage("Failed to find user: " + newOnboardApp.getMyLoginsAppOwner()); return portalResponse; } @@ -322,7 +324,7 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl * @return PortalRestResponse */ @ApiOperation(value = "Updates information about an on-boarded application in Portal.", response = PortalRestResponse.class) - @RequestMapping(value = {ONBOARD_APP + "/{appId}"}, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = {ONBOARD_APP + "/{appId}"}, produces = "application/json") @ResponseBody public PortalRestResponse putOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId, @Valid @RequestBody OnboardingApp oldOnboardApp) { @@ -341,7 +343,7 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl // Validate fields. - if (appId == null || !appId.equals(oldOnboardApp.id)) { + if (appId == null || !appId.equals(oldOnboardApp.getId())) { portalResponse.setStatus(PortalRestStatusEnum.ERROR); portalResponse.setMessage("Unexpected value for field: id"); return portalResponse; @@ -356,10 +358,10 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl try { List userList; - userList = userService.getUserByUserId(oldOnboardApp.myLoginsAppOwner); + userList = userService.getUserByUserId(oldOnboardApp.getMyLoginsAppOwner()); if (userList == null || userList.size() != 1) { portalResponse.setStatus(PortalRestStatusEnum.ERROR); - portalResponse.setMessage("Failed to find user: " + oldOnboardApp.myLoginsAppOwner); + portalResponse.setMessage("Failed to find user: " + oldOnboardApp.getMyLoginsAppOwner()); return portalResponse; } @@ -396,15 +398,15 @@ public class AppsControllerExternalRequest implements BasicAuthenticationControl } private boolean checkIfFieldsAreNull(OnboardingApp onboardingApp) { - return onboardingApp.name == null || onboardingApp.url == null || onboardingApp.restUrl == null - || onboardingApp.myLoginsAppOwner == null || onboardingApp.restrictedApp == null - || onboardingApp.isOpen == null || onboardingApp.isEnabled == null; + return onboardingApp.getAppName() == null || onboardingApp.getLandingPage() == null || onboardingApp.getRestUrl() == null + || onboardingApp.getMyLoginsAppOwner() == null || onboardingApp.getRestrictedApp() == null + || onboardingApp.getIsOpen() == null || onboardingApp.getIsEnabled() == null; } private boolean checkIfFieldsAreEmpty(OnboardingApp onboardingApp) { - return onboardingApp.name.trim().isEmpty() - || onboardingApp.url.trim().isEmpty() - || onboardingApp.restUrl.trim().isEmpty() - || onboardingApp.myLoginsAppOwner.trim().isEmpty(); + return onboardingApp.getAppName().trim().isEmpty() + || onboardingApp.getLandingPage().trim().isEmpty() + || onboardingApp.getRestUrl().trim().isEmpty() + || onboardingApp.getMyLoginsAppOwner().trim().isEmpty(); } } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalVersionRequest.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalVersionRequest.java index 13a6811e..5af76aa5 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalVersionRequest.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppsControllerExternalVersionRequest.java @@ -44,16 +44,8 @@ import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.logging.aop.EPAuditLog; import org.onap.portalapp.portal.transport.OnboardingApp; -import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import io.swagger.annotations.ApiOperation; @org.springframework.context.annotation.Configuration @EnableAspectJAutoProxy diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java index cff8245a..dc5127c6 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java @@ -48,7 +48,7 @@ import org.onap.portalapp.validation.SecureString; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -91,7 +91,7 @@ public class AuditLogController extends EPRestrictedBaseController { * @param comment * Comment */ - @RequestMapping(value = "/store", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/store", produces = "application/json") public void auditLog(HttpServletRequest request, @RequestParam String affectedAppId, @RequestParam String type, @RequestParam String comment) { logger.debug(EELFLoggerDelegate.debugLogger, "auditLog: appId {}, type {}, comment {}", affectedAppId, type, diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuxApiRequestMapperController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuxApiRequestMapperController.java index 969605ce..9acb8833 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuxApiRequestMapperController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuxApiRequestMapperController.java @@ -47,7 +47,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.atomic.AtomicReference; import java.util.jar.Attributes; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -85,7 +84,10 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @@ -107,7 +109,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B private ManifestService manifestService; @ApiOperation(value = "Gets user roles for an application which is upgraded to newer version.", response = String.class, responseContainer = "List") - @RequestMapping(value = { "/v3/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/user/{loginId}" }, produces = "application/json") public String getUser(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) throws Exception { if (loginId!=null){ @@ -129,7 +131,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets roles for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/roles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/roles" }, produces = "application/json") public List getRoles(HttpServletRequest request, HttpServletResponse response) throws Exception { Map res = getMethod(request, response); request.getMethod(); @@ -144,7 +146,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Saves role for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/role" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/role" }, produces = "application/json") public PortalRestResponse saveRole(HttpServletRequest request, HttpServletResponse response, @RequestBody Role role) throws Exception { Map res = getMethod(request, response); @@ -159,7 +161,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Gets v2 role information for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/role/{role_id}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/role/{role_id}" }, produces = "application/json") public CentralV2Role getRoleInfo(HttpServletRequest request, HttpServletResponse response, @PathVariable("role_id") Long roleId) throws Exception { Map res = getMethod(request, response); @@ -175,7 +177,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets all active Users of application", response = String.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/users" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/users" }, produces = "application/json") public List getUsersOfApplication(HttpServletRequest request, HttpServletResponse response) throws Exception { Map res = getMethod(request, response); @@ -190,7 +192,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets all role functions for an application which is upgraded to newer version.", response = CentralV2RoleFunction.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/functions" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/functions" }, produces = "application/json") public List getRoleFunctionsList(HttpServletRequest request, HttpServletResponse response) throws Exception { Map res = getMethod(request, response); @@ -204,7 +206,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Gets role information for an application provided by function code.", response = CentralV2RoleFunction.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/function/{code}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/function/{code}" }, produces = "application/json") public CentralV2RoleFunction getRoleFunction(HttpServletRequest request, HttpServletResponse response, @PathVariable("code") String code) throws Exception { if (code!=null){ @@ -225,7 +227,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Saves role function for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/roleFunction" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/roleFunction" }, produces = "application/json") public PortalRestResponse saveRoleFunction(HttpServletRequest request, HttpServletResponse response, @RequestBody String roleFunc) throws Exception { if (roleFunc!=null){ @@ -250,7 +252,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Deletes role function for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/roleFunction/{code}" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/v3/roleFunction/{code}" }, produces = "application/json") public PortalRestResponse deleteRoleFunction(HttpServletRequest request, HttpServletResponse response, @PathVariable("code") String code) throws Exception { PortalRestResponse result = null; @@ -273,7 +275,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "deletes roles for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/deleteRole/{roleId}" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/v3/deleteRole/{roleId}" }, produces = "application/json") public PortalRestResponse deleteRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("roleId") Long roleId) throws Exception { PortalRestResponse result = null; @@ -289,7 +291,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets active roles for an application.", response = CentralV2Role.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/activeRoles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/activeRoles" }, produces = "application/json") public List getActiveRoles(HttpServletRequest request, HttpServletResponse response) throws Exception { List cenRole = null; @@ -303,7 +305,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Gets ecompUser of an application.", response = CentralUser.class, responseContainer = "List") - @RequestMapping(value = { "/v4/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v4/user/{loginId}" }, produces = "application/json") public String getEcompUser(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) throws Exception { Map res = getMethod(request, response); @@ -326,7 +328,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets user ecomp role for an application.", response = CentralUser.class, responseContainer = "List") - @RequestMapping(value = { "/v4/roles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v4/roles" }, produces = "application/json") public List getEcompRolesOfApplication(HttpServletRequest request, HttpServletResponse response) throws Exception { Map res = getMethod(request, response); @@ -340,8 +342,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Gets session slot-check interval, a duration in milliseconds.", response = Integer.class) - @RequestMapping(value = { - "/v3/getSessionSlotCheckInterval" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/v3/getSessionSlotCheckInterval" }, produces = "application/json") public Integer getSessionSlotCheckInterval(HttpServletRequest request, HttpServletResponse response) throws Exception { Map res = getMethod(request, response); @@ -355,7 +357,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Extends session timeout values for all on-boarded applications.", response = Boolean.class) - @RequestMapping(value = { "/v3/extendSessionTimeOuts" }, method = RequestMethod.POST) + @PostMapping(value = { "/v3/extendSessionTimeOuts" }) public Boolean extendSessionTimeOuts(HttpServletRequest request, HttpServletResponse response, @RequestParam String sessionMap) throws Exception { @@ -377,7 +379,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Gets javascript with functions that support gathering and reporting web analytics.", response = String.class) - @RequestMapping(value = { "/v3/analytics" }, method = RequestMethod.GET, produces = "application/javascript") + @GetMapping(value = { "/v3/analytics" }, produces = "application/javascript") public String getAnalyticsScript(HttpServletRequest request, HttpServletResponse response) throws Exception { Map res = getMethod(request, response); String ans = null; @@ -389,7 +391,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B return ans; } - @RequestMapping(value = { "/v3/storeAnalytics" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/storeAnalytics" }, produces = "application/json") @ResponseBody @ApiOperation(value = "Accepts data from partner applications with web analytics data.", response = PortalAPIResponse.class) public PortalAPIResponse storeAnalyticsScript(HttpServletRequest request, HttpServletResponse response, @@ -413,8 +415,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload functions for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { - "/v3/upload/portal/functions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { + "/v3/upload/portal/functions" }, produces = "application/json") public PortalRestResponse bulkUploadFunctions(HttpServletRequest request, HttpServletResponse response) throws Exception { Optional> result = null; @@ -434,7 +436,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload roles for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/upload/portal/roles" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/upload/portal/roles" }, produces = "application/json") public PortalRestResponse bulkUploadRoles(HttpServletRequest request, HttpServletResponse response) throws Exception { Optional> result; @@ -454,8 +456,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload role functions for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { - "/v3/upload/portal/roleFunctions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { + "/v3/upload/portal/roleFunctions" }, produces = "application/json") public PortalRestResponse bulkUploadRoleFunctions(HttpServletRequest request, HttpServletResponse response) throws Exception { Optional> result; @@ -475,8 +477,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload user roles for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { - "/v3/upload/portal/userRoles" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { + "/v3/upload/portal/userRoles" }, produces = "application/json") public PortalRestResponse bulkUploadUserRoles(HttpServletRequest request, HttpServletResponse response) throws Exception { Optional> result; @@ -497,8 +499,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload users for renamed role of an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { - "/v3/upload/portal/userRole/{roleId}" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { + "/v3/upload/portal/userRole/{roleId}" }, produces = "application/json") public PortalRestResponse bulkUploadUsersSingleRole(HttpServletRequest request, HttpServletResponse response, @PathVariable Long roleId) throws Exception { Optional> result = null; @@ -518,8 +520,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload functions for an partner application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { - "/v3/upload/partner/functions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { + "/v3/upload/partner/functions" }, produces = "application/json") public PortalRestResponse bulkUploadPartnerFunctions(HttpServletRequest request, HttpServletResponse response) throws Exception { Optional> result = null; @@ -540,7 +542,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B // not using @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload roles for an partner application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/upload/partner/roles" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/upload/partner/roles" }, produces = "application/json") public PortalRestResponse bulkUploadPartnerRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody List upload) throws Exception { Optional> result = null; @@ -560,8 +562,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Bulk upload role functions for an partner application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { - "/v3/upload/partner/roleFunctions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { + "/v3/upload/partner/roleFunctions" }, produces = "application/json") public PortalRestResponse bulkUploadPartnerRoleFunctions(HttpServletRequest request, HttpServletResponse response) throws Exception { Optional> result = null; @@ -581,7 +583,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets all functions along with global functions", response = List.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/menuFunctions" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/menuFunctions" }, produces = "application/json") public List getMenuFunctions(HttpServletRequest request, HttpServletResponse response) throws Exception { List functionsList = null; Map res = getMethod(request, response); @@ -796,7 +798,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Creates an application user with the specified roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/v3/userProfile" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/userProfile" }, produces = "application/json") public PortalRestResponse postUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { @@ -818,7 +820,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Updates an application user to have only the specified roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/v3/userProfile" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { "/v3/userProfile" }, produces = "application/json") public PortalRestResponse putUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { @@ -840,7 +842,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Processes a request to delete one or more application roles for one specified user who has roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/v3/userProfile" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/v3/userProfile" }, produces = "application/json") public PortalRestResponse deleteUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { @@ -862,7 +864,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Accepts messages from external ticketing systems and creates notifications for Portal users.", response = PortalRestResponse.class) - @RequestMapping(value = { "/v3/ticketevent" }, method = RequestMethod.POST) + @PostMapping(value = { "/v3/ticketevent" }) public PortalRestResponse handleRequest(HttpServletRequest request, HttpServletResponse response, @RequestBody String ticketEventJson) throws Exception { @@ -885,7 +887,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Creates a new user as a Portal administrator.", response = PortalRestResponse.class) - @RequestMapping(value = "/v3/portalAdmin", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/v3/portalAdmin", produces = "application/json") @ResponseBody public PortalRestResponse postPortalAdmin(HttpServletRequest request, HttpServletResponse response, @RequestBody EPUser epUser) { @@ -907,7 +909,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Gets the specified application that is on-boarded in Portal.", response = OnboardingApp.class) - @RequestMapping(value = { "/v3/onboardApp/{appId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/onboardApp/{appId}" }, produces = "application/json") @ResponseBody public OnboardingApp getOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId) { @@ -923,7 +925,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Adds a new application to Portal.", response = PortalRestResponse.class) - @RequestMapping(value = { "/v3/onboardApp" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/onboardApp" }, produces = "application/json") @ResponseBody public PortalRestResponse postOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, @RequestBody OnboardingApp newOnboardApp) { @@ -947,7 +949,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Updates information about an on-boarded application in Portal.", response = PortalRestResponse.class) - @RequestMapping(value = { "/v3/onboardApp/{appId}" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { "/v3/onboardApp/{appId}" }, produces = "application/json") @ResponseBody public PortalRestResponse putOnboardAppExternal(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId, @RequestBody OnboardingApp oldOnboardApp) { @@ -969,7 +971,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Creates a Portal user notification for roles identified in the content from an external application.", response = PortalAPIResponse.class) - @RequestMapping(value = { "/v3/publishNotification" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/v3/publishNotification" }, produces = "application/json") @ResponseBody public PortalAPIResponse publishNotification(HttpServletRequest request, @RequestBody EpNotificationItem notificationItem, HttpServletResponse response) { @@ -990,7 +992,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets favorite items within the functional menu for the current user.", response = FavoritesFunctionalMenuItemJson.class, responseContainer = "List") - @RequestMapping(value = { "/v3/getFavorites" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/getFavorites" }, produces = "application/json") public List getFavoritesForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { List favorites = null; @@ -1005,8 +1007,8 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @SuppressWarnings("unchecked") @ApiOperation(value = "Gets functional menu items appropriate for the current user.", response = FunctionalMenuItem.class, responseContainer = "List") - @RequestMapping(value = { - "/v3/functionalMenuItemsForUser" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/v3/functionalMenuItemsForUser" }, produces = "application/json") public List getFunctionalMenuItemsForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { List fnMenuItems = null; @@ -1021,7 +1023,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B @ApiOperation(value = "Gets MechId roles", response = String.class, responseContainer = "List") - @RequestMapping(value = { "/v3/systemUser" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v3/systemUser" }, produces = "application/json") public List getSystemUserPerms(HttpServletRequest request, HttpServletResponse response) throws Exception { List permsList = null; Map res = getMethod(request, response); @@ -1034,7 +1036,7 @@ public class AuxApiRequestMapperController implements ApplicationContextAware, B } @ApiOperation(value = "Update role description in external auth system for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v3/update/app/roleDescription" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { "/v3/update/app/roleDescription" }, produces = "application/json") public PortalRestResponse updateAppRoleDescription(HttpServletRequest request, HttpServletResponse response) throws Exception { PortalRestResponse result = null; Map res = getMethod(request, response); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java index 51b1d484..60164967 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java @@ -40,7 +40,7 @@ package org.onap.portalapp.portal.controller; import javax.servlet.http.HttpServletRequest; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.onap.portalapp.portal.domain.BEProperty; @@ -56,7 +56,7 @@ public class BEPropertyReaderController extends FusionBaseController{ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(BEPropertyReaderController.class); - @RequestMapping(value = "/readProperty", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/readProperty", produces = "application/json") public PortalRestResponse readProperty(HttpServletRequest request, @RequestParam String key) { try { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", new BEProperty(key, SystemProperties.getProperty(key))); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java index f655d352..24c08f3a 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java @@ -59,8 +59,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -96,7 +98,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * @throws Exception * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/basicAuthAccount" }) public PortalRestResponse createBasicAuthAccount(HttpServletRequest request, HttpServletResponse response, @RequestBody BasicAuthCredentials newBasicAuthAccount) throws Exception { @@ -153,7 +155,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/basicAuthAccount" }) public PortalRestResponse> getBasicAuthAccount(HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -182,7 +184,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * @throws Exception * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }, method = RequestMethod.PUT) + @PutMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }) public PortalRestResponse updateAccount(HttpServletRequest request, HttpServletResponse response, @PathVariable("accountId") long accountId, @RequestBody BasicAuthCredentials newBasicAuthAccount) throws Exception { @@ -219,7 +221,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * @throws Exception * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }) public PortalRestResponse deleteAccount(HttpServletRequest request, HttpServletResponse response, @PathVariable("accountId") long accountId) throws Exception { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java index ee17ac0a..66b9df20 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java @@ -47,8 +47,7 @@ import org.onap.portalapp.portal.service.DashboardSearchService; import org.onap.portalapp.portal.transport.CommonWidgetMeta; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -83,7 +82,7 @@ public class CommonWidgetController extends EPRestrictedBaseController implement * Request parameter. * @return Rest response wrapped around a CommonWidgetMeta object. */ - @RequestMapping(value = "/commonWidgets", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/commonWidgets", produces = "application/json") public PortalRestResponse getWidgetData(HttpServletRequest request, @RequestParam String resourceType) { if (!isValidResourceType(resourceType)){ diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java index 6137aec9..ff89bb88 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java @@ -78,7 +78,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -132,7 +133,7 @@ public class DashboardController extends EPRestrictedBaseController { * Request parameter. * @return Rest response wrapped around a CommonWidgetMeta object. */ - @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/widgetData", produces = "application/json") public PortalRestResponse getWidgetData(HttpServletRequest request, @RequestParam String resourceType) { if (!isValidResourceType(resourceType)) { @@ -154,7 +155,7 @@ public class DashboardController extends EPRestrictedBaseController { * read from POST body. * @return Rest response wrapped around a String; e.g., "success" or "ERROR" */ - @RequestMapping(value = "/widgetDataBulk", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/widgetDataBulk", produces = "application/json") public PortalRestResponse saveWidgetDataBulk(@RequestBody CommonWidgetMeta commonWidgetMeta) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta); if (!DATA_VALIDATOR.isValid(commonWidgetMeta)){ @@ -183,7 +184,7 @@ public class DashboardController extends EPRestrictedBaseController { * read from POST body * @return Rest response wrapped around a String; e.g., "success" or "ERROR" */ - @RequestMapping(value = "/widgetData", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/widgetData", produces = "application/json") public PortalRestResponse saveWidgetData(@RequestBody CommonWidget commonWidget, HttpServletRequest request, HttpServletResponse response) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); EPUser user = EPUserUtils.getUserSession(request); @@ -249,7 +250,7 @@ public class DashboardController extends EPRestrictedBaseController { * read from POST body * @return Rest response wrapped around a String; e.g., "success" or "ERROR" */ - @RequestMapping(value = "/deleteData", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/deleteData", produces = "application/json") public PortalRestResponse deleteWidgetData(@RequestBody CommonWidget commonWidget) { logger.debug(EELFLoggerDelegate.debugLogger, "deleteWidgetData: argument is {}", commonWidget); if (!DATA_VALIDATOR.isValid(commonWidget)){ @@ -269,7 +270,7 @@ public class DashboardController extends EPRestrictedBaseController { * Result Item. */ @EPAuditLog - @RequestMapping(value = "/search", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/search", produces = "application/json") public PortalRestResponse>> searchPortal(HttpServletRequest request, @RequestParam String searchString) { if (!DATA_VALIDATOR.isValid(new SecureString(searchString))){ @@ -330,7 +331,7 @@ public class DashboardController extends EPRestrictedBaseController { * @param request * @return Rest response wrapped around a list of String */ - @RequestMapping(value = "/activeUsers", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/activeUsers", produces = "application/json") public List getActiveUsers(HttpServletRequest request) { List activeUsers; List onlineUsers = new ArrayList<>(); @@ -358,7 +359,7 @@ public class DashboardController extends EPRestrictedBaseController { * @param request * @return Rest response wrapped around a number that is the number of milliseconds. */ - @RequestMapping(value = "/onlineUserUpdateRate", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/onlineUserUpdateRate", produces = "application/json") public PortalRestResponse> getOnlineUserUpdateRate(HttpServletRequest request) { try { String updateRate = SystemProperties.getProperty(EPCommonSystemProperties.ONLINE_USER_UPDATE_RATE); @@ -381,7 +382,7 @@ public class DashboardController extends EPRestrictedBaseController { * @param request * @return Rest response wrapped around a number that is the window width threshold to collapse right menu. */ - @RequestMapping(value = "/windowWidthThresholdRightMenu", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/windowWidthThresholdRightMenu", produces = "application/json") public PortalRestResponse> getWindowWidthThresholdForRightMenu(HttpServletRequest request) { try { String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_RIGHT_MENU); @@ -402,7 +403,7 @@ public class DashboardController extends EPRestrictedBaseController { * @param request * @return Rest response wrapped around a number that is the window width threshold to collapse the left menu. */ - @RequestMapping(value = "/windowWidthThresholdLeftMenu", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/windowWidthThresholdLeftMenu", produces = "application/json") public PortalRestResponse> getWindowWidthThresholdForLeftMenu(HttpServletRequest request) { try { String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_LEFT_MENU); @@ -422,7 +423,7 @@ public class DashboardController extends EPRestrictedBaseController { * @param request * @return Rest response wrapped around a List of String */ - @RequestMapping(value = "/relatedUsers", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/relatedUsers", produces = "application/json") public PortalRestResponse> activeUsers(HttpServletRequest request) { EPUser user = EPUserUtils.getUserSession(request); try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java index 04ee5e0b..6ad88aef 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java @@ -68,7 +68,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -90,7 +91,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * Request parameter. * @return Rest response wrapped around a CommonWidgetMeta object. */ - @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/widgetData", produces = "application/json") public PortalRestResponse getWidgetData(HttpServletRequest request, @RequestParam String resourceType) { if (stringIsNotSafeHtml(resourceType)) { @@ -107,7 +108,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * read from POST body. * @return Rest response wrapped around a String; e.g., "success" or "ERROR" */ - @RequestMapping(value = "/widgetDataBulk", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/widgetDataBulk", produces = "application/json") public PortalRestResponse saveWidgetDataBulk(@Valid @RequestBody CommonWidgetMeta commonWidgetMeta) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta); if (commonWidgetMeta.getCategory() == null || commonWidgetMeta.getCategory().trim().equals("")){ @@ -137,7 +138,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * read from POST body * @return Rest response wrapped around a String; e.g., "success" or "ERROR" */ - @RequestMapping(value = "/widgetData", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/widgetData", produces = "application/json") public PortalRestResponse saveWidgetData(@Valid @RequestBody CommonWidget commonWidget) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); if (commonWidget.getCategory() == null || commonWidget.getCategory().trim().equals("")){ @@ -186,7 +187,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * read from POST body * @return Rest response wrapped around a String; e.g., "success" or "ERROR" */ - @RequestMapping(value = "/deleteData", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/deleteData", produces = "application/json") public PortalRestResponse deleteWidgetData(@Valid @RequestBody CommonWidget commonWidget) { if (commonWidget!=null){ Validator validator = VALIDATOR_FACTORY.getValidator(); @@ -208,7 +209,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * @return Rest response wrapped around a Map of String to List of Search * Result Item. */ - @RequestMapping(value = "/allPortal", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/allPortal", produces = "application/json") public PortalRestResponse>> searchPortal(HttpServletRequest request, @RequestParam String searchString) { @@ -246,7 +247,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * @param request * @return Rest response wrapped around a list of String */ - @RequestMapping(value = "/activeUsers", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/activeUsers", produces = "application/json") public List getActiveUsers(HttpServletRequest request) { List activeUsers = null; List onlineUsers = new ArrayList<>(); @@ -274,7 +275,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * @param request * @return Rest response wrapped around a List of String */ - @RequestMapping(value = "/relatedUsers", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/relatedUsers", produces = "application/json") public PortalRestResponse> activeUsers(HttpServletRequest request) { EPUser user = EPUserUtils.getUserSession(request); try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/EncryptAdminController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/EncryptAdminController.java index 258a7fd5..4f02f240 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/EncryptAdminController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/EncryptAdminController.java @@ -59,7 +59,7 @@ import org.onap.portalsdk.core.service.DataAccessService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -75,7 +75,7 @@ public class EncryptAdminController implements BasicAuthenticationController { EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EncryptAdminController.class); - @RequestMapping(value = { "/executeEncryptQuery" }, method = RequestMethod.POST) + @PostMapping(value = { "/executeEncryptQuery" }) public Map executeEncrypt(HttpServletRequest request, HttpServletResponse response) throws CipherUtilException { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java index 7d9f297c..67e71c50 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -90,7 +92,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RestController; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -124,8 +128,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl private UserService userservice = new UserServiceCentalizedImpl(); @ApiOperation(value = "Gets user role for an application.", response = CentralUser.class, responseContainer="List") - @RequestMapping(value = { - "/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/user/{loginId}" }, produces = "application/json") public CentralUser getUser(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) throws Exception { if (!DATA_VALIDATOR.isValid(new SecureString(loginId))){ @@ -145,8 +149,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets user roles for an application which is upgraded to newer version.", response = String.class, responseContainer="List") - @RequestMapping(value = { - "/v1/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/v1/user/{loginId}" }, produces = "application/json") public String getV2UserList(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) throws Exception { if (!DATA_VALIDATOR.isValid(new SecureString(loginId))){ @@ -166,8 +170,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets roles for an application.", response = CentralRole.class, responseContainer="Json") - @RequestMapping(value = { - "/roles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/roles" }, produces = "application/json") public List getRolesForApp(HttpServletRequest request, HttpServletResponse response) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "Request received for getRolesForApp"); List v2CenRole = null; @@ -190,8 +194,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets roles for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer="Json") - @RequestMapping(value = { - "/v1/roles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/v1/roles" }, produces = "application/json") public List getV2RolesForApp(HttpServletRequest request, HttpServletResponse response) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "Request received for getV2RolesForApp"); List answer = null; @@ -212,8 +216,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets all role functions for an application for older version.", response = CentralRoleFunction.class, responseContainer="Json") - @RequestMapping(value = { - "/functions" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/functions" }, produces = "application/json") public List getRoleFunctionsList(HttpServletRequest request, HttpServletResponse response) throws Exception { List answer = null; @@ -237,8 +241,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets all role functions for an application which is upgraded to newer version.", response = CentralV2RoleFunction.class, responseContainer="Json") - @RequestMapping(value = { - "/v1/functions" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/v1/functions" }, produces = "application/json") public List getV2RoleFunctionsList(HttpServletRequest request, HttpServletResponse response) throws Exception { List cenRoleFuncList = null; @@ -261,8 +265,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @ApiOperation(value = "Gets role information for an application.", response = CentralRole.class, responseContainer="Json") - @RequestMapping(value = { - "/role/{role_id}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/role/{role_id}" }, produces = "application/json") public CentralRole getRoleInfo(HttpServletRequest request, HttpServletResponse response, @PathVariable("role_id") Long roleId) throws Exception { CentralV2Role answer = null; @@ -281,8 +285,8 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets v2 role information for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer="Json") - @RequestMapping(value = { - "/v1/role/{role_id}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/v1/role/{role_id}" }, produces = "application/json") public CentralV2Role getV2RoleInfo(HttpServletRequest request, HttpServletResponse response, @PathVariable("role_id") Long roleId) throws Exception { CentralV2Role answer = null; @@ -299,7 +303,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets role information for an application provided by function code.", response = CentralRoleFunction.class, responseContainer = "Json") - @RequestMapping(value = { "/function/{code}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/function/{code}" }, produces = "application/json") public CentralRoleFunction getRoleFunction(HttpServletRequest request, HttpServletResponse response, @PathVariable("code") String code) throws Exception { CentralV2RoleFunction centralV2RoleFunction = null; @@ -322,7 +326,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets role information for an application provided by function code.", response = CentralV2RoleFunction.class, responseContainer = "Json") - @RequestMapping(value = { "/v1/function/{code}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v1/function/{code}" }, produces = "application/json") public CentralV2RoleFunction getV2RoleFunction(HttpServletRequest request, HttpServletResponse response, @PathVariable("code") String code) throws Exception { CentralV2RoleFunction centralV2RoleFunction = null; @@ -344,7 +348,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Saves role function for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/roleFunction" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/roleFunction" }, produces = "application/json") public PortalRestResponse saveRoleFunction(HttpServletRequest request, HttpServletResponse response, @RequestBody String roleFunc) { String status = "Successfully saved!"; @@ -437,7 +441,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Deletes role function for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/roleFunction/{code}" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/roleFunction/{code}" }, produces = "application/json") public PortalRestResponse deleteRoleFunction(HttpServletRequest request, HttpServletResponse response, @PathVariable("code") String code) { if(!DATA_VALIDATOR.isValid(new SecureString(code))){ @@ -492,7 +496,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Saves role for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/role" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/role" }, produces = "application/json") public PortalRestResponse saveRole(HttpServletRequest request, HttpServletResponse response, @RequestBody Role role) { try { @@ -553,7 +557,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Deletes role for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/deleteRole/{code}" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/deleteRole/{code}" }, produces = "application/json") public PortalRestResponse deleteRole(HttpServletRequest request, HttpServletResponse response, @PathVariable String code) { if(!DATA_VALIDATOR.isValid(new SecureString(code))){ @@ -608,7 +612,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets active roles for an application.", response = CentralRole.class, responseContainer = "Json") - @RequestMapping(value = { "/activeRoles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/activeRoles" }, produces = "application/json") public List getActiveRoles(HttpServletRequest request, HttpServletResponse response) throws Exception { List roles = null; try { @@ -624,7 +628,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets active roles for an application.", response = CentralV2Role.class, responseContainer = "Json") - @RequestMapping(value = { "/v1/activeRoles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v1/activeRoles" }, produces = "application/json") public List getV2ActiveRoles(HttpServletRequest request, HttpServletResponse response) throws Exception { List cenRole = null; try { @@ -639,7 +643,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "deletes user roles for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/deleteDependcyRoleRecord/{roleId}" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/deleteDependcyRoleRecord/{roleId}" }, produces = "application/json") public PortalRestResponse deleteDependencyRoleRecord(HttpServletRequest request, HttpServletResponse response, @PathVariable("roleId") Long roleId) { ExternalRequestFieldsValidator removeResult = null; @@ -666,7 +670,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @ApiOperation(value = "deletes roles for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/v2/deleteRole/{roleId}" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/v2/deleteRole/{roleId}" }, produces = "application/json") public PortalRestResponse deleteRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("roleId") Long roleId) { ExternalRequestFieldsValidator removeResult = null; @@ -693,7 +697,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @ApiOperation(value = "Bulk upload functions for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/portal/functions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/portal/functions" }, produces = "application/json") public PortalRestResponse bulkUploadFunctions(HttpServletRequest request, HttpServletResponse response) { Integer result = 0; try { @@ -707,7 +711,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Bulk upload roles for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/portal/roles" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/portal/roles" }, produces = "application/json") public PortalRestResponse bulkUploadRoles(HttpServletRequest request, HttpServletResponse response) { Integer result = 0; try { @@ -721,7 +725,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Bulk upload role functions for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/portal/roleFunctions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/portal/roleFunctions" }, produces = "application/json") public PortalRestResponse bulkUploadRoleFunctions(HttpServletRequest request, HttpServletResponse response) { Integer result = 0; try { @@ -735,7 +739,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Bulk upload user roles for an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/portal/userRoles" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/portal/userRoles" }, produces = "application/json") public PortalRestResponse bulkUploadUserRoles(HttpServletRequest request, HttpServletResponse response) { Integer result = 0; try { @@ -749,7 +753,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Bulk upload users for renamed role of an application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/portal/userRole/{roleId}" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/portal/userRole/{roleId}" }, produces = "application/json") public PortalRestResponse bulkUploadUsersSingleRole(HttpServletRequest request, HttpServletResponse response, @PathVariable Long roleId) { Integer result = 0; try { @@ -764,7 +768,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Bulk upload functions for an partner application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/partner/functions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/partner/functions" }, produces = "application/json") public PortalRestResponse bulkUploadPartnerFunctions(HttpServletRequest request, HttpServletResponse response) { Integer addedFunctions = 0; try { @@ -779,7 +783,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Bulk upload roles for an partner application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/partner/roles" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/partner/roles" }, produces = "application/json") public PortalRestResponse bulkUploadPartnerRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody List upload) { try { externalAccessRolesService.bulkUploadPartnerRoles(request.getHeader(UEBKEY), upload); @@ -792,7 +796,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Bulk upload role functions for an partner application.", response = PortalRestResponse.class, responseContainer = "Json") - @RequestMapping(value = { "/upload/partner/roleFunctions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/upload/partner/roleFunctions" }, produces = "application/json") public PortalRestResponse bulkUploadPartnerRoleFunctions(HttpServletRequest request, HttpServletResponse response) { Integer addedRoleFunctions = 0; try { @@ -808,7 +812,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets all functions along with global functions", response = List.class, responseContainer = "Json") - @RequestMapping(value = { "/menuFunctions" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/menuFunctions" }, produces = "application/json") public List getMenuFunctions(HttpServletRequest request, HttpServletResponse response) throws Exception { List functionsList = null; try { @@ -822,7 +826,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets all active Users of application", response = String.class, responseContainer = "Json") - @RequestMapping(value = { "/users" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/users" }, produces = "application/json") public List getUsersOfApplication(HttpServletRequest request, HttpServletResponse response) throws Exception { List users = null; try { @@ -847,7 +851,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl if(app.isEmpty()){ throw new Exception(INVALID_UEB_KEY); } - if(!app.isEmpty() && app.get(0).getCentralAuth()){ + if(!app.isEmpty() && app.get(0).getRolesInAAF()){ ResponseEntity response = externalAccessRolesService.getNameSpaceIfExists(app.get(0)); if (response.getStatusCode().value() == HttpServletResponse.SC_NOT_FOUND) throw new Exception("Invalid NameSpace"); @@ -882,7 +886,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets ecompUser of an application.", response = CentralUser.class, responseContainer = "List") - @RequestMapping(value = { "/v2/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v2/user/{loginId}" }, produces = "application/json") public String getEcompUser(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) throws Exception { if(!DATA_VALIDATOR.isValid(new SecureString(loginId))){ @@ -913,7 +917,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets user ecomp role for an application.", response = CentralUser.class, responseContainer = "List") - @RequestMapping(value = { "/v2/roles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/v2/roles" }, produces = "application/json") public List getEcompRolesOfApplication(HttpServletRequest request, HttpServletResponse response) throws Exception { List ecompRoles = null; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java index 5aea7f1c..d43d9f3e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java @@ -6,6 +6,8 @@ * =================================================================== * Modifications Copyright (c) 2019 Samsung * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -70,7 +72,6 @@ import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalapp.portal.utils.PortalConstants; import org.onap.portalapp.validation.DataValidator; -import org.onap.portalapp.validation.SecureString; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.crossapi.PortalAPIResponse; import org.onap.portalsdk.core.onboarding.util.CipherUtil; @@ -83,7 +84,8 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @@ -115,7 +117,7 @@ public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseContro private EPRoleService epRoleService; @ApiOperation(value = "Creates a Portal user notification for roles identified in the content from an external application.", response = PortalAPIResponse.class) - @RequestMapping(value = { "/publishNotification" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/publishNotification" }, produces = "application/json") @ResponseBody public PortalAPIResponse publishNotification(HttpServletRequest request, @RequestBody EpNotificationItem notificationItem) throws Exception { @@ -175,7 +177,7 @@ public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseContro } @ApiOperation(value = "Gets favorite items within the functional menu for the current user.", response = FavoritesFunctionalMenuItemJson.class, responseContainer="List") - @RequestMapping(value = { "/getFavorites" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/getFavorites" }, produces = "application/json") public List getFavoritesForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { String loginId = ""; @@ -204,8 +206,8 @@ public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseContro } @ApiOperation(value = "Gets functional menu items appropriate for the current user.", response = FunctionalMenuItem.class, responseContainer="List") - @RequestMapping(value = { - "/functionalMenuItemsForUser" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/functionalMenuItemsForUser" }, produces = "application/json") public List getFunctionalMenuItemsForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { String loginId = ""; @@ -247,7 +249,7 @@ public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseContro } @EPAuditLog - @RequestMapping(value = { "/validateCookie" }, method = RequestMethod.POST) + @PostMapping(value = { "/validateCookie" }) public boolean validateCookie(@RequestBody EPServiceCookie epServiceCookie, HttpServletRequest request) throws Exception { Map epServiceCookieValueMap = epServiceCookie.getValue(); if(epServiceCookieValueMap!=null) { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/FunctionalMenuController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/FunctionalMenuController.java index 5e13127c..3442d5a6 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/FunctionalMenuController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/FunctionalMenuController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -81,8 +83,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -116,7 +120,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return List of FunctionalMenuItem objects */ - @RequestMapping(value = { "/portalApi/functionalMenu" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/functionalMenu" }, produces = "application/json") public List getMenuItems(HttpServletRequest request, HttpServletResponse response) { // TODO: should only the superuser be allowed to use this API? List menuItems = null; @@ -139,7 +143,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return PortalRestResponse of ONAP portal title */ - @RequestMapping(value = { "/portalApi/ecompTitle" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/ecompTitle" }, produces = "application/json") public PortalRestResponse getECOMPTitle(HttpServletRequest request, HttpServletResponse response) { PortalRestResponse portalRestResponse = null; try { @@ -164,8 +168,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return List of FunctionalMenuItem objects */ - @RequestMapping(value = { - "/portalApi/functionalMenuForEditing" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/functionalMenuForEditing" }, produces = "application/json") public List getMenuItemsForEditing(HttpServletRequest request, HttpServletResponse response) { // TODO: should only the superuser be allowed to use this API? EPUser user = EPUserUtils.getUserSession(request); @@ -194,8 +198,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return List of FunctionalMenuItem objects */ - @RequestMapping(value = { - "/portalApi/functionalMenuForNotificationTree" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/functionalMenuForNotificationTree" }, produces = "application/json") public List getMenuItemsForNotifications(HttpServletRequest request, HttpServletResponse response) { // TODO: should only the superuser be allowed to use this API? @@ -221,8 +225,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * application ID * @return List of FunctionalMenuItem objects */ - @RequestMapping(value = { - "/portalApi/functionalMenuForApp/{appId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/functionalMenuForApp/{appId}" }, produces = "application/json") public List getMenuItemsForApp(HttpServletRequest request, @PathVariable("appId") Integer appId) { // TODO: should only the superuser be allowed to use this API? @@ -248,8 +252,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * user ID * @return List of FunctionalMenuItem objects */ - @RequestMapping(value = { - "/portalApi/functionalMenuForUser/{orgUserId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/functionalMenuForUser/{orgUserId}" }, produces = "application/json") public List getMenuItemsForUser(HttpServletRequest request, @PathVariable("orgUserId") String orgUserId) { // TODO: should only the superuser be allowed to use this API? @@ -276,8 +280,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return List of FunctionalMenuItem objects */ - @RequestMapping(value = { - "/portalApi/functionalMenuForAuthUser" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/functionalMenuForAuthUser" }, produces = "application/json") public List getMenuItemsForAuthUser(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -313,8 +317,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * menu ID * @return FunctionalMenuItem object */ - @RequestMapping(value = { - "/portalApi/functionalMenuItemDetails/{menuId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/functionalMenuItemDetails/{menuId}" }, produces = "application/json") public FunctionalMenuItem getFunctionalMenuItemDetails(HttpServletRequest request, @PathVariable("menuId") Long menuId, HttpServletResponse response) { // TODO: return FunctionalMenuItemJson @@ -349,7 +353,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * FunctionalMenuItemWithRoles * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/functionalMenuItem" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/functionalMenuItem" }) public FieldsValidator createFunctionalMenuItem(HttpServletRequest request, @RequestBody FunctionalMenuItemWithRoles menuItemJson, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -389,7 +393,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * FunctionalMenuItemWithRoles * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/functionalMenuItem" }, method = RequestMethod.PUT) + @PutMapping(value = { "/portalApi/functionalMenuItem" }) public FieldsValidator editFunctionalMenuItem(HttpServletRequest request, @RequestBody FunctionalMenuItemWithRoles menuItemJson, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -425,7 +429,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * menu identifier * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/functionalMenuItem/{menuId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/functionalMenuItem/{menuId}" }) public FieldsValidator deleteFunctionalMenuItem(HttpServletRequest request, @PathVariable("menuId") Long menuId, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -451,7 +455,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/regenerateFunctionalMenuAncestors" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/regenerateFunctionalMenuAncestors" }) public FieldsValidator regenerateAncestorTable(HttpServletRequest request, HttpServletResponse response) { // TODO: should only the superuser be allowed to use this API? EPUser user = EPUserUtils.getUserSession(request); @@ -480,7 +484,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * FunctionalMenuItemWithRoles * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/setFavoriteItem" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/setFavoriteItem" }) public FieldsValidator addFavoriteItem(HttpServletRequest request, @RequestBody FavoritesFunctionalMenuItem menuItemJson, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -504,8 +508,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return List of FavoritesFunctionalMenuItemJson */ - @RequestMapping(value = { - "/portalApi/getFavoriteItems" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/getFavoriteItems" }, produces = "application/json") public List getFavoritesForUser(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -529,7 +533,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * menu identifier * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/removeFavoriteItem/{menuId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/removeFavoriteItem/{menuId}" }) public FieldsValidator deleteFavoriteItem(HttpServletRequest request, @PathVariable("menuId") Long menuId, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -556,23 +560,33 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * HttpServletResponse * @return JSON collection of key-value pairs shown below. */ - @RequestMapping(value = { - "/portalApi/functionalMenuStaticInfo" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/functionalMenuStaticInfo" }, produces = "application/json") public String getFunctionalMenuStaticInfo(HttpServletRequest request, HttpServletResponse response) { // Get user details from session logger.debug(EELFLoggerDelegate.debugLogger, "getFunctionalMenuStaticInfo: getting user info"); String fnMenuStaticResponse = null; try { - String orgUserIdStr = null, firstNameStr = null, lastNameStr = null, emailStr = null, lastLogin = null; + String orgUserIdStr = null; + String firstNameStr = null; + String lastNameStr = null; + String emailStr = null; + String lastLogin = null; + boolean isSystemUser = false; EPUser user = EPUserUtils.getUserSession(request); firstNameStr = user.getFirstName(); lastNameStr = user.getLastName(); orgUserIdStr = user.getOrgUserId(); + isSystemUser = user.isSystemUser(); emailStr = user.getEmail(); if (emailStr == null || emailStr.equals("")) { - EPUser userResult = searchService.searchUserByUserId(orgUserIdStr); - emailStr = userResult.getEmail(); + try { + EPUser userResult = searchService.searchUserByUserId(orgUserIdStr); + emailStr = userResult.getEmail(); + }catch(Exception ex) { + logger.error(EELFLoggerDelegate.errorLogger, "searchUserByUserId call failed", ex); + } } SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss Z a"); Date lastLoginDate = user.getLastLoginDate(); @@ -586,7 +600,10 @@ public class FunctionalMenuController extends EPRestrictedBaseController { // If any item is missing from session, try the Shared Context // service. - SharedContext orgUserIdSC = null, firstNameSC = null, lastNameSC = null, emailSC = null; + SharedContext orgUserIdSC = null; + SharedContext firstNameSC = null; + SharedContext lastNameSC = null; + SharedContext emailSC = null; String sessionId = request.getSession().getId(); if (firstNameStr == null) firstNameSC = sharedContextService.getSharedContext(sessionId, @@ -609,6 +626,7 @@ public class FunctionalMenuController extends EPRestrictedBaseController { map.put("userId", orgUserIdStr != null ? orgUserIdStr : (orgUserIdSC != null ? orgUserIdSC.getCvalue() : null)); map.put("last_login", lastLogin); + map.put("isSystemUser", String.valueOf(isSystemUser)); JSONObject j = new JSONObject(map); fnMenuStaticResponse = j.toString(); // Be chatty in the log @@ -641,8 +659,8 @@ public class FunctionalMenuController extends EPRestrictedBaseController { * @throws IOException * on error */ - @RequestMapping(value = { - "/portalApi/userApplicationRoles" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/userApplicationRoles" }, produces = "application/json") public List getAppList(HttpServletRequest request, HttpServletResponse response, @RequestParam("userId") String userId) throws IOException { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/GetAccessController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/GetAccessController.java index d8bf7ddf..6124544e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/GetAccessController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/GetAccessController.java @@ -46,8 +46,7 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.onap.portalapp.controller.EPUnRestrictedBaseController; import org.onap.portalapp.portal.domain.EPUser; @@ -78,7 +77,7 @@ public class GetAccessController extends EPUnRestrictedBaseController { } }; - @RequestMapping(value = { "/portalApi/getAppList" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/getAppList" }, produces = "application/json") public List getAppList(HttpServletRequest request) throws IOException { List appsList = null; EPUser user = EPUserUtils.getUserSession(request); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java index ca66809f..0acfabfe 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -45,8 +47,7 @@ import javax.servlet.http.HttpServletResponse; import org.slf4j.MDC; import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.onap.music.main.MusicUtil; import org.onap.portalapp.controller.EPUnRestrictedBaseController; @@ -118,7 +119,7 @@ public class HealthCheckController extends EPUnRestrictedBaseController { private final String statusDown = "DOWN"; private final String statusOk = "OK"; - @RequestMapping(value = { "/portalApi/healthCheck" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/healthCheck" }, produces = "application/json") public HealthStatus healthCheck(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, ""); @@ -229,8 +230,8 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { - "/portalApi/healthCheckSuspend" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/healthCheckSuspend" }, produces = "application/json") public HealthStatus healthCheckSuspend(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, "Suspended for manual failover mechanism"); @@ -243,8 +244,8 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { - "/portalApi/healthCheckResume" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/healthCheckResume" }, produces = "application/json") public HealthStatus healthCheckResume(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, "Resumed from manual failover mechanism"); @@ -255,7 +256,7 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { "/portalApi/ping" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/ping" }, produces = "application/json") public HealthStatus ping(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(200, "OK"); EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/ping", "GET result =", response.getStatus()); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java index 508b1be2..0046bc59 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java @@ -1,6 +1,8 @@ /** * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved. * + * Modification Copyright © 2020 IBM. + * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,7 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import com.alibaba.fastjson.JSONObject; @@ -33,19 +36,19 @@ public class LanguageController { @Autowired private LanguageService languageService; - @RequestMapping(value = "/language",method = RequestMethod.GET, produces = "application/json;charset=UTF-8") + @GetMapping(value = "/language", produces = "application/json;charset=UTF-8") public JSONObject getLanguageList() { return languageService.getLanguages(); } - @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.POST) + @PostMapping(value = "/languageSetting/user/{loginId}") public void setUpUserLanguage(@RequestBody JSONObject jsonLanguageId, @PathVariable("loginId") String loginId) throws Exception { Integer languageId = jsonLanguageId.getInteger("languageId"); languageService.setUpUserLanguage(languageId,loginId); } - @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.GET) + @GetMapping(value = "/languageSetting/user/{loginId}") public JSONObject getUserLanguage(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) { return languageService.getUserLanguage(loginId); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ManifestController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ManifestController.java index 471ebe55..5e3212ec 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ManifestController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ManifestController.java @@ -47,7 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.onap.portalapp.portal.logging.aop.EPAuditLog; @@ -91,7 +91,7 @@ public class ManifestController extends RestrictedBaseController { * { "error": "message" } * */ - @RequestMapping(value = { "/portalApi/manifest" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/manifest" }, produces = "application/json") @ResponseBody public Map getManifest(HttpServletRequest request) { Map response = new HashMap(); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java index 2e1a2b46..a80a3b42 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -39,15 +41,10 @@ package org.onap.portalapp.portal.controller; import java.util.List; -import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.validation.ConstraintViolation; import javax.validation.Valid; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; import org.onap.portalapp.controller.EPRestrictedBaseController; import org.onap.portalapp.portal.domain.MicroserviceData; import org.onap.portalapp.portal.domain.WidgetCatalog; @@ -68,8 +65,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @@ -90,7 +89,7 @@ public class MicroserviceController extends EPRestrictedBaseController { @Autowired private MicroserviceService microserviceService; - @RequestMapping(value = { "/portalApi/microservices" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/microservices" }) public PortalRestResponse createMicroservice(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody MicroserviceData newServiceData) throws Exception { if (newServiceData == null) { @@ -113,13 +112,13 @@ public class MicroserviceController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", ""); } - @RequestMapping(value = { "/portalApi/microservices" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices" }) public List getMicroservice(HttpServletRequest request, HttpServletResponse response) throws Exception { return microserviceService.getMicroserviceData(); } - @RequestMapping(value = { "/portalApi/microservices/{serviceId}" }, method = RequestMethod.PUT) + @PutMapping(value = { "/portalApi/microservices/{serviceId}" }) public PortalRestResponse updateMicroservice(HttpServletRequest request, HttpServletResponse response, @PathVariable("serviceId") long serviceId, @Valid @RequestBody MicroserviceData newServiceData) { @@ -140,7 +139,7 @@ public class MicroserviceController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", ""); } - @RequestMapping(value = { "/portalApi/microservices/{serviceId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/microservices/{serviceId}" }) public PortalRestResponse deleteMicroservice(HttpServletRequest request, HttpServletResponse response, @PathVariable("serviceId") long serviceId) { try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java index fed3b98e..8bf93549 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -51,8 +53,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.HttpClientErrorException; @@ -69,8 +70,7 @@ public class MicroserviceProxyController extends EPUnRestrictedBaseController { @Autowired private MicroserviceProxyService microserviceProxyService; - @RequestMapping(value = { "/portalApi/microservice/proxy/{serviceId}" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/microservice/proxy/{serviceId}" }, produces = "application/json") public String getMicroserviceProxy(HttpServletRequest request, HttpServletResponse response, @PathVariable("serviceId") long serviceId) throws Exception { EPUser user = EPUserUtils.getUserSession(request); @@ -83,8 +83,7 @@ public class MicroserviceProxyController extends EPUnRestrictedBaseController { return isValidJSON(answer) ? answer : "{\"error\":\"" + answer.replace(System.getProperty("line.separator"), "") + "\"}"; } - @RequestMapping(value = { "/portalApi/microservice/proxy/parameter/{widgetId}" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/microservice/proxy/parameter/{widgetId}" }, produces = "application/json") public String getMicroserviceProxyByWidgetId(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId) throws Exception { EPUser user = EPUserUtils.getUserSession(request); @@ -104,9 +103,16 @@ public class MicroserviceProxyController extends EPUnRestrictedBaseController { */ private boolean isValidJSON(String response) { try { + if(response != null && !response.isEmpty()) + { final ObjectMapper mapper = new ObjectMapper(); mapper.readTree(response); return true; + } + else + { + return false; + } } catch (IOException e) { logger.debug(EELFLoggerDelegate.debugLogger, "isValidJSON failed", e); return false; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java index 32b28c7d..0cc3e3fa 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -68,8 +70,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -92,7 +95,7 @@ public class PortalAdminController extends EPRestrictedBaseController { this.auditService = auditService; } - @RequestMapping(value = { "/portalApi/portalAdmins" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/portalAdmins" }, produces = "application/json") public List getPortalAdmins(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List portalAdmins = null; @@ -120,7 +123,7 @@ public class PortalAdminController extends EPRestrictedBaseController { * @param response * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/portalAdmin" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/portalAdmin" }) public FieldsValidator createPortalAdmin(HttpServletRequest request, @RequestBody String userId, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -167,7 +170,7 @@ public class PortalAdminController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { "/portalApi/portalAdmin/{userInfo}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/portalAdmin/{userInfo}" }) public FieldsValidator deletePortalAdmin(HttpServletRequest request, @PathVariable("userInfo") String userInfo, HttpServletResponse response) { @@ -225,8 +228,8 @@ public class PortalAdminController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { - "/portalApi/adminAppsRoles/{appId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/adminAppsRoles/{appId}" }, produces = "application/json") public List getRolesByApp(HttpServletRequest request, @PathVariable("appId") Long appId, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java index e2dd6588..4b983d8d 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java @@ -4,17 +4,19 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== - * Modifications Copyright (c) 2019 Samsung + * Modifications Copyright (c) 2019 Samsung * =================================================================== + * Modifications Copyright (c) 2020 IBM + * =================================================================== * * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software + * 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 @@ -95,8 +97,8 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -154,7 +156,7 @@ public class RoleManageController extends EPRestrictedBaseController { * @throws Exception */ - @RequestMapping(value = { "/portalApi/get_roles/{appId}" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/get_roles/{appId}" }) public void getRoles(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId) throws Exception { try { @@ -162,7 +164,7 @@ public class RoleManageController extends EPRestrictedBaseController { EPApp requestedApp = appService.getApp(appId); if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); - if (requestedApp.getCentralAuth()) { + if (requestedApp.getRolesInAAF()) { List answer = null; Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); @@ -183,7 +185,7 @@ public class RoleManageController extends EPRestrictedBaseController { } } - @RequestMapping(value = { "/portalApi/role_list/toggleRole/{appId}/{roleId}" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role_list/toggleRole/{appId}/{roleId}" }) public Map toggleRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId, @PathVariable("roleId") Long roleId) throws Exception { EPApp requestedApp = null; @@ -227,7 +229,7 @@ public class RoleManageController extends EPRestrictedBaseController { return responseMap; } - @RequestMapping(value = { "/portalApi/role_list/removeRole/{appId}/{roleId}" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role_list/removeRole/{appId}/{roleId}" }) public Map removeRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId, @PathVariable("roleId") Long roleId) throws Exception { @@ -240,7 +242,7 @@ public class RoleManageController extends EPRestrictedBaseController { requestedApp = appService.getApp(appId); if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); - if (requestedApp.getCentralAuth()) { + if (requestedApp.getRolesInAAF()) { externalRequestFieldsValidator = externalAccessRolesService.deleteDependencyRoleRecord(roleId, requestedApp.getUebKey(), user.getOrgUserId()); boolean deleteResponse = externalRequestFieldsValidator.isResult(); @@ -293,7 +295,7 @@ public class RoleManageController extends EPRestrictedBaseController { return responseMap; } - @RequestMapping(value = { "/portalApi/role/saveRole/{appId}" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role/saveRole/{appId}" }) public Map saveRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId) throws Exception { EPUser user = EPUserUtils.getUserSession(request); @@ -303,7 +305,7 @@ public class RoleManageController extends EPRestrictedBaseController { EPApp requestedApp = appService.getApp(appId); if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); - if (requestedApp != null && requestedApp.getCentralAuth().equals(true)) { + if (requestedApp != null && requestedApp.getRolesInAAF().equals(true)) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); @@ -415,29 +417,29 @@ public class RoleManageController extends EPRestrictedBaseController { return responseMap; } - @RequestMapping(value = { "/portalApi/role/removeRoleFunction" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role/removeRoleFunction" }) public ModelAndView removeRoleRoleFunction(HttpServletRequest request, HttpServletResponse response) throws Exception { return getRoleController().removeRoleFunction(request, response); } - @RequestMapping(value = { "/portalApi/role/addRoleFunction" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role/addRoleFunction" }) public ModelAndView addRoleRoRoleFunction(HttpServletRequest request, HttpServletResponse response) throws Exception { return getRoleController().addRoleFunction(request, response); } - @RequestMapping(value = { "/portalApi/role/removeChildRole" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role/removeChildRole" }) public ModelAndView removeChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception { return getRoleController().removeChildRole(request, response); } - @RequestMapping(value = { "/portalApi/role/addChildRole" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role/addChildRole" }) public ModelAndView addChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception { return getRoleController().addChildRole(request, response); } - @RequestMapping(value = { "/portalApi/get_role/{appId}/{roleId}" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/get_role/{appId}/{roleId}" }) public void getRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId, @PathVariable("roleId") Long roleId) throws Exception { try { @@ -446,7 +448,7 @@ public class RoleManageController extends EPRestrictedBaseController { EPApp requestedApp = appService.getApp(appId); if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); - if (requestedApp.getCentralAuth()) { + if (requestedApp.getRolesInAAF()) { CentralV2Role answer = externalAccessRolesService.getRoleInfo(roleId, requestedApp.getUebKey()); logger.info(EELFLoggerDelegate.applicationLogger, "role_id" + roleId); Map model = new HashMap<>(); @@ -471,7 +473,7 @@ public class RoleManageController extends EPRestrictedBaseController { } } - @RequestMapping(value = { "/portalApi/get_role_functions/{appId}" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/get_role_functions/{appId}" }) public void getRoleFunctionList(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId) throws Exception { try { @@ -479,7 +481,7 @@ public class RoleManageController extends EPRestrictedBaseController { EPApp requestedApp = appService.getApp(appId); if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); - if (requestedApp.getCentralAuth()) { + if (requestedApp.getRolesInAAF()) { List answer = null; Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); @@ -502,7 +504,7 @@ public class RoleManageController extends EPRestrictedBaseController { } } - @RequestMapping(value = { "/portalApi/role_function_list/saveRoleFunction/{appId}" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role_function_list/saveRoleFunction/{appId}" }) public PortalRestResponse saveRoleFunction(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody CentralV2RoleFunction roleFunc, @PathVariable("appId") Long appId) throws Exception { if (roleFunc!=null) { @@ -521,7 +523,7 @@ public class RoleManageController extends EPRestrictedBaseController { EPApp requestedApp = appService.getApp(appId); if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); - if (requestedApp.getCentralAuth() && roleFunc!=null) { + if (requestedApp.getRolesInAAF() && roleFunc!=null) { String code = roleFunc.getType() + PIPE + roleFunc.getCode() + PIPE + roleFunc.getAction(); CentralV2RoleFunction domainRoleFunction = externalAccessRolesService.getRoleFunction(code, requestedApp.getUebKey()); @@ -599,7 +601,7 @@ public class RoleManageController extends EPRestrictedBaseController { } } - @RequestMapping(value = { "/portalApi/role_function_list/removeRoleFunction/{appId}" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/role_function_list/removeRoleFunction/{appId}" }) public PortalRestResponse removeRoleFunction(HttpServletRequest request, HttpServletResponse response, @RequestBody String roleFunc, @PathVariable("appId") Long appId) throws Exception { EPUser user = EPUserUtils.getUserSession(request); @@ -620,7 +622,7 @@ public class RoleManageController extends EPRestrictedBaseController { EPApp requestedApp = appService.getApp(appId); if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); - if (requestedApp.getCentralAuth()) { + if (requestedApp.getRolesInAAF()) { ObjectMapper mapper = new ObjectMapper(); String data = roleFunc; boolean getDelFuncResponse = false; @@ -676,7 +678,7 @@ public class RoleManageController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "Deleted Successfully!", "Success"); } - @RequestMapping(value = { "/portalApi/centralizedApps" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/centralizedApps" }) public List getCentralizedAppRoles(HttpServletRequest request, HttpServletResponse response, String userId) { if(userId!=null) { SecureString secureString = new SecureString(userId); @@ -719,7 +721,7 @@ public class RoleManageController extends EPRestrictedBaseController { this.roleController = roleController; } - @RequestMapping(value = { "/portalApi/syncRoles" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/portalApi/syncRoles" }, produces = "application/json") public PortalRestResponse syncRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody Long appId) { EPUser user = EPUserUtils.getUserSession(request); @@ -741,7 +743,7 @@ public class RoleManageController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "Sync roles completed successfully!", "Success"); } - @RequestMapping(value = { "/portalApi/syncFunctions" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/portalApi/syncFunctions" }, produces = "application/json") public PortalRestResponse syncFunctions(HttpServletRequest request, HttpServletResponse response, @RequestBody Long appId) { EPUser user = EPUserUtils.getUserSession(request); @@ -807,7 +809,7 @@ public class RoleManageController extends EPRestrictedBaseController { throw new InvalidApplicationException("Invalid credentials"); } if (!appInfo.isEmpty() && EcompPortalUtils.checkIfRemoteCentralAccessAllowed() - && appInfo.get(0).getCentralAuth()) { + && appInfo.get(0).getRolesInAAF()) { ResponseEntity response = externalAccessRolesService.getNameSpaceIfExists(appInfo.get(0)); if (response.getStatusCode().value() == HttpServletResponse.SC_NOT_FOUND) throw new InvalidApplicationException("Invalid NameSpace"); @@ -826,8 +828,8 @@ public class RoleManageController extends EPRestrictedBaseController { response.getWriter().write("Unauthorized User"); } - @RequestMapping(value = { - "/portalApi/uploadRoleFunction/{appId}" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { + "/portalApi/uploadRoleFunction/{appId}" }, produces = "application/json") public PortalRestResponse bulkUploadRoleFunc(HttpServletRequest request, HttpServletResponse response, @RequestBody UploadRoleFunctionExtSystem data, @PathVariable("appId") Long appId) { EPUser user = EPUserUtils.getUserSession(request); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java index 5562caac..5b953b6e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java @@ -56,7 +56,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.ApiOperation; @@ -81,7 +83,7 @@ public class RolesApprovalSystemController implements BasicAuthenticationControl * @return PortalRestResponse with appropriate status value and message */ @ApiOperation(value = "Creates an application user with the specified roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/userProfile" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/userProfile" }, produces = "application/json") public PortalRestResponse postUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { ExternalRequestFieldsValidator reqResult = null; @@ -129,7 +131,7 @@ public class RolesApprovalSystemController implements BasicAuthenticationControl * @return PortalRestResponse with appropriate status value and message */ @ApiOperation(value = "Updates an application user to have only the specified roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/userProfile" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { "/userProfile" }, produces = "application/json") public PortalRestResponse putUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { ExternalRequestFieldsValidator reqResult = null; @@ -176,7 +178,7 @@ public class RolesApprovalSystemController implements BasicAuthenticationControl * @return PortalRestResponse with appropriate status value and message */ @ApiOperation(value = "Processes a request to delete one or more application roles for one specified user who has roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/userProfile" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/userProfile" }, produces = "application/json") public PortalRestResponse deleteUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { ExternalRequestFieldsValidator reqResult = null; @@ -219,9 +221,9 @@ public class RolesApprovalSystemController implements BasicAuthenticationControl * If any field is missing. */ private void validateExtSystemUser(ExternalSystemUser extSysUser, boolean rolesRequired) throws Exception { - if (extSysUser.getLoginId() == null || extSysUser.getLoginId() == "") + if (extSysUser.getLoginId() == null || extSysUser.getLoginId().equals("")) throw new Exception("Request has no login ID"); - if (extSysUser.getApplicationName() == null || extSysUser.getApplicationName() == "") + if (extSysUser.getApplicationName() == null || extSysUser.getApplicationName().equals("")) throw new Exception("Request has no application name"); if (extSysUser.getMyloginrequestId() == null) throw new Exception("Request has no request ID"); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java index c99953fa..20fddf91 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java @@ -37,9 +37,6 @@ */ package org.onap.portalapp.portal.controller; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; import java.util.UUID; import javax.servlet.http.HttpServletRequest; @@ -61,6 +58,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -78,7 +76,7 @@ public class SchedulerAuxController extends EPRestrictedBaseController { /** The logger. */ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerAuxController.class); - @RequestMapping(value = "/get_policy", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/get_policy", produces = "application/json") public ResponseEntity getPolicyInfo(HttpServletRequest request) throws Exception { try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java index 69f25683..53275763 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java @@ -77,6 +77,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -102,7 +104,7 @@ public class SchedulerController extends EPRestrictedBaseController { this.adminRolesService = adminRolesService; } - @RequestMapping(value = "/get_time_slots/{scheduler_request}", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/get_time_slots/{scheduler_request}", produces = "application/json") public ResponseEntity getTimeSlots(HttpServletRequest request, @PathVariable("scheduler_request") String schedulerRequest) throws Exception { if (checkIfUserISValidToMakeSchedule(request)) { @@ -169,7 +171,7 @@ public class SchedulerController extends EPRestrictedBaseController { } @SuppressWarnings("unchecked") - @RequestMapping(value = "/post_create_new_vnf_change", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/post_create_new_vnf_change", produces = "application/json") public ResponseEntity postCreateNewVNFChange(HttpServletRequest request, @RequestBody JSONObject schedulerRequest) throws Exception { if (checkIfUserISValidToMakeSchedule(request)) { @@ -249,7 +251,7 @@ public class SchedulerController extends EPRestrictedBaseController { } } - @RequestMapping(value = "/submit_vnf_change_timeslots", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/submit_vnf_change_timeslots", produces = "application/json") public ResponseEntity postSubmitVnfChangeTimeslots(HttpServletRequest request, @RequestBody JSONObject schedulerRequest) throws Exception { if (checkIfUserISValidToMakeSchedule(request)) { @@ -335,7 +337,7 @@ public class SchedulerController extends EPRestrictedBaseController { * @return Rest response wrapped around a String; e.g., "success" or "ERROR" * @throws Exception */ - @RequestMapping(value = "/get_scheduler_constant", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/get_scheduler_constant", produces = "application/json") public PortalRestResponse> getSchedulerConstant(HttpServletRequest request, HttpServletResponse response) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "get scheduler constant"); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java index 9e3428e6..232b691f 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java @@ -63,6 +63,8 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -114,7 +116,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Gets a value for the specified context and key.", response = SharedContext.class) - @RequestMapping(value = { "/get" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/get" }, produces = "application/json") public String getContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "getContext for ID " + context_id + ", key " + ckey); @@ -151,7 +153,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Gets user information for the specified context.", response = SharedContext.class, responseContainer = "List") - @RequestMapping(value = { "/get_user" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/get_user" }, produces = "application/json") public String getUserContext(HttpServletRequest request, @RequestParam String context_id) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "getUserContext for ID " + context_id); @@ -197,7 +199,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Tests for presence of the specified key in the specified context.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/check" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/check" }, produces = "application/json") public String checkContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) throws Exception { @@ -236,7 +238,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Removes the specified key in the specified context.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/remove" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/remove" }, produces = "application/json") public String removeContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) throws Exception { @@ -275,7 +277,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Clears all key-value pairs in the specified context.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/clear" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/clear" }, produces = "application/json") public String clearContext(HttpServletRequest request, @RequestParam String context_id) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "clearContext for " + context_id); @@ -311,7 +313,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Sets a context value for the specified context and key. Creates the context if no context with the specified ID-key pair exists, overwrites the value if it exists already.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/set" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/set" }, produces = "application/json") public String setContext(HttpServletRequest request, @RequestBody String userJson) throws Exception { if (userJson !=null){ SecureString secureUserJson = new SecureString(userJson); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java index 56a4df3d..26559ae9 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java @@ -67,6 +67,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -105,7 +106,7 @@ public class TicketEventController implements BasicAuthenticationController { @ApiOperation( value = "Accepts messages from external ticketing systems and creates notifications for Portal users.", response = PortalRestResponse.class) - @RequestMapping(value = { "/ticketevent" }, method = RequestMethod.POST) + @PostMapping(value = { "/ticketevent" }) public PortalRestResponse handleRequest(HttpServletRequest request, HttpServletResponse response, @RequestBody String ticketEventJson) throws Exception { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java index fc76a0e6..eec14f71 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java @@ -55,6 +55,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -79,7 +81,7 @@ public class UserController extends EPRestrictedBaseController { * * @return PortalRestResponse of EPUser */ - @RequestMapping(value = { "/portalApi/loggedinUser" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/loggedinUser" }, produces = "application/json") public PortalRestResponse getLoggedinUser(HttpServletRequest request) { PortalRestResponse portalRestResponse = null; try { @@ -106,8 +108,8 @@ public class UserController extends EPRestrictedBaseController { * Body with user information * @return PortalRestResponse of String */ - @RequestMapping(value = { - "/portalApi/modifyLoggedinUser" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/modifyLoggedinUser" }, produces = "application/json") public PortalRestResponse modifyLoggedinUser(HttpServletRequest request, @RequestBody ProfileDetail profileDetail) { PortalRestResponse portalRestResponse = null; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java index 0dfccc9c..8b874621 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java @@ -4,13 +4,15 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright (c) 2020 IBM + * =================================================================== * * 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, @@ -49,8 +51,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.onap.portalapp.controller.EPRestrictedBaseController; @@ -87,8 +89,8 @@ public class UserNotificationController extends EPRestrictedBaseController { private static final String SUCCESS = "success"; private static final String FAILURE = "FAILURE"; - @RequestMapping(value = { - "/portalApi/getFunctionalMenuRole" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/getFunctionalMenuRole" }, produces = "application/json") public List getMenuIdRoleId(HttpServletRequest request, HttpServletResponse response) { // EPUser user = EPUserUtils.getUserSession(request); List menuRoleList = null; @@ -96,8 +98,8 @@ public class UserNotificationController extends EPRestrictedBaseController { return menuRoleList; } - @RequestMapping(value = { - "/portalApi/getNotifications" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/getNotifications" }, produces = "application/json") public PortalRestResponse> getNotifications(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -114,8 +116,8 @@ public class UserNotificationController extends EPRestrictedBaseController { return portalRestResponse; } - @RequestMapping(value = { - "/portalApi/getAdminNotifications" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/getAdminNotifications" }, produces = "application/json") public List getAdminNotifications(HttpServletRequest request, HttpServletResponse response) { List adminNotificationList = null; EPUser user = EPUserUtils.getUserSession(request); @@ -123,7 +125,7 @@ public class UserNotificationController extends EPRestrictedBaseController { return adminNotificationList; } - @RequestMapping(value = "/portalApi/saveNotification", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/portalApi/saveNotification", produces = "application/json") public PortalRestResponse save(HttpServletRequest request, HttpServletResponse response, @RequestBody EpNotificationItem notificationItem) { @@ -160,8 +162,8 @@ public class UserNotificationController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", ""); } - @RequestMapping(value = { - "/portalApi/notificationUpdateRate" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/notificationUpdateRate" }, produces = "application/json") public PortalRestResponse> getNotificationUpdateRate(HttpServletRequest request) { try { String updateRate = SystemProperties.getProperty(EPCommonSystemProperties.NOTIFICATION_UPDATE_RATE); @@ -178,8 +180,8 @@ public class UserNotificationController extends EPRestrictedBaseController { } } - @RequestMapping(value = { - "/portalApi/notificationRead" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/notificationRead" }, produces = "application/json") public PortalRestResponse> notificationRead( @RequestParam("notificationId") String notificationID, HttpServletRequest request) { try { @@ -191,8 +193,8 @@ public class UserNotificationController extends EPRestrictedBaseController { } } - @RequestMapping(value = { - "/portalApi/getNotificationHistory" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/getNotificationHistory" }, produces = "application/json") public List getNotificationHistory(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List notificationList = null; @@ -200,8 +202,7 @@ public class UserNotificationController extends EPRestrictedBaseController { return notificationList; } - @RequestMapping(value = { "/portalApi/notificationRole/{notificationId}/roles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/notificationRole/{notificationId}/roles" }, produces = "application/json") public List testGetRoles(HttpServletRequest request, @PathVariable("notificationId") Long notificationId) { List notifRoles = userNotificationService.getNotificationRoles(notificationId); ArrayList rolesList = new ArrayList<>(); @@ -211,8 +212,7 @@ public class UserNotificationController extends EPRestrictedBaseController { return rolesList; } - @RequestMapping(value = { "/portalApi/getNotificationAppRoles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/getNotificationAppRoles" }, produces = "application/json") public List getNotificationAppRoles(HttpServletRequest request, HttpServletResponse response) { List epAppRoleList = null; try { @@ -225,8 +225,8 @@ public class UserNotificationController extends EPRestrictedBaseController { return epAppRoleList; } - @RequestMapping(value = { - "/portalApi/getMessageRecipients" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/getMessageRecipients" }, produces = "application/json") public List getMessageRecipients(@RequestParam("notificationId") Long notificationID) { // EPUser user = EPUserUtils.getUserSession(request); List messageUserRecipients = null; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java index aa180b0e..906563cf 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java @@ -46,7 +46,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.cxf.transport.http.HTTPException; import org.onap.portalapp.controller.EPRestrictedBaseController; -import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPRole; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.EPUserAppCatalogRoles; @@ -59,7 +58,6 @@ import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice; import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalapp.portal.service.AdminRolesService; import org.onap.portalapp.portal.service.ApplicationsRestClientService; -import org.onap.portalapp.portal.service.EPAppService; import org.onap.portalapp.portal.service.SearchService; import org.onap.portalapp.portal.service.UserRolesService; import org.onap.portalapp.portal.transport.AppNameIdIsAdmin; @@ -84,8 +82,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -119,7 +117,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param response HttpServletResponse * @return array of found users as json */ - @RequestMapping(value = { "/portalApi/queryUsers" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/queryUsers" }, produces = "application/json") public String getPhoneBookSearchResult(HttpServletRequest request, @RequestParam("search") String searchString, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -149,8 +147,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param response HttpServletResponse * @return for GET: array of all applications with boolean isAdmin=true/false for each application */ - @RequestMapping(value = { "/portalApi/adminAppsRoles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/adminAppsRoles" }, produces = "application/json") public AppsListWithAdminRole getAppsWithAdminRoleStateForUser(HttpServletRequest request, @RequestParam("user") String orgUserId, HttpServletResponse response) { @@ -200,8 +197,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param response HttpServletResponse * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/adminAppsRoles" }, method = { - RequestMethod.PUT }, produces = "application/json") + @PutMapping(value = { "/portalApi/adminAppsRoles" }, produces = "application/json") public FieldsValidator putAppsWithAdminRoleStateForUser(HttpServletRequest request, @RequestBody AppsListWithAdminRole newAppsListWithAdminRoles, HttpServletResponse response) { @@ -277,8 +273,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param extRequestValue set to false if request is from users page otherwise true * @return List */ - @RequestMapping(value = { "/portalApi/userAppRoles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/userAppRoles" }, produces = "application/json") public List getAppRolesForUser(HttpServletRequest request, @RequestParam("user") String orgUserId, @RequestParam("app") Long appid, @RequestParam("externalRequest") Boolean extRequestValue, @RequestParam("isSystemUser") Boolean isSystemUser, @@ -356,8 +351,7 @@ public class UserRolesController extends EPRestrictedBaseController { return result; } - @RequestMapping(value = { "/portalApi/userAppRoles" }, method = { - RequestMethod.PUT }, produces = "application/json") + @PutMapping(value = { "/portalApi/userAppRoles" }, produces = "application/json") public PortalRestResponse putAppWithUserRoleStateForUser(HttpServletRequest request, @RequestBody AppWithRolesForUser newAppRolesForUser, HttpServletResponse response) { // FieldsValidator fieldsValidator = new FieldsValidator(); @@ -437,8 +431,7 @@ public class UserRolesController extends EPRestrictedBaseController { return portalResponse; } - @RequestMapping(value = { "/portalApi/updateRemoteUserProfile" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/updateRemoteUserProfile" }, produces = "application/json") public PortalRestResponse updateRemoteUserProfile(HttpServletRequest request, HttpServletResponse response) { @@ -457,8 +450,7 @@ public class UserRolesController extends EPRestrictedBaseController { } - @RequestMapping(value = { "/portalApi/app/{appId}/users" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/app/{appId}/users" }, produces = "application/json") public List getUsersFromAppEndpoint(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { try { @@ -470,8 +462,7 @@ public class UserRolesController extends EPRestrictedBaseController { } } - @RequestMapping(value = { "/portalApi/app/{appId}/roles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/app/{appId}/roles" }, produces = "application/json") public List testGetRoles(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { EcompRole[] appRoles = applicationsRestClientService.get(EcompRole[].class, appId, "/roles"); @@ -482,8 +473,7 @@ public class UserRolesController extends EPRestrictedBaseController { return rolesList; } - @RequestMapping(value = { "/portalApi/admin/import/app/{appId}/roles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/admin/import/app/{appId}/roles" }, produces = "application/json") public List importRolesFromRemoteApplication(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { List rolesList = userRolesService.importRolesFromRemoteApplication(appId); @@ -493,8 +483,7 @@ public class UserRolesController extends EPRestrictedBaseController { return rolesList; } - @RequestMapping(value = { "/portalApi/app/{appId}/user/{orgUserId}/roles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/app/{appId}/user/{orgUserId}/roles" }, produces = "application/json") public EcompRole testGetRoles(HttpServletRequest request, @PathVariable("appId") Long appId, @PathVariable("orgUserId") String orgUserId) throws Exception { if (!EcompPortalUtils.legitimateUserId(orgUserId)) { @@ -515,8 +504,7 @@ public class UserRolesController extends EPRestrictedBaseController { return roles[0]; } - @RequestMapping(value = { "/portalApi/saveUserAppRoles" }, method = { - RequestMethod.PUT }, produces = "application/json") + @PutMapping(value = { "/portalApi/saveUserAppRoles" }, produces = "application/json") public FieldsValidator putAppWithUserRoleRequest(HttpServletRequest request, @RequestBody AppWithRolesForUser newAppRolesForUser, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -536,8 +524,7 @@ public class UserRolesController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { "/portalApi/appCatalogRoles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/appCatalogRoles" }, produces = "application/json") public List getUserAppCatalogRoles(HttpServletRequest request, @RequestParam("appName") String appName) { EPUser user = EPUserUtils.getUserSession(request); @@ -562,7 +549,7 @@ public class UserRolesController extends EPRestrictedBaseController { } }; - @RequestMapping(value = "/portalApi/externalRequestAccessSystem", method = RequestMethod.GET, + @GetMapping(value = "/portalApi/externalRequestAccessSystem", produces = "application/json") public ExternalSystemAccess readExternalRequestAccess(HttpServletRequest request) { ExternalSystemAccess result = null; @@ -576,8 +563,7 @@ public class UserRolesController extends EPRestrictedBaseController { return result; } - @RequestMapping(value = { "/portalApi/checkIfUserIsSuperAdmin" }, method = RequestMethod.GET, - produces = "application/json") + @GetMapping(value = { "/portalApi/checkIfUserIsSuperAdmin" }, produces = "application/json") public boolean checkIfUserIsSuperAdmin(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java index 92449a3a..929ac474 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright (c) 2020 IBM + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -77,7 +79,8 @@ import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.SuccessCallback; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.AsyncRestTemplate; @@ -117,7 +120,7 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl * @return String */ @ApiOperation(value = "Gets javascript with functions that support gathering and reporting web analytics.", response = String.class) - @RequestMapping(value = { "/analytics" }, method = RequestMethod.GET, produces = "application/javascript") + @GetMapping(value = { "/analytics" }, produces = "application/javascript") public String getAnalyticsScript(HttpServletRequest request) { String responseText = ""; EPApp app = null; @@ -162,7 +165,7 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl * Analytics * @return PortalAPIResponse */ - @RequestMapping(value = { "/storeAnalytics" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/storeAnalytics" }, produces = "application/json") @ResponseBody @ApiOperation(value = "Accepts data from partner applications with web analytics data.", response = PortalAPIResponse.class) public PortalAPIResponse storeAnalyticsScript(HttpServletRequest request, @RequestBody Analytics analyticsMap) { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetMSController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetMSController.java index eab811ab..9ba56224 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetMSController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetMSController.java @@ -48,7 +48,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -60,7 +60,7 @@ public class WidgetMSController extends EPRestrictedBaseController { private WidgetMService widgetMService; // Get location of a healthy node running our service - @RequestMapping(value = { "/service/{service}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/service/{service}" }, produces = "application/json") public PortalRestResponse getServiceLocation(HttpServletRequest request, HttpServletResponse response, @PathVariable("service") String service) { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java index 015e6c46..4b68a01e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java @@ -40,7 +40,6 @@ package org.onap.portalapp.portal.controller; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; @@ -81,8 +80,10 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -136,7 +137,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { }); } - @RequestMapping(value = { "/portalApi/microservices/widgetCatalog/{loginName}" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices/widgetCatalog/{loginName}" }) public List getUserWidgetCatalog(@PathVariable("loginName") String loginName) { List widgets = new ArrayList<>(); try { @@ -156,7 +157,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { return widgets; } - @RequestMapping(value = { "/portalApi/microservices/widgetCatalog" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices/widgetCatalog" }) public List getWidgetCatalog() { List widgets = new ArrayList<>(); try { @@ -176,8 +177,8 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { return widgets; } - @RequestMapping(value = { - "/portalApi/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/microservices/widgetCatalog/{widgetId}" }, produces = "application/json") public void updateWidgetCatalog(@RequestBody WidgetCatalog newWidgetCatalog, @PathVariable("widgetId") long widgetId) throws Exception { template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" @@ -187,7 +188,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { HttpMethod.PUT, new HttpEntity<>(newWidgetCatalog, WidgetServiceHeaders.getInstance()), String.class); } - @RequestMapping(value = { "/portalApi/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/microservices/widgetCatalog/{widgetId}" }) public void deleteOnboardingWidget(@PathVariable("widgetId") long widgetId) throws Exception { template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" @@ -197,7 +198,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { HttpMethod.DELETE, new HttpEntity<>(WidgetServiceHeaders.getInstance()), String.class); } - @RequestMapping(value = { "/portalApi/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/microservices/widgetCatalog/{widgetId}" }) public String updateWidgetCatalogWithFiles(HttpServletRequest request, @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { MultipartHttpServletRequest mRequest; @@ -231,7 +232,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { return respond; } - @RequestMapping(value = { "/portalApi/microservices/widgetCatalog" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/microservices/widgetCatalog" }) public String createWidgetCatalog(HttpServletRequest request) throws Exception { @@ -273,7 +274,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { return respond; } - @RequestMapping(value = "/portalApi/microservices/{widgetId}/framework.js", method = RequestMethod.GET) + @GetMapping(value = "/portalApi/microservices/{widgetId}/framework.js") public String getWidgetFramework(@PathVariable("widgetId") long widgetId) throws Exception { return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, @@ -282,7 +283,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { WidgetServiceHeaders.getInstance()); } - @RequestMapping(value = "/portalApi/microservices/{widgetId}/controller.js", method = RequestMethod.GET) + @GetMapping(value = "/portalApi/microservices/{widgetId}/controller.js") public String getWidgetController(@PathVariable("widgetId") long widgetId) throws Exception { return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, @@ -291,7 +292,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { WidgetServiceHeaders.getInstance()); } - @RequestMapping(value = "/portalApi/microservices/{widgetId}/style.css", method = RequestMethod.GET) + @GetMapping(value = "/portalApi/microservices/{widgetId}/style.css") public String getWidgetCSS(@PathVariable("widgetId") long widgetId) throws Exception { return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, @@ -300,7 +301,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { WidgetServiceHeaders.getInstance()); } - @RequestMapping(value = { "/portalApi/microservices/parameters/{widgetId}" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices/parameters/{widgetId}" }) public PortalRestResponse> getWidgetParameterResult(HttpServletRequest request, @PathVariable("widgetId") long widgetId) throws Exception { EPUser user = EPUserUtils.getUserSession(request); @@ -336,17 +337,17 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", list); } - @RequestMapping(value = { "/portalApi/microservices/services/{paramId}" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices/services/{paramId}" }) public List getUserParameterById( @PathVariable("paramId") long paramId) { return widgetParameterService.getUserParameterById(paramId); } - @RequestMapping(value = { "/portalApi/microservices/services/{paramId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/microservices/services/{paramId}" }) public void deleteUserParameterById(@PathVariable("paramId") long paramId) { widgetParameterService.deleteUserParameterById(paramId); } - @RequestMapping(value = { "/portalApi/microservices/download/{widgetId}" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices/download/{widgetId}" }) public void doDownload(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId) throws Exception { @@ -395,7 +396,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { } } - @RequestMapping(value = { "/portalApi/microservices/parameters" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/microservices/parameters" }) public PortalRestResponse saveWidgetParameter(HttpServletRequest request, @RequestBody WidgetCatalogParameter widgetParameters) { EPUser user = EPUserUtils.getUserSession(request); @@ -415,7 +416,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", ""); } - @RequestMapping(value = { "/portalApi/microservices/uploadFlag" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices/uploadFlag" }) public String getUploadFlag() { String uplaodFlag=""; try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java index 0c464fbf..eba0faf4 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java @@ -51,8 +51,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -89,7 +88,7 @@ public class WidgetsCatalogMarkupController extends EPUnRestrictedBaseController }); } - @RequestMapping(value = "/portalApi/microservices/markup/{widgetId}", method = RequestMethod.GET) + @GetMapping(value = "/portalApi/microservices/markup/{widgetId}") public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId) throws RestClientException, Exception { return template diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsController.java index 404784fe..306a0efb 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright © 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modifications Copyright (c) 2020 IBM + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -62,8 +64,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -86,7 +90,7 @@ public class WidgetsController extends EPRestrictedBaseController { this.persUserWidgetService = persUserWidgetService; } - @RequestMapping(value = { "/portalApi/widgets" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/widgets" }, produces = "application/json") public List getOnboardingWidgets(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List onboardingWidgets = null; @@ -118,7 +122,7 @@ public class WidgetsController extends EPRestrictedBaseController { // Attention: real json has all OnboardingWidget fields except "id", we use OnboardingWidget for not // to create new class for parsing - @RequestMapping(value = { "/portalApi/widgets/{widgetId}" }, method = { RequestMethod.PUT }, + @PutMapping(value = { "/portalApi/widgets/{widgetId}" }, produces = "application/json") public FieldsValidator putOnboardingWidget(HttpServletRequest request, @PathVariable("widgetId") Long widgetId, @RequestBody OnboardingWidget onboardingWidget, HttpServletResponse response) { @@ -147,7 +151,7 @@ public class WidgetsController extends EPRestrictedBaseController { // Attention: real json has all OnboardingWidget fields except "id", we use OnboardingWidget for not // to create new class for parsing - @RequestMapping(value = { "/portalApi/widgets" }, method = { RequestMethod.POST }, produces = "application/json") + @PostMapping(value = { "/portalApi/widgets" }, produces = "application/json") public FieldsValidator postOnboardingWidget(HttpServletRequest request, @RequestBody OnboardingWidget onboardingWidget, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -173,7 +177,7 @@ public class WidgetsController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { "/portalApi/widgets/{widgetId}" }, method = { RequestMethod.DELETE }, + @DeleteMapping(value = { "/portalApi/widgets/{widgetId}" }, produces = "application/json") public FieldsValidator deleteOnboardingWidget(HttpServletRequest request, @PathVariable("widgetId") Long widgetId, HttpServletResponse response) { @@ -199,7 +203,7 @@ public class WidgetsController extends EPRestrictedBaseController { * @return FieldsValidator * @throws IOException */ - @RequestMapping(value = { "portalApi/widgetCatalogSelection" }, method = RequestMethod.PUT, + @PutMapping(value = { "portalApi/widgetCatalogSelection" }, produces = "application/json") public FieldsValidator putWidgetCatalogSelection(HttpServletRequest request, @RequestBody WidgetCatalogPersonalization persRequest, HttpServletResponse response) throws IOException { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPApp.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPApp.java index 8227d9ab..61fcfaee 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPApp.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPApp.java @@ -52,45 +52,72 @@ import org.onap.portalsdk.core.domain.support.DomainVo; public class EPApp extends DomainVo { private static final long serialVersionUID = 1L; + @SafeHtml private String name; + @SafeHtml private String imageUrl; + @SafeHtml - private String description; + private String appDescription; + @SafeHtml - private String notes; + private String appNotes; + @SafeHtml - private String url; + private String landingPage; + @SafeHtml - private String alternateUrl; + private String alternateLandingPage; + @SafeHtml private String appRestEndpoint; + @SafeHtml private String mlAppName; + @SafeHtml private String mlAppAdminId; private Long motsId; + @SafeHtml - private String username; + private String appBasicAuthUsername; + @SafeHtml - private String appPassword; + private String appBasicAuthPassword; + @Lob private byte[] thumbnail; + private Boolean open; + private Boolean enabled; + @SafeHtml private String uebTopicName; + @SafeHtml private String uebKey; + @SafeHtml private String uebSecret; + private Integer appType; + @Valid private AppContactUs contactUs; - private Boolean centralAuth; + + private Boolean rolesInAAF; @SafeHtml - private String nameSpace; + private String nameSpace; + + @SafeHtml + private String modeOfIntegration; + + private Boolean appAck; + + private Boolean usesCadi; public EPApp() { // Attention!!! @@ -102,8 +129,8 @@ public class EPApp extends DomainVo { this.name = ""; this.mlAppName = ""; this.mlAppAdminId = ""; - this.username = ""; - this.appPassword = ""; + this.appBasicAuthUsername = ""; + this.appBasicAuthPassword = ""; this.open = new Boolean(false); this.enabled = new Boolean(true); this.uebTopicName = ""; @@ -131,8 +158,6 @@ public class EPApp extends DomainVo { this.imageUrl = imageUrl; } - - public byte[] getThumbnail() { return this.thumbnail; } @@ -141,36 +166,36 @@ public class EPApp extends DomainVo { this.thumbnail = thumbnail; } - public String getDescription() { - return description; + public String getAppDescription() { + return appDescription; } - public void setDescription(String description) { - this.description = description; + public void setAppDescription(String appDescription) { + this.appDescription = appDescription; } - public String getNotes() { - return notes; + public String getAppNotes() { + return appNotes; } - public void setNotes(String notes) { - this.notes = notes; + public void setAppNotes(String appNotes) { + this.appNotes = appNotes; } - public String getUrl() { - return url; + public String getLandingPage() { + return landingPage; } - public void setUrl(String url) { - this.url = url; + public void setLandingPage(String landingPage) { + this.landingPage = landingPage; } - public String getAlternateUrl() { - return alternateUrl; + public String getAlternateLandingPage() { + return alternateLandingPage; } - public void setAlternateUrl(String alternateUrl) { - this.alternateUrl = alternateUrl; + public void setAlternateLandingPage(String alternateLandingPage) { + this.alternateLandingPage = alternateLandingPage; } public String getAppRestEndpoint() { @@ -211,25 +236,25 @@ public class EPApp extends DomainVo { this.motsId = motsId; } - public String getUsername() { - return username; + public String getAppBasicAuthUsername() { + return appBasicAuthUsername; } - public void setUsername(String username) { - this.username = username; + public void setAppBasicAuthUsername(String appBasicAuthUsername) { + this.appBasicAuthUsername = appBasicAuthUsername; } - public String getAppPassword() { - return appPassword; + public String getAppBasicAuthPassword() { + return appBasicAuthPassword; } - public void setAppPassword(String appPassword) { - if (StringUtils.isEmpty(appPassword)) { - appPassword = ""; + public void setAppBasicAuthPassword(String appBasicAuthPassword) { + if (StringUtils.isEmpty(appBasicAuthPassword)) { + appBasicAuthPassword = ""; } - this.appPassword = appPassword; + this.appBasicAuthPassword = appBasicAuthPassword; } - + public Boolean getOpen() { return open; } @@ -252,25 +277,6 @@ public class EPApp extends DomainVo { this.enabled = enabled; } - public Integer getAppType() { - return appType; - } - - public void setAppType(Integer appType) { - if (appType == null) { - appType = new Integer(1); - } - this.appType = appType; - } - - public void setRestrictedApp(Boolean restrictedApp) { - Integer result = 1; - if (restrictedApp) { - result = 2; - } - this.appType = result; - } - public Boolean isRestrictedApp() { return (this.appType == 2 ? true : false); } @@ -308,6 +314,14 @@ public class EPApp extends DomainVo { return this.uebSecret; } + public Integer getAppType() { + return appType; + } + + public void setAppType(Integer appType) { + this.appType = appType; + } + public void setUebSecret(String uebSecret) { if (StringUtils.isEmpty(uebSecret)) { this.uebSecret = ""; @@ -322,18 +336,18 @@ public class EPApp extends DomainVo { public void setContactUs(AppContactUs contactUs) { this.contactUs = contactUs; } - - public Boolean getCentralAuth() { - return centralAuth; + + public Boolean getRolesInAAF() { + return rolesInAAF; } - public void setCentralAuth(Boolean centralAuth) { - if (centralAuth == null) { - centralAuth = new Boolean(false); + public void setRolesInAAF(Boolean rolesInAAF) { + if (rolesInAAF == null) { + rolesInAAF = new Boolean(false); } - this.centralAuth = centralAuth; + this.rolesInAAF = rolesInAAF; } - + public String getNameSpace() { return nameSpace; } @@ -345,38 +359,71 @@ public class EPApp extends DomainVo { this.nameSpace = nameSpace; } + public String getModeOfIntegration() { + return modeOfIntegration; + } + + public void setModeOfIntegration(String modeOfIntegration) { + this.modeOfIntegration = modeOfIntegration; + } + + public Boolean getAppAck() { + return appAck; + } + + public void setAppAck(Boolean appAck) { + this.appAck = appAck; + } + + public Boolean getUsesCadi() { + return usesCadi; + } + + public void setUsesCadi(Boolean usesCadi) { + this.usesCadi = usesCadi; + } + @Override public String toString() { - String str = "[" + getId() + ":" + getName() + "]"; - return str; + return "EPApp [name=" + name + ", imageUrl=" + imageUrl + ", appDescription=" + appDescription + ", appNotes=" + + appNotes + ", landingPage=" + landingPage + ", alternateLandingPage=" + alternateLandingPage + + ", appRestEndpoint=" + appRestEndpoint + ", mlAppName=" + mlAppName + ", mlAppAdminId=" + mlAppAdminId + + ", motsId=" + motsId + ", appBasicAuthUsername=" + appBasicAuthUsername + ", appBasicAuthPassword=" + + appBasicAuthPassword + ", thumbnail=" + Arrays.toString(thumbnail) + ", open=" + open + ", enabled=" + + enabled + ", uebTopicName=" + uebTopicName + ", uebKey=" + uebKey + ", uebSecret=" + uebSecret + + ", appType=" + appType + ", contactUs=" + contactUs + ", rolesInAAF=" + rolesInAAF + ", nameSpace=" + + nameSpace + ", modeOfIntegration=" + modeOfIntegration + ", appAck=" + appAck + ", usesCadi=" + + usesCadi + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((alternateUrl == null) ? 0 : alternateUrl.hashCode()); - result = prime * result + ((appPassword == null) ? 0 : appPassword.hashCode()); + result = prime * result + ((alternateLandingPage == null) ? 0 : alternateLandingPage.hashCode()); + result = prime * result + ((appAck == null) ? 0 : appAck.hashCode()); + result = prime * result + ((appBasicAuthPassword == null) ? 0 : appBasicAuthPassword.hashCode()); + result = prime * result + ((appBasicAuthUsername == null) ? 0 : appBasicAuthUsername.hashCode()); + result = prime * result + ((appDescription == null) ? 0 : appDescription.hashCode()); + result = prime * result + ((appNotes == null) ? 0 : appNotes.hashCode()); result = prime * result + ((appRestEndpoint == null) ? 0 : appRestEndpoint.hashCode()); result = prime * result + ((appType == null) ? 0 : appType.hashCode()); - result = prime * result + ((centralAuth == null) ? 0 : centralAuth.hashCode()); - result = prime * result + ((contactUs == null) ? 0 : contactUs.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((enabled == null) ? 0 : enabled.hashCode()); result = prime * result + ((imageUrl == null) ? 0 : imageUrl.hashCode()); + result = prime * result + ((landingPage == null) ? 0 : landingPage.hashCode()); result = prime * result + ((mlAppAdminId == null) ? 0 : mlAppAdminId.hashCode()); result = prime * result + ((mlAppName == null) ? 0 : mlAppName.hashCode()); + result = prime * result + ((modeOfIntegration == null) ? 0 : modeOfIntegration.hashCode()); result = prime * result + ((motsId == null) ? 0 : motsId.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((nameSpace == null) ? 0 : nameSpace.hashCode()); - result = prime * result + ((notes == null) ? 0 : notes.hashCode()); result = prime * result + ((open == null) ? 0 : open.hashCode()); + result = prime * result + ((rolesInAAF == null) ? 0 : rolesInAAF.hashCode()); result = prime * result + Arrays.hashCode(thumbnail); result = prime * result + ((uebKey == null) ? 0 : uebKey.hashCode()); result = prime * result + ((uebSecret == null) ? 0 : uebSecret.hashCode()); result = prime * result + ((uebTopicName == null) ? 0 : uebTopicName.hashCode()); - result = prime * result + ((url == null) ? 0 : url.hashCode()); - result = prime * result + ((username == null) ? 0 : username.hashCode()); + result = prime * result + ((usesCadi == null) ? 0 : usesCadi.hashCode()); return result; } @@ -384,45 +431,50 @@ public class EPApp extends DomainVo { public boolean equals(Object obj) { if (this == obj) return true; - if (obj == null) + if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof EPApp)) return false; EPApp other = (EPApp) obj; - if (alternateUrl == null) { - if (other.alternateUrl != null) + if (alternateLandingPage == null) { + if (other.alternateLandingPage != null) return false; - } else if (!alternateUrl.equals(other.alternateUrl)) + } else if (!alternateLandingPage.equals(other.alternateLandingPage)) return false; - if (appPassword == null) { - if (other.appPassword != null) + if (appAck == null) { + if (other.appAck != null) return false; - } else if (!appPassword.equals(other.appPassword)) + } else if (!appAck.equals(other.appAck)) return false; - if (appRestEndpoint == null) { - if (other.appRestEndpoint != null) + if (appBasicAuthPassword == null) { + if (other.appBasicAuthPassword != null) return false; - } else if (!appRestEndpoint.equals(other.appRestEndpoint)) + } else if (!appBasicAuthPassword.equals(other.appBasicAuthPassword)) return false; - if (appType == null) { - if (other.appType != null) + if (appBasicAuthUsername == null) { + if (other.appBasicAuthUsername != null) return false; - } else if (!appType.equals(other.appType)) + } else if (!appBasicAuthUsername.equals(other.appBasicAuthUsername)) return false; - if (centralAuth == null) { - if (other.centralAuth != null) + if (appDescription == null) { + if (other.appDescription != null) return false; - } else if (!centralAuth.equals(other.centralAuth)) + } else if (!appDescription.equals(other.appDescription)) return false; - if (contactUs == null) { - if (other.contactUs != null) + if (appNotes == null) { + if (other.appNotes != null) return false; - } else if (!contactUs.equals(other.contactUs)) + } else if (!appNotes.equals(other.appNotes)) return false; - if (description == null) { - if (other.description != null) + if (appRestEndpoint == null) { + if (other.appRestEndpoint != null) return false; - } else if (!description.equals(other.description)) + } else if (!appRestEndpoint.equals(other.appRestEndpoint)) + return false; + if (appType == null) { + if (other.appType != null) + return false; + } else if (!appType.equals(other.appType)) return false; if (enabled == null) { if (other.enabled != null) @@ -434,6 +486,11 @@ public class EPApp extends DomainVo { return false; } else if (!imageUrl.equals(other.imageUrl)) return false; + if (landingPage == null) { + if (other.landingPage != null) + return false; + } else if (!landingPage.equals(other.landingPage)) + return false; if (mlAppAdminId == null) { if (other.mlAppAdminId != null) return false; @@ -444,6 +501,11 @@ public class EPApp extends DomainVo { return false; } else if (!mlAppName.equals(other.mlAppName)) return false; + if (modeOfIntegration == null) { + if (other.modeOfIntegration != null) + return false; + } else if (!modeOfIntegration.equals(other.modeOfIntegration)) + return false; if (motsId == null) { if (other.motsId != null) return false; @@ -459,16 +521,16 @@ public class EPApp extends DomainVo { return false; } else if (!nameSpace.equals(other.nameSpace)) return false; - if (notes == null) { - if (other.notes != null) - return false; - } else if (!notes.equals(other.notes)) - return false; if (open == null) { if (other.open != null) return false; } else if (!open.equals(other.open)) return false; + if (rolesInAAF == null) { + if (other.rolesInAAF != null) + return false; + } else if (!rolesInAAF.equals(other.rolesInAAF)) + return false; if (!Arrays.equals(thumbnail, other.thumbnail)) return false; if (uebKey == null) { @@ -486,16 +548,13 @@ public class EPApp extends DomainVo { return false; } else if (!uebTopicName.equals(other.uebTopicName)) return false; - if (url == null) { - if (other.url != null) - return false; - } else if (!url.equals(other.url)) - return false; - if (username == null) { - if (other.username != null) + if (usesCadi == null) { + if (other.usesCadi != null) return false; - } else if (!username.equals(other.username)) + } else if (!usesCadi.equals(other.usesCadi)) return false; return true; } + + } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EpAppType.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EpAppType.java new file mode 100644 index 00000000..ae6d12cd --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EpAppType.java @@ -0,0 +1,48 @@ +/*- + * ============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.domain; + +public interface EpAppType { + public static final int GUI = 1; + public static final int HYPERLINK = 2; + public static final int NONGUI = 3; + + public static final String GUI_STR = "gui"; + public static final String HYPERLINK_STR = "hyperlink"; + public static final String NONGUI_STR = "nongui"; +} diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java index 9900827f..583b43ad 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java @@ -44,7 +44,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Transient; -import javax.validation.constraints.DecimalMax; import javax.validation.constraints.Digits; import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/MicroserviceData.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/MicroserviceData.java index b8f79d06..6db834eb 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/MicroserviceData.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/MicroserviceData.java @@ -39,11 +39,6 @@ package org.onap.portalapp.portal.domain; import java.util.List; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - import javax.validation.Valid; import org.hibernate.validator.constraints.SafeHtml; import org.onap.portalsdk.core.domain.support.DomainVo; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/SharedContext.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/SharedContext.java index 421a2fbc..14837dbf 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/SharedContext.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/SharedContext.java @@ -43,7 +43,6 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.validation.constraints.Digits; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java index 3209f35a..e96485d8 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java @@ -39,19 +39,12 @@ */ package org.onap.portalapp.portal.interceptor; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import java.util.HashMap; import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.mockito.internal.stubbing.answers.ThrowsException; import org.onap.aaf.cadi.CadiWrap; import org.onap.portalapp.controller.sessionmgt.SessionCommunicationController; import org.onap.portalapp.portal.controller.BasicAuthenticationController; @@ -60,7 +53,6 @@ import org.onap.portalapp.portal.controller.SharedContextRestController; import org.onap.portalapp.portal.controller.WebAnalyticsExtAppController; import org.onap.portalapp.portal.domain.BasicAuthCredentials; import org.onap.portalapp.portal.domain.EPApp; -import org.onap.portalapp.portal.domain.EPEndpoint; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice; import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum; @@ -68,7 +60,6 @@ import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalapp.portal.service.AdminRolesService; import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.service.BasicAuthenticationCredentialService; -import org.onap.portalapp.portal.service.ExternalAccessRolesService; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalapp.service.RemoteWebServiceCallService; @@ -81,6 +72,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.onap.portalsdk.core.onboarding.util.AuthUtil; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.onap.portalsdk.core.util.SystemProperties; @@ -262,7 +255,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor { throw new Exception("Invalid credentials!"); } else { - final String appUsername = application.getUsername(); + final String appUsername = application.getAppBasicAuthUsername(); logger.debug(EELFLoggerDelegate.debugLogger, "appUsername : {}",appUsername); String[] accountNamePassword = EcompPortalUtils.getUserNamePassword(authHeader); @@ -326,8 +319,8 @@ public class PortalResourceInterceptor extends ResourceInterceptor { throw new Exception("Invalid credentials!"); } else { - final String appUsername = application.getUsername(); - final String dbDecryptedPwd = CipherUtil.decryptPKC(application.getAppPassword()); + final String appUsername = application.getAppBasicAuthUsername(); + final String dbDecryptedPwd = CipherUtil.decryptPKC(application.getAppBasicAuthPassword()); if (appUsername.equals(accountNamePassword[0]) && dbDecryptedPwd.equals(accountNamePassword[1])) { return true; } @@ -379,7 +372,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor { String result = ""; if (encrypted != null && encrypted.length() > 0) { try { - result = CipherUtil.decryptPKC(encrypted, SystemProperties.getProperty(SystemProperties.Decryption_Key)); + result = CipherUtil.decryptPKC(encrypted, KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; @@ -393,7 +386,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor { if (decryptedPwd != null && decryptedPwd.length() > 0) { try { result = CipherUtil.encryptPKC(decryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java index 93310a97..6a581c19 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java @@ -41,7 +41,6 @@ import java.util.Collections; import java.util.Date; import javax.security.auth.login.CredentialException; -import javax.ws.rs.client.Entity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java index 4d81c6d0..869a9de5 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java @@ -40,7 +40,6 @@ package org.onap.portalapp.portal.scheduleraux; import org.glassfish.jersey.client.ClientResponse; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; public class SchedulerAuxUtil { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java index 6950bdda..969ccc5f 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java @@ -349,7 +349,7 @@ public class AdminRolesServiceImpl implements AdminRolesService { for (AppNameIdIsAdmin appNameIdIsAdmin : newAppsWhereUserIsAdmin) { EPApp app = (EPApp) localSession.get(EPApp.class, appNameIdIsAdmin.id); try { - if (app.getCentralAuth()) { + if (app.getRolesInAAF()) { String extRole = app.getNameSpace() + "." + PortalConstants.ADMIN_ROLE.replaceAll(" ", "_"); HttpEntity entity = new HttpEntity<>(headers); String name = ""; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java index 09d78046..ab504fba 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java @@ -67,6 +67,8 @@ import org.onap.portalapp.util.SystemType; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; @@ -176,8 +178,8 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient if (externalApp != null) { String appBaseUri = (type == SystemType.APPLICATION) ? externalApp.getAppRestEndpoint() : ""; - String username = (type == SystemType.APPLICATION) ? externalApp.getUsername(): ""; - String encriptedPwd = (type == SystemType.APPLICATION) ? externalApp.getAppPassword(): ""; + String username = (type == SystemType.APPLICATION) ? externalApp.getAppBasicAuthUsername(): ""; + String encriptedPwd = (type == SystemType.APPLICATION) ? externalApp.getAppBasicAuthPassword(): ""; String appName = (type == SystemType.APPLICATION) ? externalApp.getName(): ""; String decreptedAppPwd = StringUtils.EMPTY; @@ -194,7 +196,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient if(!encriptedPwd.isEmpty() || encriptedPwd != null || StringUtils.isEmpty(encriptedPwd)){ try { decreptedAppPwd = CipherUtil.decryptPKC(encriptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "createClientFor failed to decrypt", e); } @@ -202,20 +204,20 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient WebClient client = createClientForPath(appBaseUri, restPath); - if(externalApp.getAppPassword().isEmpty() || externalApp.getAppPassword()==null){ + if(externalApp.getAppBasicAuthPassword().isEmpty() || externalApp.getAppBasicAuthPassword()==null){ logger.debug(EELFLoggerDelegate.debugLogger, "Entering in the externalApp get app password contains null : {}"); externalApp = appsCacheService.getApp(1L); logger.debug(EELFLoggerDelegate.debugLogger, "external App Information : {}",externalApp); - String mechidUsername=externalApp.getUsername(); + String mechidUsername=externalApp.getAppBasicAuthUsername(); logger.debug(EELFLoggerDelegate.debugLogger, "external App mechidUsername Information : {}",mechidUsername); - String password=externalApp.getAppPassword(); + String password=externalApp.getAppBasicAuthPassword(); String decreptedexternalAppPwd = StringUtils.EMPTY; try { decreptedexternalAppPwd = CipherUtil.decryptPKC(password, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e); } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java index 3a70da84..94498f6e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java @@ -54,7 +54,6 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.service.AppsCacheServiceImple; import org.onap.portalapp.portal.transport.OnboardingApp; -import org.onap.portalapp.portal.utils.EPCommonSystemProperties; @Service("appsCacheService") @org.springframework.context.annotation.Configuration diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java index 98b0f127..151430d3 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java @@ -52,6 +52,8 @@ import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.validation.DataValidator; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; @@ -229,7 +231,7 @@ public class BasicAuthAccountServiceImpl implements BasicAuthAccountService{ if (encryptedPwd != null && encryptedPwd.length() > 0) { try { result = CipherUtil.decryptPKC(encryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword() failed", e); throw e; @@ -243,7 +245,7 @@ public class BasicAuthAccountServiceImpl implements BasicAuthAccountService{ if (decryptedPwd != null && decryptedPwd.length() > 0) { try { result = CipherUtil.encryptPKC(decryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java index da09c172..618e9ba9 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthenticationCredentialServiceImpl.java @@ -50,7 +50,6 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.onap.portalsdk.core.service.DataAccessService; -import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java index 126d6276..54510d2c 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java @@ -94,6 +94,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.ueb.Helper; import org.onap.portalsdk.core.onboarding.ueb.TopicManager; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.onap.portalsdk.core.service.DataAccessService; @@ -147,17 +149,17 @@ public class EPAppCommonServiceImpl implements EPAppService { public Boolean onboardingAppFieldsValidation(OnboardingApp onboardingApp) { //FieldsValidator fieldsValidator = new FieldsValidator(); - if ((!onboardingApp.restrictedApp) &&( onboardingApp.name == null || onboardingApp.name.length() == 0 || onboardingApp.restrictedApp == null - || onboardingApp.url == null || onboardingApp.url.length() == 0 || onboardingApp.restUrl == null || onboardingApp.restUrl.length() == 0 - || onboardingApp.username == null || onboardingApp.username.length() == 0 - || onboardingApp.isOpen == null - || (onboardingApp.id != null && onboardingApp.id.equals(ECOMP_APP_ID))) + if ((!onboardingApp.getRestrictedApp()) &&( onboardingApp.getAppName() == null || onboardingApp.getAppName().length() == 0 || onboardingApp.getRestrictedApp() == null + || onboardingApp.getLandingPage() == null || onboardingApp.getLandingPage().length() == 0 || onboardingApp.getRestUrl() == null || onboardingApp.getRestUrl().length() == 0 + || onboardingApp.getAppBasicAuthUsername() == null || onboardingApp.getAppBasicAuthUsername().length() == 0 + || onboardingApp.getIsOpen() == null + || (onboardingApp.getId() != null && onboardingApp.getId().equals(ECOMP_APP_ID))) // For a normal app (appType == PortalConstants.PortalAppId), // these fields must be filled // in. // For a restricted app (appType==2), they will be empty. - || ((onboardingApp.restrictedApp) && (onboardingApp.name == null || onboardingApp.name.length() == 0 - || onboardingApp.url == null || onboardingApp.url.length() == 0 || onboardingApp.isOpen == null))) { + || ((onboardingApp.getRestrictedApp()) && (onboardingApp.getAppName() == null || onboardingApp.getAppName().length() == 0 + || onboardingApp.getLandingPage() == null || onboardingApp.getLandingPage().length() == 0 || onboardingApp.getIsOpen() == null))) { return false; } return true; @@ -165,8 +167,8 @@ public class EPAppCommonServiceImpl implements EPAppService { } private Boolean onboardingInactiveAppFieldsForValidation(OnboardingApp onboardingApp) { - if (onboardingApp.name == null || onboardingApp.name.length() == 0 - || onboardingApp.isOpen == null) { + if (onboardingApp.getAppName() == null || onboardingApp.getAppName().length() == 0 + || onboardingApp.getIsOpen() == null) { return false; } return true; @@ -174,28 +176,28 @@ public class EPAppCommonServiceImpl implements EPAppService { protected FieldsValidator onboardingAppFieldsChecker(OnboardingApp onboardingApp) { FieldsValidator fieldsValidator = new FieldsValidator(); - if (onboardingApp.isCentralAuth) { - if (!onboardingApp.isEnabled) { + if (onboardingApp.getRolesInAAF()) { + if (!onboardingApp.getIsEnabled()) { if (!onboardingInactiveAppFieldsForValidation(onboardingApp)) { fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); } - } else if (onboardingApp.isEnabled) { - if (onboardingAppFieldsValidation(onboardingApp) == false || onboardingApp.nameSpace == null - || onboardingApp.nameSpace.length() == 0) { + } else if (onboardingApp.getIsEnabled()) { + if (onboardingAppFieldsValidation(onboardingApp) == false || onboardingApp.getNameSpace() == null + || onboardingApp.getNameSpace().length() == 0) { fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); } } } else { - if (!onboardingApp.isEnabled) { + if (!onboardingApp.getIsEnabled()) { if (!onboardingInactiveAppFieldsForValidation(onboardingApp)) { fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); } - } else if (onboardingApp.isEnabled) { - if(onboardingApp.restrictedApp && onboardingAppFieldsValidation(onboardingApp) == false){ + } else if (onboardingApp.getIsEnabled()) { + if(onboardingApp.getRestrictedApp() && onboardingAppFieldsValidation(onboardingApp) == false){ fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); } - else if (!onboardingApp.restrictedApp && (onboardingAppFieldsValidation(onboardingApp) == false || onboardingApp.appPassword == null - || onboardingApp.appPassword.length() == 0)) { + else if (!onboardingApp.getRestrictedApp() && (onboardingAppFieldsValidation(onboardingApp) == false || onboardingApp.getAppBasicAuthPassword() == null + || onboardingApp.getAppBasicAuthPassword().length() == 0)) { fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); } } @@ -268,15 +270,15 @@ public class EPAppCommonServiceImpl implements EPAppService { ecompApp.setId(app.getId()); ecompApp.setName(app.getName()); ecompApp.setImageUrl(app.getImageUrl()); - ecompApp.setDescription(app.getDescription()); - ecompApp.setNotes(app.getNotes()); - ecompApp.setUrl(app.getUrl()); - ecompApp.setAlternateUrl(app.getAlternateUrl()); + ecompApp.setDescription(app.getAppDescription()); + ecompApp.setNotes(app.getAppNotes()); + ecompApp.setUrl(app.getLandingPage()); + ecompApp.setAlternateUrl(app.getAlternateLandingPage()); ecompApp.setUebTopicName(app.getUebTopicName()); //ecompApp.setUebKey(app.getUebKey()); ecompApp.setUebSecret(app.getUebSecret()); ecompApp.setEnabled(app.getEnabled()); - ecompApp.setCentralAuth(app.getCentralAuth()); + ecompApp.setCentralAuth(app.getRolesInAAF()); ecompApp.setNameSpace(app.getNameSpace()); ecompApp.setRestrictedApp(app.isRestrictedApp()); ecompAppList.add(ecompApp); @@ -381,7 +383,7 @@ public class EPAppCommonServiceImpl implements EPAppService { if (apps.size() > 0) { EPApp app = apps.get(0); if (!EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { - app.setCentralAuth(false); + app.setRolesInAAF(false); } return app; } else{ @@ -582,14 +584,14 @@ public class EPAppCommonServiceImpl implements EPAppService { FieldsValidator fieldsValidator = new FieldsValidator(); if(onboardingApp.isCentralAuth){ if (onboardingApp.name == null || onboardingApp.name.length() == 0 || onboardingApp.url == null - || onboardingApp.url.length() == 0 || onboardingApp.restrictedApp == null - || onboardingApp.isOpen == null || onboardingApp.isEnabled == null - || (onboardingApp.id != null && ECOMP_APP_ID.equals(onboardingApp.id.toString())) + || onboardingApp.url.length() == 0 || onboardingApp.getRestrictedApp() == null + || onboardingApp.getIsOpen() == null || onboardingApp.getIsEnabled() == null + || (onboardingApp.getId() != null && ECOMP_APP_ID.equals(onboardingApp.getId().toString())) // For a normal app (appType == PortalConstants.PortalAppId), // these fields must be filled // in. // For a restricted app (appType==2), they will be empty. - || ((!onboardingApp.restrictedApp) && (onboardingApp.myLoginsAppName == null + || ((!onboardingApp.getRestrictedApp()) && (onboardingApp.myLoginsAppName == null || onboardingApp.myLoginsAppName.length() == 0 || onboardingApp.myLoginsAppOwner == null || onboardingApp.myLoginsAppOwner.length() == 0 || onboardingApp.username == null || onboardingApp.username.length() == 0 ))) { @@ -598,14 +600,14 @@ public class EPAppCommonServiceImpl implements EPAppService { }else{ if (onboardingApp.name == null || onboardingApp.name.length() == 0 || onboardingApp.url == null - || onboardingApp.url.length() == 0 || onboardingApp.restrictedApp == null - || onboardingApp.isOpen == null || onboardingApp.isEnabled == null - || (onboardingApp.id != null && ECOMP_APP_ID.equals(onboardingApp.id.toString())) + || onboardingApp.url.length() == 0 || onboardingApp.getRestrictedApp() == null + || onboardingApp.getIsOpen() == null || onboardingApp.getIsEnabled() == null + || (onboardingApp.getId() != null && ECOMP_APP_ID.equals(onboardingApp.getId().toString())) // For a normal app (appType == PortalConstants.PortalAppId), // these fields must be filled // in. // For a restricted app (appType==2), they will be empty. - || ((!onboardingApp.restrictedApp) && (onboardingApp.myLoginsAppName == null + || ((!onboardingApp.getRestrictedApp()) && (onboardingApp.myLoginsAppName == null || onboardingApp.myLoginsAppName.length() == 0 || onboardingApp.myLoginsAppOwner == null || onboardingApp.myLoginsAppOwner.length() == 0 || onboardingApp.username == null || onboardingApp.username.length() == 0 || onboardingApp.appPassword == null @@ -815,7 +817,7 @@ public class EPAppCommonServiceImpl implements EPAppService { } return finalsortedAppsByManual; } - + @Override public List getOnboardingApps() { @SuppressWarnings("unchecked") @@ -823,7 +825,7 @@ public class EPAppCommonServiceImpl implements EPAppService { List onboardingAppsList = new ArrayList(); for (EPApp app : apps) { OnboardingApp onboardingApp = new OnboardingApp(); - app.setAppPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD);//to hide password from get request + app.setAppBasicAuthPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD);//to hide password from get request createOnboardingFromApp(app, onboardingApp); onboardingAppsList.add(onboardingApp); } @@ -846,7 +848,7 @@ public class EPAppCommonServiceImpl implements EPAppService { onboardingAppsList = getOnboardingApps(); final List userAdminApps1 = userAdminApps; - List userApplicationAdmins = onboardingAppsList.stream().filter(x -> userAdminApps1.contains((int) (long)x.id)).collect(Collectors.toList()); + List userApplicationAdmins = onboardingAppsList.stream().filter(x -> userAdminApps1.contains((int) (long)x.getId())).collect(Collectors.toList()); return userApplicationAdmins; } @@ -855,7 +857,8 @@ public class EPAppCommonServiceImpl implements EPAppService { public List getEnabledNonOpenOnboardingApps() { @SuppressWarnings("unchecked") List apps = dataAccessService.getList(EPApp.class, - " where enabled = true and open = false and id!=" + ECOMP_APP_ID, null, null); + " where enabled = true and open = false and app_type!= 3 and id!=" + ECOMP_APP_ID, null, null); + List onboardingAppsList = new ArrayList(); for (EPApp app : apps) { OnboardingApp onboardingApp = new OnboardingApp(); @@ -870,13 +873,13 @@ public class EPAppCommonServiceImpl implements EPAppService { boolean duplicatedNameSpace = false; boolean duplicatedName = false; List apps; - if (onboardingApp.id == null) { + if (onboardingApp.getId() == null) { List restrictionsList = new ArrayList(); - Criterion nameCrit = Restrictions.eq("name",onboardingApp.name); + Criterion nameCrit = Restrictions.eq("name",onboardingApp.getAppName()); Criterion nameSpaceCrit = null; Criterion orCrit = null; - if (onboardingApp.isCentralAuth) { - nameSpaceCrit = Restrictions.eq("nameSpace", onboardingApp.nameSpace); + if (onboardingApp.getRolesInAAF()) { + nameSpaceCrit = Restrictions.eq("nameSpace", onboardingApp.getNameSpace()); orCrit = Restrictions.or(nameCrit, nameSpaceCrit); } else orCrit = Restrictions.or(nameCrit); @@ -884,12 +887,12 @@ public class EPAppCommonServiceImpl implements EPAppService { apps = (List) dataAccessService.getList(EPApp.class, null, restrictionsList, null); } else { List restrictionsList = new ArrayList(); - Criterion idCrit =Restrictions.eq("id", onboardingApp.id); - Criterion nameCrit = Restrictions.eq("name",onboardingApp.name); + Criterion idCrit =Restrictions.eq("id", onboardingApp.getId()); + Criterion nameCrit = Restrictions.eq("name",onboardingApp.getAppName()); Criterion nameSpaceCrit = null; Criterion orCrit= null; - if (onboardingApp.isCentralAuth) { - nameSpaceCrit = Restrictions.eq("nameSpace",onboardingApp.nameSpace); + if (onboardingApp.getRolesInAAF()) { + nameSpaceCrit = Restrictions.eq("nameSpace",onboardingApp.getNameSpace()); orCrit = Restrictions.or(idCrit, nameSpaceCrit, nameCrit); } else @@ -900,16 +903,16 @@ public class EPAppCommonServiceImpl implements EPAppService { } for (EPApp app : apps) { - if (onboardingApp.id != null && onboardingApp.id.equals(app.getId())) { + if (onboardingApp.getId() != null && onboardingApp.getId().equals(app.getId())) { continue; } - if (!duplicatedName && app.getName().equalsIgnoreCase(onboardingApp.name)) { + if (!duplicatedName && app.getName().equalsIgnoreCase(onboardingApp.getAppName())) { duplicatedName = true; if (duplicatedName) { break; } } - if (!duplicatedNameSpace && app.getNameSpace().equalsIgnoreCase(onboardingApp.nameSpace)) { + if (!duplicatedNameSpace && app.getNameSpace().equalsIgnoreCase(onboardingApp.getNameSpace())) { duplicatedNameSpace = true; if (duplicatedNameSpace) { break; @@ -937,8 +940,8 @@ public class EPAppCommonServiceImpl implements EPAppService { validateOnboardingApp(modifiedOnboardingApp, fieldsValidator); } if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { - if (modifiedOnboardingApp.id != null) { - updateApp(modifiedOnboardingApp.id, modifiedOnboardingApp, fieldsValidator, user); + if (modifiedOnboardingApp.getId() != null) { + updateApp(modifiedOnboardingApp.getId(), modifiedOnboardingApp, fieldsValidator, user); } else { fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); } @@ -953,7 +956,7 @@ public class EPAppCommonServiceImpl implements EPAppService { validateOnboardingApp(newOnboardingApp, fieldsValidator); } if (fieldsValidator.httpStatusCode.intValue() == HttpServletResponse.SC_OK) { - if (newOnboardingApp.id == null) { + if (newOnboardingApp.getId() == null) { updateApp(null, newOnboardingApp, fieldsValidator, user); } else { fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_BAD_REQUEST); @@ -1211,7 +1214,7 @@ public class EPAppCommonServiceImpl implements EPAppService { logger.debug(EELFLoggerDelegate.debugLogger, "LR: entering updateApp"); // Separate out the code for a restricted app, since it doesn't need any // of the UEB code. - if (onboardingApp.restrictedApp) { + if (Boolean.TRUE.equals(onboardingApp.getRestrictedApp())) { boolean result = false; Session localSession = null; Transaction transaction = null; @@ -1234,7 +1237,7 @@ public class EPAppCommonServiceImpl implements EPAppService { createAppFromOnboarding(app, onboardingApp, localSession); localSession.saveOrUpdate(app); // Enable or disable all menu items associated with this app - setFunctionalMenuItemsEnabled(localSession, onboardingApp.isEnabled, appId); + setFunctionalMenuItemsEnabled(localSession, onboardingApp.getIsEnabled(), appId); transaction.commit(); result = true; } catch (Exception e) { @@ -1300,7 +1303,7 @@ public class EPAppCommonServiceImpl implements EPAppService { logger.debug(EELFLoggerDelegate.debugLogger, "updateRestrictedApp: finished calling localSession.saveOrUpdate"); // Enable or disable all menu items associated with this app - setFunctionalMenuItemsEnabled(localSession, onboardingApp.isEnabled, appId); + setFunctionalMenuItemsEnabled(localSession, onboardingApp.getIsEnabled(), appId); logger.debug(EELFLoggerDelegate.debugLogger, "updateRestrictedApp: finished calling setFunctionalMenuItemsEnabled"); transaction.commit(); @@ -1405,10 +1408,10 @@ public class EPAppCommonServiceImpl implements EPAppService { topicManager.createTopic( PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), - appMailboxName, "ECOMP outbox for app" + onboardingApp.name); + appMailboxName, "ECOMP outbox for app" + onboardingApp.getAppName()); successfullyCreatedMailbox = true; logger.debug(EELFLoggerDelegate.debugLogger, - "Successfully created " + appMailboxName + " for App " + onboardingApp.name); + "Successfully created " + appMailboxName + " for App " + onboardingApp.getAppName()); logger.debug(EELFLoggerDelegate.debugLogger, " Key = " + appKey + " Secret = " + appSecret + " generated using = " + user.getEmail()); break; @@ -1487,7 +1490,7 @@ public class EPAppCommonServiceImpl implements EPAppService { logger.debug(EELFLoggerDelegate.debugLogger, "LR: updateApp: finished calling localSession.saveOrUpdate"); // Enable or disable all menu items associated with this app - setFunctionalMenuItemsEnabled(localSession, onboardingApp.isEnabled, appId); + setFunctionalMenuItemsEnabled(localSession, onboardingApp.getIsEnabled(), appId); logger.debug(EELFLoggerDelegate.debugLogger, "LR: updateApp: finished calling setFunctionalMenuItemsEnabled"); transaction.commit(); @@ -1528,27 +1531,35 @@ public class EPAppCommonServiceImpl implements EPAppService { */ @Override public void createOnboardingFromApp(EPApp app, OnboardingApp onboardingApp) { - onboardingApp.id = app.getId(); - onboardingApp.name = app.getName(); - onboardingApp.imageUrl = app.getImageUrl(); - onboardingApp.description = app.getDescription(); - onboardingApp.notes = app.getNotes(); - onboardingApp.url = app.getUrl(); - onboardingApp.alternateUrl = app.getAlternateUrl(); - onboardingApp.restUrl = app.getAppRestEndpoint(); - onboardingApp.isOpen = app.getOpen(); - onboardingApp.isEnabled = app.getEnabled(); - onboardingApp.username = app.getUsername(); - onboardingApp.appPassword = (app.getAppPassword().equals(EPCommonSystemProperties.APP_DISPLAY_PASSWORD)) ? EPCommonSystemProperties.APP_DISPLAY_PASSWORD :decryptedPassword(app.getAppPassword(), app); - onboardingApp.uebTopicName = app.getUebTopicName(); - onboardingApp.uebKey = app.getUebKey(); - onboardingApp.uebSecret = app.getUebSecret(); - onboardingApp.isCentralAuth = app.getCentralAuth(); - onboardingApp.nameSpace = app.getNameSpace(); + onboardingApp.setId(app.getId()); + onboardingApp.setAppName(app.getName()); + onboardingApp.setImageUrl(app.getImageUrl()); + onboardingApp.setAppDescription(app.getAppDescription()); + onboardingApp.setAppNotes(app.getAppNotes()); + onboardingApp.setLandingPage(app.getLandingPage()); + onboardingApp.setAlternateLandingPage(app.getAlternateLandingPage()); + onboardingApp.setRestUrl(app.getAppRestEndpoint()); + onboardingApp.setIsOpen(app.getOpen()); + onboardingApp.setIsEnabled(app.getEnabled()); + onboardingApp.setAppBasicAuthUsername(app.getAppBasicAuthUsername()); + + String effectivePwd = null; + if (app.getAppBasicAuthPassword().equals(EPCommonSystemProperties.APP_DISPLAY_PASSWORD)) + effectivePwd = EPCommonSystemProperties.APP_DISPLAY_PASSWORD; + else + effectivePwd = decryptedPassword(app.getAppBasicAuthPassword(), app); + + onboardingApp.setAppBasicAuthPassword(effectivePwd); + onboardingApp.setUebTopicName(app.getUebTopicName()); + onboardingApp.setUebKey(app.getUebKey()); + onboardingApp.setUebSecret(app.getUebSecret()); + onboardingApp.setRolesInAAF(app.getRolesInAAF()); + onboardingApp.setNameSpace(app.getNameSpace()); onboardingApp.setRestrictedApp(app.isRestrictedApp()); - // if (app.getThumbnail() != null) - // onboardingApp.thumbnail = new - // String(Base64.getEncoder().encode(app.getThumbnail())); + onboardingApp.setModeOfIntegration(app.getModeOfIntegration()); + onboardingApp.setAppAck(app.getAppAck()); + onboardingApp.setUsesCadi(app.getUsesCadi()); + onboardingApp.setApplicationType(app.getAppType().toString()); } /** @@ -1561,26 +1572,31 @@ public class EPAppCommonServiceImpl implements EPAppService { * @return The first argument. */ protected EPApp createAppFromOnboarding(EPApp app, OnboardingApp onboardingApp, Session localSession) { - app.setName(onboardingApp.name); - app.setDescription(onboardingApp.description); - app.setNotes(onboardingApp.notes); - app.setUrl(onboardingApp.url); - app.setAlternateUrl(onboardingApp.alternateUrl); - app.setAppRestEndpoint(onboardingApp.restUrl); - app.setOpen(onboardingApp.isOpen); - app.setEnabled(onboardingApp.isEnabled); - app.setUsername(onboardingApp.username); - if(!onboardingApp.appPassword.equals(EPCommonSystemProperties.APP_DISPLAY_PASSWORD)) - app.setAppPassword(this.encryptedPassword(onboardingApp.appPassword, app)); + app.setName(onboardingApp.getAppName()); + app.setAppDescription(onboardingApp.getAppDescription()); + app.setAppNotes(onboardingApp.getAppNotes()); + app.setLandingPage(onboardingApp.getLandingPage()); + app.setAlternateLandingPage(onboardingApp.getAlternateLandingPage()); + app.setAppRestEndpoint(onboardingApp.getRestUrl()); + app.setOpen(onboardingApp.getIsOpen()); + app.setEnabled(onboardingApp.getIsEnabled()); + app.setAppBasicAuthUsername(onboardingApp.getAppBasicAuthUsername()); + if(!onboardingApp.getAppBasicAuthPassword().equals(EPCommonSystemProperties.APP_DISPLAY_PASSWORD)) + app.setAppBasicAuthPassword(this.encryptedPassword(onboardingApp.getAppBasicAuthPassword(), app)); //app.setUebTopicName(onboardingApp.uebTopicName); - app.setUebKey(onboardingApp.uebKey); - app.setUebSecret(onboardingApp.uebSecret); - app.setCentralAuth(onboardingApp.isCentralAuth); - app.setNameSpace(onboardingApp.nameSpace); - app.setRestrictedApp(onboardingApp.restrictedApp); - if (!StringUtils.isEmpty(onboardingApp.thumbnail)) { + app.setUebKey(onboardingApp.getUebKey()); + app.setUebSecret(onboardingApp.getUebSecret()); + app.setRolesInAAF(onboardingApp.getRolesInAAF()); + app.setNameSpace(onboardingApp.getNameSpace()); + app.setAppType(new Integer(onboardingApp.getApplicationType())); + app.setModeOfIntegration(onboardingApp.getModeOfIntegration()); + app.setAppAck(onboardingApp.getAppAck()); + app.setUsesCadi(onboardingApp.getUsesCadi()); + + + if (!StringUtils.isEmpty(onboardingApp.getThumbnail())) { logger.debug(EELFLoggerDelegate.debugLogger, "createAppFromOnboarding: onboarding thumbnail is NOT empty"); - String[] splitBase64Thumbnail = onboardingApp.thumbnail.split("base64,"); + String[] splitBase64Thumbnail = onboardingApp.getThumbnail().split("base64,"); logger.debug(EELFLoggerDelegate.debugLogger, "createAppFromOnboarding: length of splitBase64Thumbnail: " + splitBase64Thumbnail.length); if (splitBase64Thumbnail.length > 1) { @@ -1592,7 +1608,7 @@ public class EPAppCommonServiceImpl implements EPAppService { app.setImageUrl(constructImageName(onboardingApp)); app.setThumbnail(decodedImage); } - } else if (app.getThumbnail() != null && onboardingApp.imageLink == null) { + } else if (app.getThumbnail() != null && onboardingApp.getImageLink() == null) { // The thumbnail that came in from the json is empty; the previous // thumbnail is NOT empty. Must delete it. logger.debug(EELFLoggerDelegate.debugLogger, @@ -1607,7 +1623,7 @@ public class EPAppCommonServiceImpl implements EPAppService { } protected String constructImageName(OnboardingApp onboardingApp) { - return "portal_" + String.valueOf(onboardingApp.url.hashCode() + "_" + (int) (Math.random() * 100000.0)) + return "portal_" + String.valueOf(onboardingApp.getLandingPage().hashCode() + "_" + (int) (Math.random() * 100000.0)) + ".png"; } @@ -1617,7 +1633,7 @@ public class EPAppCommonServiceImpl implements EPAppService { if (encryptedAppPwd != null && !encryptedAppPwd.isEmpty()) { try { result = CipherUtil.decryptPKC(encryptedAppPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed for app " + app.getName(), e); } @@ -1630,7 +1646,7 @@ public class EPAppCommonServiceImpl implements EPAppService { if (decryptedAppPwd != null && !decryptedAppPwd.isEmpty()) { try { result = CipherUtil.encryptPKC(decryptedAppPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed for app " + app.getName(), e); } @@ -1929,9 +1945,11 @@ public class EPAppCommonServiceImpl implements EPAppService { logger.debug(EELFLoggerDelegate.debugLogger, "checkIfNameSpaceExists: Connecting to External Auth system for : "+namespace); ResponseEntity response = null; try { - response = template - .exchange(SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL) - + "nss/" + namespace, HttpMethod.GET, entity, String.class); + + String namespaceUrl = SystemProperties. + getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL) + "nss/" + namespace; + + response = template.exchange(namespaceUrl, HttpMethod.GET, entity, String.class); logger.debug(EELFLoggerDelegate.debugLogger, "checkIfNameSpaceExists for"+ namespace , response.getStatusCode().value()); if (response.getStatusCode().value() == 200) { 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 241468c3..ad06dd96 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 @@ -1183,13 +1183,13 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic .setModified(epApp.getModified()).setCreatedId(epApp.getCreatedId()) .setModifiedId(epApp.getModifiedId()).setRowNum(epApp.getRowNum()) .setName(epApp.getName()).setImageUrl(epApp.getImageUrl()) - .setDescription(epApp.getDescription()).setNotes(epApp.getNotes()) - .setUrl(epApp.getUrl()).setAlternateUrl(epApp.getAlternateUrl()) + .setDescription(epApp.getAppDescription()).setNotes(epApp.getAppNotes()) + .setUrl(epApp.getLandingPage()).setAlternateUrl(epApp.getLandingPage()) .setRestEndpoint(epApp.getAppRestEndpoint()).setMlAppName(epApp.getMlAppName()) .setMlAppAdminId(epApp.getMlAppAdminId()).setMotsId(String.valueOf(epApp.getMotsId())) - .setAppPassword(epApp.getAppPassword()).setOpen(String.valueOf(epApp.getOpen())) + .setAppPassword(epApp.getAppBasicAuthPassword()).setOpen(String.valueOf(epApp.getOpen())) .setEnabled(String.valueOf(epApp.getEnabled())).setThumbnail(epApp.getThumbnail()) - .setUsername(epApp.getUsername()).setUebKey(epApp.getUebKey()) + .setUsername(epApp.getAppBasicAuthUsername()).setUebKey(epApp.getUebKey()) .setUebSecret(epApp.getUebSecret()).setUebTopicName(epApp.getUebTopicName()) .createCentralApp(); cenApp.setAppPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD); @@ -3005,7 +3005,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic params.put("uebKey", app.getUebKey()); List userRolesList = null; Integer userRolesAdded = 0; - if (app.getCentralAuth()) { + if (app.getRolesInAAF()) { userRolesList = dataAccessService.executeNamedQuery("getBulkUserRoles", params, null); for (BulkUploadUserRoles userRolesUpload : userRolesList) { if (!userRolesUpload.getOrgUserId().equals("su1234")) { @@ -3602,7 +3602,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic params.put("roleId", String.valueOf(roleId)); List userRolesList = null; Integer userRolesAdded = 0; - if (app.getCentralAuth()) { + if (app.getRolesInAAF()) { userRolesList = dataAccessService.executeNamedQuery("getBulkUsersForSingleRole", params, null); for (BulkUploadUserRoles userRolesUpload : userRolesList) { userRolesUpload.setRoleName(modifiedRoleName); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java index 570d1e92..ee39dd48 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageService.java @@ -16,9 +16,6 @@ package org.onap.portalapp.portal.service; import com.alibaba.fastjson.JSONObject; -import org.onap.portalapp.portal.domain.Language; - -import java.util.List; public interface LanguageService { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyService.java index 3db8e5e3..ee87a629 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyService.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyService.java @@ -3,7 +3,7 @@ * 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"); @@ -40,7 +40,6 @@ package org.onap.portalapp.portal.service; import javax.servlet.http.HttpServletRequest; import org.onap.portalapp.portal.domain.EPUser; -import org.springframework.web.client.RestClientException; public interface MicroserviceProxyService { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java index 31cb8a45..df8b59d8 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java @@ -50,6 +50,8 @@ import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; @@ -177,7 +179,7 @@ public class MicroserviceProxyServiceImpl implements MicroserviceProxyService { if (encryptedPwd != null && encryptedPwd.length() > 0) { try { result = CipherUtil.decryptPKC(encryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java index 451500d6..9d9fde3a 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java @@ -52,6 +52,8 @@ import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; @@ -197,7 +199,7 @@ public class MicroserviceServiceImpl implements MicroserviceService { if (encryptedPwd != null && !encryptedPwd.isEmpty()) { try { result = CipherUtil.decryptPKC(encryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; @@ -211,7 +213,7 @@ public class MicroserviceServiceImpl implements MicroserviceService { if (decryptedPwd != null && !decryptedPwd.isEmpty()) { try { result = CipherUtil.encryptPKC(decryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed", e); throw e; 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 c766106d..07c1ea64 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 @@ -40,8 +40,6 @@ package org.onap.portalapp.portal.service; import java.util.ArrayList; import java.util.List; -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; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java index 4924e654..7a7f9ee4 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java @@ -376,7 +376,7 @@ public class UserRolesCommonServiceImpl { .setParameter("appId",appId) .list(); for (EPRole role : roles) { - if (!extRequestValue && app.getCentralAuth()) { + if (!extRequestValue && app.getRolesInAAF()) { rolesMap.put(role.getId(), role); } else { rolesMap.put(role.getAppRoleId(), role); @@ -1086,12 +1086,11 @@ public class UserRolesCommonServiceImpl { } } } - applyChangesToUserAppRolesForMyLoginsRequest(user, appId); Boolean systemUser = (newAppRolesForUser.getIsSystemUser() != null ? newAppRolesForUser.getIsSystemUser() : false); - if ((app.getCentralAuth() || app.getId().equals(PortalConstants.PORTAL_APP_ID)) && systemUser) { + if ((app.getRolesInAAF() || app.getId().equals(PortalConstants.PORTAL_APP_ID)) && systemUser) { Set userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper, applicationsRestClientService, appId, userId); @@ -1108,13 +1107,16 @@ public class UserRolesCommonServiceImpl { result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal", systemUser,rolesGotDeletedByApprover,false); - }else if (!app.getCentralAuth() && systemUser) + }else if (!app.getRolesInAAF() && systemUser) { throw new Exception("For non-centralized application we cannot add systemUser"); } else{ // if centralized app - if (app.getCentralAuth()) { - if (!app.getId().equals(PortalConstants.PORTAL_APP_ID)) { + if (app.getRolesInAAF()) { + + if (!app.getId().equals(PortalConstants.PORTAL_APP_ID) && (app.getAppAck() != null && app.getAppAck())) { + logger.debug(EELFLoggerDelegate.debugLogger,"setAppWithUserRoleStateForUser: calling pushRemoteUser method for Central application"); + logger.debug(EELFLoggerDelegate.debugLogger,"setAppWithUserRoleStateForUser:"+app.getAppAck()); pushRemoteUser(roleInAppForUserList, userId, app, mapper, searchService, applicationsRestClientService,false); } @@ -1125,7 +1127,6 @@ public class UserRolesCommonServiceImpl { userRolesInLocalApp); List roleAppUserList = rolesInAppForUser.roles; if (EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { - // Apply changes in external Access system updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList, epRequestValue,false,rolesGotDeletedFromApprover,checkIfUserisOnlyRoleAdmin); @@ -1133,7 +1134,7 @@ public class UserRolesCommonServiceImpl { result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal", systemUser,rolesGotDeletedFromApprover,checkIfUserisOnlyRoleAdmin); } // In case if portal is not centralized then follow existing approach - else if(!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){ + else if(!app.getRolesInAAF() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){ Set userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper, applicationsRestClientService, appId, userId); RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(userId, appId, @@ -1142,10 +1143,10 @@ public class UserRolesCommonServiceImpl { result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal",false,rolesGotDeletedByApprover,false); } else{// remote app EPUser remoteAppUser = null; - if(!app.getCentralAuth() && !app.getId().equals(PortalConstants.PORTAL_APP_ID)){ + if(!app.getRolesInAAF() && !app.getId().equals(PortalConstants.PORTAL_APP_ID)){ remoteAppUser = checkIfRemoteUserExits(userId, app, applicationsRestClientService); - + if (remoteAppUser == null) { remoteAppUser = addRemoteUser(roleInAppForUserList, userId, app, mapper, searchService, applicationsRestClientService); } @@ -1620,7 +1621,7 @@ public class UserRolesCommonServiceImpl { } //If Non-Centralized app make sure you sync app roles before assigning to user - if (!app.getId().equals(PortalConstants.PORTAL_APP_ID) && !app.getCentralAuth()) { + if (!app.getId().equals(PortalConstants.PORTAL_APP_ID) && !app.getRolesInAAF()) { logger.debug(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: Starting GET roles for app {}",app.getId()); EcompRole[] appRoles = applicationsRestClientService.get(EcompRole[].class, app.getId(), "/roles"); logger.debug(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: Finshed GET roles for app {} and payload {}",app.getId(), appRoles); @@ -1647,12 +1648,13 @@ public class UserRolesCommonServiceImpl { .anyMatch(roleList -> roleList.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)); } // if Centralized app - if (app.getCentralAuth()) { + if (app.getRolesInAAF()) { // We should add If user does not exist in remote application try { // If adding just account admin role dont make remote application user call or // if request has only single non admin role then make remote call if (!(app.getId().equals(PortalConstants.PORTAL_APP_ID) && reqType.equals("DELETE")) + && (app.getAppAck() != null && app.getAppAck()) && ((checkIfAdminRoleExists && roleInAppForUserList.size() > 1) || (!checkIfAdminRoleExists && roleInAppForUserList.size() >= 1))) { // check if admin role exist then delete @@ -1662,6 +1664,7 @@ public class UserRolesCommonServiceImpl { return (role.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)); }); String orgUserIdNewOrExist = (userInfo.size() != 0 || !userInfo.isEmpty()) ? user.getOrgUserId() : orgUserId; + pushRemoteUser(remoteUserRoles, orgUserIdNewOrExist , app, mapper, searchService, applicationsRestClientService,true); } @@ -1686,7 +1689,7 @@ public class UserRolesCommonServiceImpl { result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, reqType,false,rolesGotDeletedByApprover,false); } // If local application is not centralized - else if(!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){ + else if(!app.getRolesInAAF() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){ Set userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper, applicationsRestClientService, app.getId(), orgUserId); RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(orgUserId, app.getId(), @@ -1896,7 +1899,7 @@ public class UserRolesCommonServiceImpl { // for onap portal app, no need to make a remote call List roleList = new ArrayList<>(); if (appId == PortalConstants.PORTAL_APP_ID) { - if(app.getCentralAuth()){ + if(app.getRolesInAAF()){ List cenRoleList = externalAccessRolesService.getRolesForApp(app.getUebKey()); for(CentralV2Role cenRole : cenRoleList){ Role role = new Role(); @@ -1935,7 +1938,7 @@ public class UserRolesCommonServiceImpl { EcompRole[] appRoles = null; boolean checkIfUserisApplicationAccAdmin = false; List roles = new ArrayList<>(); - if (app.getCentralAuth()) { + if (app.getRolesInAAF()) { final Map appParams = new HashMap<>(); appParams.put("appId", app.getId()); List applicationRoles = dataAccessService.executeNamedQuery("getActiveRolesOfApplication", @@ -2038,14 +2041,14 @@ public class UserRolesCommonServiceImpl { // If there is an exception in the rest client api, then null will // be returned. if (appRoles != null) { - if(!app.getCentralAuth()) { + if(!app.getRolesInAAF()) { syncAppRoles(sessionFactory, appId, appRoles); } EcompRole[] userAppRoles = null; try { try { - if(app.getCentralAuth()){ + if(app.getRolesInAAF()){ final Map params = new HashMap<>(); final Map userParams = new HashMap<>(); params.put("orgUserIdValue", userId); @@ -2315,7 +2318,7 @@ public class UserRolesCommonServiceImpl { EPApp app = appsService.getApp(appId); //If local or centralized application - if (appId == PortalConstants.PORTAL_APP_ID || app.getCentralAuth()) { + if (appId == PortalConstants.PORTAL_APP_ID || app.getRolesInAAF()) { Map params = new HashMap<>(); params.put("id", app.getId()); params.put("active", true); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralRole.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralRole.java index 6f587697..26fd63db 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralRole.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CentralRole.java @@ -42,8 +42,6 @@ import java.util.Date; import java.util.SortedSet; import java.util.TreeSet; -import org.onap.portalsdk.core.domain.RoleFunction; - public class CentralRole implements Serializable { private static final long serialVersionUID = -9210905386086213882L; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/OnboardingApp.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/OnboardingApp.java index 37ad5add..d1b2a568 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/OnboardingApp.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/OnboardingApp.java @@ -38,6 +38,7 @@ package org.onap.portalapp.portal.transport; import org.hibernate.validator.constraints.SafeHtml; +import org.onap.portalapp.portal.domain.EpAppType; /** * Model of rows in the fn_app table; serialized as a message add or update an @@ -45,81 +46,301 @@ import org.hibernate.validator.constraints.SafeHtml; */ public class OnboardingApp { - public Long id; + private Long id; @SafeHtml - public String name; + private String appName; @SafeHtml - public String imageUrl; + private String imageUrl; @SafeHtml - public String imageLink; + private String imageLink; @SafeHtml - public String description; + private String appDescription; @SafeHtml - public String notes; + private String appNotes; @SafeHtml - public String url; + private String landingPage; @SafeHtml - public String alternateUrl; + private String alternateLandingPage; @SafeHtml - public String restUrl; + private String restUrl; - public Boolean isOpen; + @SafeHtml + private String applicationType; + + private Boolean isOpen; - public Boolean isEnabled; + private Boolean isEnabled; - public Long motsId; + private Long motsId; @SafeHtml - public String myLoginsAppName; + private String myLoginsAppName; @SafeHtml - public String myLoginsAppOwner; + private String myLoginsAppOwner; @SafeHtml - public String username; + private String appBasicAuthUsername; @SafeHtml - public String appPassword; + private String appBasicAuthPassword; @SafeHtml - public String thumbnail; + private String thumbnail; @SafeHtml - public String uebTopicName; + private String uebTopicName; @SafeHtml - public String uebKey; + private String uebKey; @SafeHtml - public String uebSecret; + private String uebSecret; - public Boolean restrictedApp; + private Boolean restrictedApp; - public Boolean isCentralAuth; + private Boolean rolesInAAF; + @SafeHtml + private String nameSpace; + @SafeHtml - public String nameSpace; + private String modeOfIntegration; + private Boolean appAck; + + private Boolean usesCadi; + /** * Sets the name, myLoginsAppName, myLoginsAppOwner, username and * appPassword fields to the empty string OR trims leading/trailing space, * as appropriate. */ public void normalize() { - this.name = (this.name == null) ? "" : this.name.trim(); + this.appName = (this.appName == null) ? "" : this.appName.trim(); this.myLoginsAppName = (this.myLoginsAppName == null) ? "" : this.myLoginsAppName.trim(); this.myLoginsAppOwner = (this.myLoginsAppOwner == null) ? "" : this.myLoginsAppOwner.trim(); - this.username = (this.username == null) ? "" : this.username.trim(); - this.appPassword = (this.appPassword == null) ? "" : this.appPassword.trim(); + this.appBasicAuthUsername = (this.appBasicAuthUsername == null) ? "" : this.appBasicAuthUsername.trim(); + this.appBasicAuthPassword = (this.appBasicAuthPassword == null) ? "" : this.appBasicAuthPassword.trim(); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public String getImageLink() { + return imageLink; + } + + public void setImageLink(String imageLink) { + this.imageLink = imageLink; + } + + public String getAppDescription() { + return appDescription; + } + + public void setAppDescription(String appDescription) { + this.appDescription = appDescription; + } + + public String getAppNotes() { + return appNotes; + } + + public void setAppNotes(String appNotes) { + this.appNotes = appNotes; + } + + public String getLandingPage() { + return landingPage; + } + + public void setLandingPage(String landingPage) { + this.landingPage = landingPage; } - public void setUebTopicName(String topicName) { - this.uebTopicName = topicName; + public String getAlternateLandingPage() { + return alternateLandingPage; } - public void setUebKey(String key) { - this.uebKey = key; + public void setAlternateLandingPage(String alternateLandingPage) { + this.alternateLandingPage = alternateLandingPage; } - public void setUebSecret(String secret) { - this.uebSecret = secret; + public String getRestUrl() { + return restUrl; } - // Hide the implementation of restricted and normal app from the front end. - // The json sent and received will include restrictedApp but not appType. + public void setRestUrl(String restUrl) { + this.restUrl = restUrl; + } + + public Boolean getIsOpen() { + return isOpen; + } + + public void setIsOpen(Boolean isOpen) { + this.isOpen = isOpen; + } + + public Boolean getIsEnabled() { + return isEnabled; + } + + public void setIsEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + } + + public Long getMotsId() { + return motsId; + } + + public void setMotsId(Long motsId) { + this.motsId = motsId; + } + + public String getMyLoginsAppName() { + return myLoginsAppName; + } + + public void setMyLoginsAppName(String myLoginsAppName) { + this.myLoginsAppName = myLoginsAppName; + } + + public String getMyLoginsAppOwner() { + return myLoginsAppOwner; + } + + public void setMyLoginsAppOwner(String myLoginsAppOwner) { + this.myLoginsAppOwner = myLoginsAppOwner; + } + + public String getAppBasicAuthUsername() { + return appBasicAuthUsername; + } + + public void setAppBasicAuthUsername(String appBasicAuthUsername) { + this.appBasicAuthUsername = appBasicAuthUsername; + } + + public String getAppBasicAuthPassword() { + return appBasicAuthPassword; + } + + public void setAppBasicAuthPassword(String appBasicAuthPassword) { + this.appBasicAuthPassword = appBasicAuthPassword; + } + + public String getThumbnail() { + return thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + public String getUebTopicName() { + return uebTopicName; + } + + public void setUebTopicName(String uebTopicName) { + this.uebTopicName = uebTopicName; + } + + public String getUebKey() { + return uebKey; + } + + public void setUebKey(String uebKey) { + this.uebKey = uebKey; + } + + public String getUebSecret() { + return uebSecret; + } + + public void setUebSecret(String uebSecret) { + this.uebSecret = uebSecret; + } + + public Boolean getRestrictedApp() { + return restrictedApp; + } public void setRestrictedApp(Boolean restrictedApp) { this.restrictedApp = restrictedApp; } + + public Boolean getRolesInAAF() { + return rolesInAAF; + } + + public void setRolesInAAF(Boolean rolesInAAF) { + this.rolesInAAF = rolesInAAF; + } + + public String getNameSpace() { + return nameSpace; + } + + public void setNameSpace(String nameSpace) { + this.nameSpace = nameSpace; + } + + public String getModeOfIntegration() { + return modeOfIntegration; + } + + public void setModeOfIntegration(String modeOfIntegration) { + this.modeOfIntegration = modeOfIntegration; + } + + public Boolean getAppAck() { + return appAck; + } + + public void setAppAck(Boolean appAck) { + this.appAck = appAck; + } + + public Boolean getUsesCadi() { + return usesCadi; + } + + public void setUsesCadi(Boolean usesCadi) { + this.usesCadi = usesCadi; + } + + public String getApplicationType() { + return applicationType; + } + + public void setApplicationType(String applicationType) { + this.applicationType = applicationType; + } + + public Integer appTypePersistedValue() { + switch (this.getApplicationType()) { + case EpAppType.GUI_STR: + return EpAppType.GUI; + case EpAppType.HYPERLINK_STR: + return EpAppType.HYPERLINK; + case EpAppType.NONGUI_STR: + return EpAppType.NONGUI; + default: + return 0; + } + } } 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 e5543a36..3fc8c393 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 @@ -61,6 +61,8 @@ 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.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; import org.springframework.http.HttpHeaders; @@ -435,7 +437,7 @@ public class EcompPortalUtils { if (encrypted != null && encrypted.length() > 0) { try { result = CipherUtil.decryptPKC(encrypted, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; 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 891f6d78..afe56368 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 @@ -62,7 +62,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; import java.util.Map; -import org.onap.portalapp.portal.utils.EPCommonSystemProperties; public final class MusicCookieCsrfTokenRepository implements CsrfTokenRepository { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java index 805e04a4..f65199c7 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java @@ -57,11 +57,12 @@ import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.transport.OnboardingApp; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; -import org.onap.portalapp.util.SystemType; import org.onap.portalsdk.core.exception.UrlAccessRestrictedException; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; @@ -86,12 +87,12 @@ public class SessionCommunication { String appResponse = ""; String appName = ""; int responseCode = 0; - if (app != null && app.name != null && app.name != "") { + if (app != null && app.getAppName() != null && app.getAppName() != "") { try { - appName = app.name; - String url = app.restUrl + "/sessionTimeOuts"; - String encriptedPwdDB = app.appPassword; - String appUserName = app.username; + appName = app.getAppName(); + String url = app.getRestUrl() + "/sessionTimeOuts"; + String encriptedPwdDB = app.getAppBasicAuthPassword(); + String appUserName = app.getAppBasicAuthUsername(); setLocalMDCContext(app, "/sessionTimeOuts", url); @@ -158,12 +159,12 @@ public class SessionCommunication { try { if (app == null) throw new Exception("SessionCommunication.pingSession: app is null"); - if (app != null && app.name != null && app.name != "") { - appName = app.name; + if (app != null && app.getAppName() != null && app.getAppName() != "") { + appName = app.getAppName(); } - String url = app.restUrl + "/updateSessionTimeOuts"; - String encriptedPwdDB = app.appPassword; - String appUserName = app.username; + String url = app.getRestUrl() + "/updateSessionTimeOuts"; + String encriptedPwdDB = app.getAppBasicAuthPassword(); + String appUserName = app.getAppBasicAuthUsername(); setLocalMDCContext(app, "/updateSessionTimeOuts", url); @@ -219,13 +220,13 @@ public class SessionCommunication { public Boolean timeoutSession(OnboardingApp app, String portalJSessionId) throws Exception { String appName = "Unknwon"; int responseCode = 0; - if (app != null && app.name != null && app.name != "") { + if (app != null && app.getAppName() != null && app.getAppName() != "") { try { - appName = app.name; - String url = app.restUrl + "/timeoutSession" + "?portalJSessionId=" + portalJSessionId; + appName = app.getAppName(); + String url = app.getRestUrl() + "/timeoutSession" + "?portalJSessionId=" + portalJSessionId; - String encriptedPwdDB = app.appPassword; - String appUserName = app.username; + String encriptedPwdDB = app.getAppBasicAuthPassword(); + String appUserName = app.getAppBasicAuthUsername(); // String decreptedPwd = CipherUtil.decrypt(encriptedPwdDB, // SystemProperties.getProperty(SystemProperties.Decryption_Key)); @@ -288,7 +289,7 @@ public class SessionCommunication { MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS); } MDC.put(EPCommonSystemProperties.FULL_URL, url); - MDC.put(EPCommonSystemProperties.TARGET_ENTITY, app.myLoginsAppName); + MDC.put(EPCommonSystemProperties.TARGET_ENTITY, app.getMyLoginsAppName()); MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, restPath); } @@ -333,19 +334,19 @@ public class SessionCommunication { Map headersMap = new HashMap<>(); EPApp externalApp = null; - if(app.appPassword.isEmpty() || app.appPassword==null){ + if(app.getAppBasicAuthPassword().isEmpty() || app.getAppBasicAuthPassword()==null){ logger.debug(EELFLoggerDelegate.debugLogger, "Entering in the externalApp get app password contains null : {}"); externalApp = appsCacheService.getApp(1L); logger.debug(EELFLoggerDelegate.debugLogger, "external App Information : {}",externalApp); - String mechidUsername=externalApp.getUsername(); + String mechidUsername=externalApp.getAppBasicAuthUsername(); logger.debug(EELFLoggerDelegate.debugLogger, "external App mechidUsername Information : {}",mechidUsername); - String password=externalApp.getAppPassword(); + String password=externalApp.getAppBasicAuthPassword(); String decreptedexternalAppPwd = StringUtils.EMPTY; try { decreptedexternalAppPwd = CipherUtil.decryptPKC(password, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e); } @@ -354,8 +355,8 @@ public class SessionCommunication { encriptedPwdDB = decreptedexternalAppPwd; }else{ - appUserName = app.username; - encriptedPwdDB = app.appPassword; + appUserName = app.getAppBasicAuthUsername(); + encriptedPwdDB = app.getAppBasicAuthPassword(); } headersMap.put("username", appUserName); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java index c855a8dc..2b8d6d43 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java @@ -57,7 +57,6 @@ import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.service.EPAppService; import org.onap.portalapp.portal.transport.OnboardingApp; -import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.domain.sessionmgt.TimeoutVO; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; @@ -133,19 +132,19 @@ public class TimeoutHandler extends QuartzJobBean { Map> appSessionTimeOutMap = new Hashtable>(); // determine the Max TimeOut Time for each of the managed sessions for (OnboardingApp app : appList) { - if (app.restUrl == null) { - logger.info(EELFLoggerDelegate.debugLogger, "Session Management: null restUrl, not fetching from app " + app.name); + if (app.getRestUrl() == null) { + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: null restUrl, not fetching from app " + app.getAppName()); continue; } - logger.info(EELFLoggerDelegate.debugLogger, "Session Management: Calling App " + app.name + " at URL " + app.restUrl); + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: Calling App " + app.getAppName() + " at URL " + app.getRestUrl()); String jsonSessionStr = fetchAppSessions(app); - logger.info(EELFLoggerDelegate.debugLogger, "Session Management: App " + app.name + " returned " + jsonSessionStr); + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: App " + app.getAppName() + " returned " + jsonSessionStr); if (jsonSessionStr == null || jsonSessionStr.isEmpty()) continue; try { Map sessionTimeoutMap = mapper.readValue(jsonSessionStr, typeRef); - appSessionTimeOutMap.put(app.id, sessionTimeoutMap); + appSessionTimeOutMap.put(app.getId(), sessionTimeoutMap); for (String portalJSessionId : sessionTimeoutMap.keySet()) { final TimeoutVO maxTimeoutVO = portalSessionTimeoutMap.get(portalJSessionId); final TimeoutVO compareTimeoutVO = sessionTimeoutMap.get(portalJSessionId); @@ -169,12 +168,12 @@ public class TimeoutHandler extends QuartzJobBean { // post the updated session timeouts back to the Apps for (OnboardingApp app : appList) { - if (app.restUrl == null) { - logger.warn(EELFLoggerDelegate.errorLogger, "Session Management: null restUrl, not posting back to app " + app.name); + if (app.getRestUrl() == null) { + logger.warn(EELFLoggerDelegate.errorLogger, "Session Management: null restUrl, not posting back to app " + app.getAppName()); continue; } - Map sessionTimeoutMap = appSessionTimeOutMap.get(app.id); + Map sessionTimeoutMap = appSessionTimeOutMap.get(app.getId()); if (sessionTimeoutMap == null || sessionTimeoutMap.isEmpty()) continue; @@ -185,7 +184,7 @@ public class TimeoutHandler extends QuartzJobBean { if (maxTimeoutVO == null || setTimeoutVO == null) { String message = String.format( "Session Management: Failed to update the session timeouts for the app: %s and the sessionId: %s.", - app.name, portalJSessionId); + app.getAppName(), portalJSessionId); logger.warn(EELFLoggerDelegate.errorLogger, message); continue; } @@ -195,7 +194,7 @@ public class TimeoutHandler extends QuartzJobBean { continue; } } - logger.info(EELFLoggerDelegate.debugLogger, "Session Management: Updating App " + app.restUrl); + logger.info(EELFLoggerDelegate.debugLogger, "Session Management: Updating App " + app.getRestUrl()); String sessionTimeoutMapStr = ""; try { sessionTimeoutMapStr = mapper.writeValueAsString(sessionTimeoutMap); 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 961006cc..5909036e 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 @@ -328,10 +328,10 @@ - - - - + + + + @@ -340,11 +340,11 @@ - + - + @@ -365,12 +365,22 @@ - + + + + + + + + + + + @@ -1248,7 +1258,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1261,6 +1271,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y or (a.OPEN = 'N' and r.ROLE_ID is null and p.STATUS_CD = 'S') ) + and a.app_type != 3 union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , @@ -1268,7 +1279,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION , b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d , ep_app_function e 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 order by app_name @@ -1289,7 +1300,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1300,6 +1311,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y or (a.OPEN = 'N' and r.USER_ID is not null and (p.STATUS_CD is null or p.STATUS_CD != 'H')) ) + and a.app_type != 3 union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , @@ -1307,7 +1319,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION, b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d , ep_app_function e 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 order by app_name @@ -1331,7 +1343,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1344,6 +1356,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y or (a.OPEN = 'N' and r.ROLE_ID is null and p.STATUS_CD = 'S') ) + and a.app_type != 3 union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , @@ -1351,7 +1364,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION, b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d , ep_app_function e 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 @@ -1379,7 +1392,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1389,14 +1402,16 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y (a.OPEN = 'Y' and p.STATUS_CD = 'S') or (a.OPEN = 'N' and r.USER_ID is not null and (p.STATUS_CD is null or p.STATUS_CD != 'H')) - )union + ) + and a.app_type != 3 + union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , b.APP_NOTES , b.APP_URL , b.APP_ALTERNATE_URL , b.APP_REST_ENDPOINT , b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION, b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d , ep_app_function e 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 @@ -1431,7 +1446,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1443,14 +1458,16 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y (a.OPEN = 'N' and r.ROLE_ID is not null and (p.STATUS_CD is null or p.STATUS_CD != 'H')) or (a.OPEN = 'N' and r.ROLE_ID is null and p.STATUS_CD = 'S') - )union + ) + and a.app_type != 3 + union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , b.APP_NOTES , b.APP_URL , b.APP_ALTERNATE_URL , b.APP_REST_ENDPOINT , b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION, b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d , ep_app_function e 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 @@ -1481,7 +1498,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1491,14 +1508,16 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y (a.OPEN = 'Y' and p.STATUS_CD = 'S') or (a.OPEN = 'N' and r.USER_ID is not null and (p.STATUS_CD is null or p.STATUS_CD != 'H')) - )union + ) + and a.app_type != 3 + union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , b.APP_NOTES , b.APP_URL , b.APP_ALTERNATE_URL , b.APP_REST_ENDPOINT , b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION, b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d, ep_app_function e 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 @@ -1528,7 +1547,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1540,14 +1559,16 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y (a.OPEN = 'N' and r.ROLE_ID is not null and (p.STATUS_CD is null or p.STATUS_CD != 'H')) or (a.OPEN = 'N' and r.ROLE_ID is null and p.STATUS_CD = 'S') - )union + ) + and a.app_type != 3 + union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , b.APP_NOTES , b.APP_URL , b.APP_ALTERNATE_URL , b.APP_REST_ENDPOINT , b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION, b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d, ep_app_function e 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 @@ -1575,7 +1596,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y a.ML_APP_NAME , a.ML_APP_ADMIN_ID , a.MOTS_ID , a.APP_PASSWORD , a.THUMBNAIL , a.APP_USERNAME , a.OPEN , a.ENABLED , a.UEB_TOPIC_NAME , a.UEB_KEY , a.UEB_SECRET , a.APP_TYPE , a.AUTH_CENTRAL , - a.AUTH_NAMESPACE + a.AUTH_NAMESPACE , a.MODE_OF_INTEGRATION, a.ACK_APP , a.USES_CADI from FN_APP a -- Portal assigns role 999 to app administrator left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 @@ -1585,14 +1606,16 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y (a.OPEN = 'Y' and p.STATUS_CD = 'S') or (a.OPEN = 'N' and r.USER_ID is not null and (p.STATUS_CD is null or p.STATUS_CD != 'H')) - )union + ) + and a.app_type != 3 + union select distinct -- multiple roles yield multiple rows b.APP_ID , b.APP_NAME , b.APP_IMAGE_URL ,b.APP_DESCRIPTION , b.APP_NOTES , b.APP_URL , b.APP_ALTERNATE_URL , b.APP_REST_ENDPOINT , b.ML_APP_NAME , b.ML_APP_ADMIN_ID , b.MOTS_ID , b.APP_PASSWORD , b.THUMBNAIL , b.APP_USERNAME , b.OPEN , b.ENABLED , b.UEB_TOPIC_NAME , b.UEB_KEY , b.UEB_SECRET , b.APP_TYPE , b.AUTH_CENTRAL , - b.AUTH_NAMESPACE + b.AUTH_NAMESPACE , b.MODE_OF_INTEGRATION, b.ACK_APP , b.USES_CADI from fn_user_role a, fn_app b, ep_app_role_function c , fn_role d, ep_app_function e 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 @@ -1647,8 +1670,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 left outer join FN_PERS_USER_APP_SEL p ON a.APP_ID = p.APP_ID and p.USER_ID = :userId left outer join EP_USER_ROLES_REQUEST q ON a.APP_ID = q.APP_ID and q.USER_ID = :userId and q.request_status = 'P' - where a.ENABLED = 'Y' - + where a.ENABLED = 'Y' and a.app_type != 3 -- Show accessible apps first, then the rest; sort by name within each set. order by access desc, app_name asc ; @@ -1897,7 +1919,7 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y left outer join FN_USER_ROLE r ON a.APP_ID = r.APP_ID and r.USER_ID = :userId and r.ROLE_ID != 999 left outer join FN_PERS_USER_APP_SEL p ON a.APP_ID = p.APP_ID and p.USER_ID = :userId left outer join EP_USER_ROLES_REQUEST q ON a.APP_ID = q.APP_ID and q.USER_ID = :userId and q.request_status = 'P' - where a.ENABLED = 'Y' + where a.ENABLED = 'Y' and a.app_type != 3 -- Show accessible apps first, then the rest; sort by name within each set. order by access desc, app_name asc ; diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppCatalogControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppCatalogControllerTest.java index 1c1d7bc0..8b1fc82d 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppCatalogControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppCatalogControllerTest.java @@ -59,6 +59,7 @@ import org.onap.portalapp.portal.controller.AppCatalogController; import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.ecomp.model.AppCatalogItem; import org.onap.portalapp.portal.framework.MockitoTestSuite; import org.onap.portalapp.portal.service.AdminRolesService; @@ -245,23 +246,23 @@ public class AppCatalogControllerTest extends MockitoTestSuite { app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); Mockito.when(appService.getApp(persRequest.getAppId())).thenReturn(app); @@ -302,23 +303,23 @@ public class AppCatalogControllerTest extends MockitoTestSuite { app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); Mockito.when(appService.getApp(persRequest.getAppId())).thenReturn(app); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequestTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequestTest.java index 4535cf17..6e32846c 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequestTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerExternalRequestTest.java @@ -268,7 +268,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = (long) 1; + expectedOnboardingApp.setId(1l); PortalRestResponse actualPortalRestResponse = appsControllerExternalRequest .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp); @@ -285,13 +285,29 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = null; + expectedOnboardingApp.setId(null); + PortalRestResponse actualPortalRestResponse = appsControllerExternalRequest .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp); assertEquals(actualPortalRestResponse, expectedportalRestResponse); } + + private OnboardingApp createExpectedApp() { + + OnboardingApp expectedOnboardingApp = new OnboardingApp();; + expectedOnboardingApp.setAppName("test"); + expectedOnboardingApp.setLandingPage("test.com"); + expectedOnboardingApp.setRestUrl(""); + expectedOnboardingApp.setMyLoginsAppOwner("testUser"); + expectedOnboardingApp.setRestrictedApp(false); + expectedOnboardingApp.setIsOpen(true); + expectedOnboardingApp.setIsEnabled(true); + return expectedOnboardingApp; + + } + @Test public void postOnboardAppExternalXSSTest() { @@ -302,14 +318,8 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { PortalRestStatusEnum portalRestStatusEnum = null; expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); - OnboardingApp expectedOnboardingApp = new OnboardingApp();; - expectedOnboardingApp.name = "test"; - expectedOnboardingApp.url="test.com"; - expectedOnboardingApp.restUrl=""; - expectedOnboardingApp.myLoginsAppOwner="testUser"; - expectedOnboardingApp.restrictedApp=false; - expectedOnboardingApp.isOpen=true; - expectedOnboardingApp.isEnabled=true; + OnboardingApp expectedOnboardingApp = createExpectedApp(); + EPUser user = mockUser.mockEPUser(); user.setEmail("guestT@test.portal.onap.org"); user.setLoginPwd("pwd"); @@ -332,8 +342,9 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); Long appId = null; OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = null; - + + expectedOnboardingApp.setId(null); + PortalRestResponse actualPortalRestResponse = appsControllerExternalRequest .putOnboardAppExternal(mockedRequest, mockedResponse, appId, expectedOnboardingApp); assertEquals(actualPortalRestResponse, expectedportalRestResponse); @@ -348,14 +359,8 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { PortalRestStatusEnum portalRestStatusEnum = null; expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); - OnboardingApp expectedOnboardingApp = new OnboardingApp();; - expectedOnboardingApp.name = "test"; - expectedOnboardingApp.url="test.com"; - expectedOnboardingApp.restUrl=""; - expectedOnboardingApp.myLoginsAppOwner="testUser"; - expectedOnboardingApp.restrictedApp=false; - expectedOnboardingApp.isOpen=true; - expectedOnboardingApp.isEnabled=true; + OnboardingApp expectedOnboardingApp = createExpectedApp(); + EPUser user = mockUser.mockEPUser(); user.setEmail("guestT@test.portal.onap.org"); user.setLoginPwd("pwd"); @@ -381,7 +386,9 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); Long appId = (long) 1; OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = (long) 1; + + expectedOnboardingApp.setId(1l); + PortalRestResponse actualPortalRestResponse = appsControllerExternalRequest .putOnboardAppExternal(mockedRequest, mockedResponse, appId, expectedOnboardingApp); assertEquals(actualPortalRestResponse, expectedportalRestResponse); @@ -390,21 +397,14 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { @Test public void putOnboardAppExternalIfOnboardingAppDetailsTest() { PortalRestResponse expectedportalRestResponse = new PortalRestResponse(); - expectedportalRestResponse.setMessage("Failed to find user: testUser"); + expectedportalRestResponse.setMessage("Failed to find user: 12"); expectedportalRestResponse.setResponse(null); PortalRestStatusEnum portalRestStatusEnum = null; expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); Long appId = (long) 1; - OnboardingApp expectedOnboardingApp = new OnboardingApp(); - expectedOnboardingApp.id = (long) 1; - expectedOnboardingApp.name = "test"; - expectedOnboardingApp.url="test.com"; - expectedOnboardingApp.restUrl="test1.com"; - expectedOnboardingApp.myLoginsAppOwner="testUser"; - expectedOnboardingApp.restrictedApp=false; - expectedOnboardingApp.isOpen=true; - expectedOnboardingApp.isEnabled=true; + OnboardingApp expectedOnboardingApp = createOldOnapApp(1l); + EPUser user = mockUser.mockEPUser(); user.setEmail("guestT@test.portal.onap.org"); user.setLoginPwd("pwd"); @@ -422,6 +422,27 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { assertEquals(actualPortalRestResponse, expectedportalRestResponse); } + private OnboardingApp createOldOnapApp(Long id) { + + OnboardingApp oldOnboardApp = new OnboardingApp(); + oldOnboardApp.setId(id); + oldOnboardApp.setAppName("test"); + oldOnboardApp.setLandingPage("test.com"); + oldOnboardApp.setRestUrl("test1.com"); + oldOnboardApp.setMyLoginsAppOwner("12"); + oldOnboardApp.setRestrictedApp(false); + oldOnboardApp.setIsOpen(true); + oldOnboardApp.setIsEnabled(true); + oldOnboardApp.setModeOfIntegration("test"); + oldOnboardApp.setAppAck(false); + oldOnboardApp.setUsesCadi(false); + oldOnboardApp.setModeOfIntegration("test"); + oldOnboardApp.setAppAck(false); + oldOnboardApp.setUsesCadi(false); + + return oldOnboardApp; + } + @Test public void putOnboardAppExternalIfOnboardingAppDetailsTest2() throws Exception { @@ -433,15 +454,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { Long appId = (long) 1; - OnboardingApp oldOnboardApp = new OnboardingApp(); - oldOnboardApp.id = (long) 1; - oldOnboardApp.name = "test"; - oldOnboardApp.url="test.com"; - oldOnboardApp.restUrl="test1.com"; - oldOnboardApp.myLoginsAppOwner="12"; - oldOnboardApp.restrictedApp=false; - oldOnboardApp.isOpen=true; - oldOnboardApp.isEnabled=true; + OnboardingApp oldOnboardApp = createOldOnapApp(1l); EPUser user = mockUser.mockEPUser(); @@ -451,7 +464,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { List expectedList = new ArrayList(); expectedList.add(user); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(userService.getUserByUserId(oldOnboardApp.myLoginsAppOwner)).thenReturn(expectedList); + Mockito.when(userService.getUserByUserId(oldOnboardApp.getMyLoginsAppOwner())).thenReturn(expectedList); //Mockito.when(userService.saveNewUser(user, "Yes")).thenReturn(null); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); @@ -479,15 +492,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { Long appId = (long) 1; - OnboardingApp oldOnboardApp = new OnboardingApp(); - oldOnboardApp.id = (long) 1; - oldOnboardApp.name = "test"; - oldOnboardApp.url="test.com"; - oldOnboardApp.restUrl="test1.com"; - oldOnboardApp.myLoginsAppOwner="12"; - oldOnboardApp.restrictedApp=false; - oldOnboardApp.isOpen=true; - oldOnboardApp.isEnabled=true; + OnboardingApp oldOnboardApp = createOldOnapApp(1l); EPUser user = mockUser.mockEPUser(); @@ -497,7 +502,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { List expectedList = new ArrayList(); expectedList.add(user); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(userService.getUserByUserId(oldOnboardApp.myLoginsAppOwner)).thenReturn(expectedList); + Mockito.when(userService.getUserByUserId(oldOnboardApp.getMyLoginsAppOwner())).thenReturn(expectedList); //Mockito.when(userService.saveNewUser(user, "Yes")).thenReturn(null); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); @@ -524,16 +529,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { Long appId = (long) 1; - OnboardingApp oldOnboardApp = new OnboardingApp(); - oldOnboardApp.id = (long) 1; - oldOnboardApp.name = "test"; - oldOnboardApp.url="test.com"; - oldOnboardApp.restUrl="test1.com"; - oldOnboardApp.myLoginsAppOwner="12"; - oldOnboardApp.restrictedApp=false; - oldOnboardApp.isOpen=true; - oldOnboardApp.isEnabled=true; - + OnboardingApp oldOnboardApp = createOldOnapApp(1l); EPUser user = mockUser.mockEPUser(); user.setEmail("guestT@test.portal.onap.org"); @@ -542,7 +538,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { List expectedList = new ArrayList(); expectedList.add(user); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(userService.getUserByUserId(oldOnboardApp.myLoginsAppOwner)).thenReturn(expectedList); + Mockito.when(userService.getUserByUserId(oldOnboardApp.getMyLoginsAppOwner())).thenReturn(expectedList); //Mockito.when(userService.saveNewUser(user, "Yes")).thenReturn(null); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); @@ -569,17 +565,10 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { user.setLoginId("Test"); Long appId = (long) 1; - OnboardingApp oldOnboardApp = new OnboardingApp(); - oldOnboardApp.id = (long) 1; - oldOnboardApp.name = "test"; - oldOnboardApp.url="test.com"; - oldOnboardApp.restUrl="test1.com"; - oldOnboardApp.myLoginsAppOwner="12"; - oldOnboardApp.restrictedApp=false; - oldOnboardApp.isOpen=true; - oldOnboardApp.isEnabled=true; + OnboardingApp oldOnboardApp = createOldOnapApp(1l); + Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(userService.getUserByUserId(oldOnboardApp.myLoginsAppOwner)).thenThrow(nullPointerException); + Mockito.when(userService.getUserByUserId(oldOnboardApp.getMyLoginsAppOwner())).thenThrow(nullPointerException); PortalRestResponse actualPortalRestResponse = appsControllerExternalRequest .putOnboardAppExternal(mockedRequest, mockedResponse, appId,oldOnboardApp); assertEquals(actualPortalRestResponse, expectedportalRestResponse); @@ -596,18 +585,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { Long appId = (long) 1; - - - OnboardingApp newOnboardApp = new OnboardingApp(); - //newOnboardApp.id = (long) 1; - newOnboardApp.name = "test"; - newOnboardApp.url="test.com"; - newOnboardApp.restUrl="test1.com"; - newOnboardApp.myLoginsAppOwner="12"; - newOnboardApp.restrictedApp=false; - newOnboardApp.isOpen=true; - newOnboardApp.isEnabled=true; - + OnboardingApp newOnboardApp = createOldOnapApp(null); EPUser user = mockUser.mockEPUser(); user.setEmail("guestT@test.portal.onap.org"); @@ -616,7 +594,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { List expectedList = new ArrayList(); expectedList.add(user); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(userService.getUserByUserId(newOnboardApp.myLoginsAppOwner)).thenReturn(expectedList); + Mockito.when(userService.getUserByUserId(newOnboardApp.getMyLoginsAppOwner())).thenReturn(expectedList); //Mockito.when(userService.saveNewUser(user, "Yes")).thenReturn(null); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false); @@ -634,25 +612,14 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { public void postOnboardAppExternalIsNotSuperAdminTest() throws Exception { PortalRestResponse expectedportalRestResponse = new PortalRestResponse(); - expectedportalRestResponse.setMessage("java.lang.NullPointerException"); + expectedportalRestResponse.setMessage("Unexpected field: id"); expectedportalRestResponse.setResponse(null); PortalRestStatusEnum portalRestStatusEnum = null; expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR); Long appId = (long) 1; - - - OnboardingApp newOnboardApp = new OnboardingApp(); - //newOnboardApp.id = (long) 1; - newOnboardApp.name = "test"; - newOnboardApp.url="test.com"; - newOnboardApp.restUrl="test1.com"; - newOnboardApp.myLoginsAppOwner="12"; - newOnboardApp.restrictedApp=false; - newOnboardApp.isOpen=true; - newOnboardApp.isEnabled=true; - + OnboardingApp newOnboardApp = createOldOnapApp(1l); EPUser user = mockUser.mockEPUser(); user.setEmail("guestT@test.portal.onap.org"); @@ -661,7 +628,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { List expectedList = new ArrayList(); expectedList.add(user); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(userService.getUserByUserId(newOnboardApp.myLoginsAppOwner)).thenReturn(expectedList); + Mockito.when(userService.getUserByUserId(newOnboardApp.getMyLoginsAppOwner())).thenReturn(expectedList); //Mockito.when(userService.saveNewUser(user, "Yes")).thenReturn(null); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); @@ -686,18 +653,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { Long appId = (long) 1; - - - OnboardingApp newOnboardApp = new OnboardingApp(); - //newOnboardApp.id = (long) 1; - newOnboardApp.name = "test"; - newOnboardApp.url="test.com"; - newOnboardApp.restUrl="test1.com"; - newOnboardApp.myLoginsAppOwner="12"; - newOnboardApp.restrictedApp=false; - newOnboardApp.isOpen=true; - newOnboardApp.isEnabled=true; - + OnboardingApp newOnboardApp = createOldOnapApp(null); EPUser user = mockUser.mockEPUser(); user.setEmail("guestT@test.portal.onap.org"); @@ -706,7 +662,7 @@ public class AppsControllerExternalRequestTest extends MockitoTestSuite { List expectedList = new ArrayList(); expectedList.add(user); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(userService.getUserByUserId(newOnboardApp.myLoginsAppOwner)).thenReturn(expectedList); + Mockito.when(userService.getUserByUserId(newOnboardApp.getMyLoginsAppOwner())).thenReturn(expectedList); //Mockito.when(userService.saveNewUser(user, "Yes")).thenReturn(null); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerTest.java index f622faca..bd824e45 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/AppsControllerTest.java @@ -65,6 +65,7 @@ import org.onap.portalapp.portal.domain.AppsResponse; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.EcompApp; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.domain.UserRole; import org.onap.portalapp.portal.domain.UserRoles; import org.onap.portalapp.portal.framework.MockitoTestSuite; @@ -214,23 +215,23 @@ public class AppsControllerTest extends MockitoTestSuite{ app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); expectedApps.add(app); @@ -263,23 +264,23 @@ public class AppsControllerTest extends MockitoTestSuite{ app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); expectedApps.add(app); @@ -824,14 +825,14 @@ public class AppsControllerTest extends MockitoTestSuite{ EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); OnboardingApp OnboardingApp = new OnboardingApp(); - OnboardingApp.isCentralAuth = true; - OnboardingApp.nameSpace = "test1"; + OnboardingApp.setRolesInAAF(true); + OnboardingApp.setNameSpace("test1"); FieldsValidator expectedFieldValidator = new FieldsValidator(); expectedFieldValidator.setHttpStatusCode((long) 200); expectedFieldValidator.setFields(null); expectedFieldValidator.setErrorCode(null); EPApp OnboardingApp1 = new EPApp(); - OnboardingApp1.setCentralAuth(false); + OnboardingApp1.setRolesInAAF(false); OnboardingApp1.setNameSpace("test"); Mockito.when(appService.getApp(Matchers.anyLong())).thenReturn(OnboardingApp1); Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true); @@ -849,8 +850,8 @@ public class AppsControllerTest extends MockitoTestSuite{ EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); OnboardingApp onboardingApp = new OnboardingApp(); - onboardingApp.isCentralAuth = true; - onboardingApp.nameSpace = "com.test1"; + onboardingApp.setRolesInAAF(true); + onboardingApp.setNameSpace("com.test1"); EPApp app = new EPApp(); app.setNameSpace("com.test "); FieldsValidator expectedFieldValidator = new FieldsValidator(); @@ -876,10 +877,10 @@ public class AppsControllerTest extends MockitoTestSuite{ EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); OnboardingApp onboardingApp = new OnboardingApp(); - onboardingApp.isCentralAuth = false; - onboardingApp.nameSpace = "com.test1"; + onboardingApp.setRolesInAAF(false); + onboardingApp.setNameSpace("com.test1"); EPApp app = new EPApp(); - app.setCentralAuth(false); + app.setRolesInAAF(false); app.setNameSpace("com.test "); FieldsValidator expectedFieldValidator = new FieldsValidator(); expectedFieldValidator.setHttpStatusCode((long) 404); @@ -902,8 +903,8 @@ public class AppsControllerTest extends MockitoTestSuite{ EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); OnboardingApp onboardingApp = new OnboardingApp(); - onboardingApp.isCentralAuth = true; - onboardingApp.nameSpace = "com.test1"; + onboardingApp.setRolesInAAF(true); + onboardingApp.setNameSpace("com.test1"); EPApp app = new EPApp(); app.setNameSpace("com.test "); FieldsValidator expectedFieldValidator = new FieldsValidator(); @@ -1074,11 +1075,11 @@ public class AppsControllerTest extends MockitoTestSuite{ EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); - app.setAppType(1); + app.setAppType(EpAppType.GUI); app.setImageUrl("www.ecomp.com"); app.setThumbnail(new byte[] {1, 6, 3}); Mockito.when(appService.getApp((long) 1)).thenReturn(app); @@ -1093,11 +1094,11 @@ public class AppsControllerTest extends MockitoTestSuite{ EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); - app.setAppType(1); + app.setAppType(EpAppType.GUI); app.setImageUrl("www.ecomp.png"); app.setThumbnail(new byte[] {1, 6, 3}); Mockito.when(appService.getApp((long) 1)).thenReturn(app); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java index 6b06ee22..1ac21b68 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java @@ -63,6 +63,7 @@ import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.CentralV2RoleFunction; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.framework.MockitoTestSuite; @@ -125,23 +126,23 @@ public class ExternalAccessRolesControllerTest { EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } @@ -166,7 +167,7 @@ public class ExternalAccessRolesControllerTest { PrintWriter writer = new PrintWriter(sw); Mockito.when(mockedResponse.getWriter()).thenReturn(writer); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); @@ -207,7 +208,7 @@ public class ExternalAccessRolesControllerTest { String expectedCentralUser = "test"; String loginId = "test"; EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); @@ -225,7 +226,7 @@ public class ExternalAccessRolesControllerTest { String expectedCentralUser = null; String loginId = "test"; EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); @@ -245,7 +246,7 @@ public class ExternalAccessRolesControllerTest { List centralV2RoleList = new ArrayList<>(); List centralRoleList = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response); @@ -267,7 +268,7 @@ public class ExternalAccessRolesControllerTest { List centralV2RoleList = new ArrayList<>(); List centralRoleList = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); ResponseEntity response = null; Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response); @@ -289,7 +290,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); List centralV2Role = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response); @@ -309,7 +310,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); List centralV2Role = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); ResponseEntity response = null; Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response); @@ -354,7 +355,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); List centralV2RoleFunction = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response); @@ -387,7 +388,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); List centralV2RoleFunction = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); Mockito.when(externalAccessRolesService.getNameSpaceIfExists(applicationList.get(0))).thenReturn(response); @@ -419,7 +420,7 @@ public class ExternalAccessRolesControllerTest { long roleId = 1; CentralV2Role centralV2Role = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); @@ -467,7 +468,7 @@ public class ExternalAccessRolesControllerTest { long roleId = 1; CentralV2Role centralV2Role = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); @@ -516,7 +517,7 @@ public class ExternalAccessRolesControllerTest { CentralV2RoleFunction centralV2RoleFunction = new CentralV2RoleFunction(); centralV2RoleFunction.setCode("test"); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); @@ -537,7 +538,7 @@ public class ExternalAccessRolesControllerTest { String code = "test"; CentralV2RoleFunction centralV2RoleFunction = null; EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); ResponseEntity response = new ResponseEntity<>(HttpStatus.FOUND); @@ -565,7 +566,7 @@ public class ExternalAccessRolesControllerTest { @Test public void getRoleFunctionTest() throws Exception { EPApp mockApp = mockApp(); - mockApp.setCentralAuth(true); + mockApp.setRolesInAAF(true); List mockAppList = new ArrayList<>(); mockAppList.add(mockApp); StringWriter sw = new StringWriter(); @@ -607,7 +608,7 @@ public class ExternalAccessRolesControllerTest { public void getRoleFunctionXSSTest() throws Exception { String expected = getXSSKeyJson(); EPApp mockApp = mockApp(); - mockApp.setCentralAuth(true); + mockApp.setRolesInAAF(true); List mockAppList = new ArrayList<>(); mockAppList.add(mockApp); StringWriter sw = new StringWriter(); @@ -656,12 +657,12 @@ public class ExternalAccessRolesControllerTest { public void saveRoleFunctionExceptionTest() throws Exception { List applicationList = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); PortalRestResponse portalRestResponse = null; PortalRestResponse expectedportalRestResponse = new PortalRestResponse<>(); - expectedportalRestResponse.setMessage(null); + expectedportalRestResponse.setMessage("argument \"content\" is null"); expectedportalRestResponse.setResponse("Failed"); expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR); Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn(uebKey); @@ -679,7 +680,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); JSONObject roleFunc = new JSONObject(); roleFunc.put("type", "test_type"); @@ -720,7 +721,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); JSONObject roleFunc = new JSONObject(); roleFunc.put("type", " "); @@ -768,7 +769,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); expectedportalRestResponse.setStatus(PortalRestStatusEnum.OK); @@ -799,7 +800,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); String code = ""; @@ -831,7 +832,7 @@ public class ExternalAccessRolesControllerTest { public void getActiveRolesValidationTest() throws Exception { List expectedRolesList = null; EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); List cenRoles = new ArrayList<>(); @@ -1112,7 +1113,7 @@ public class ExternalAccessRolesControllerTest { Mockito.when(mockedResponse.getWriter()).thenReturn(writer); List applicationList = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); Mockito.when(externalAccessRolesService.getAllAppUsers(mockedRequest.getHeader(uebKey))).thenReturn(users); @@ -1209,7 +1210,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); EPApp app = mockApp(); app.setUebKey("uebKey"); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); ResponseEntity response = new ResponseEntity<>(HttpStatus.OK); @@ -1222,7 +1223,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); EPApp app = mockApp(); app.setUebKey("uebKey"); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); ResponseEntity response = new ResponseEntity<>(HttpStatus.OK); @@ -1241,7 +1242,7 @@ public class ExternalAccessRolesControllerTest { public void getEpUserExceptionTest() throws Exception { List applicationList = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); @@ -1254,7 +1255,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); EPApp app = mockApp(); app.setUebKey("uebKey"); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); ResponseEntity response = new ResponseEntity<>(HttpStatus.OK); @@ -1279,7 +1280,7 @@ public class ExternalAccessRolesControllerTest { List applicationList = new ArrayList<>(); EPApp app = mockApp(); app.setUebKey("uebKey"); - app.setCentralAuth(true); + app.setRolesInAAF(true); applicationList.add(app); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); ResponseEntity response = new ResponseEntity<>(HttpStatus.OK); @@ -1297,7 +1298,7 @@ public class ExternalAccessRolesControllerTest { public void getEPRolesOfApplicationExceptionTest() throws Exception { List applicationList = new ArrayList<>(); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList); StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); @@ -1319,7 +1320,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); expectedportalRestResponse.setStatus(PortalRestStatusEnum.OK); @@ -1351,7 +1352,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR); @@ -1383,7 +1384,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR); @@ -1435,7 +1436,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); expectedportalRestResponse.setStatus(PortalRestStatusEnum.OK); @@ -1467,7 +1468,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); String code = ""; @@ -1497,7 +1498,7 @@ public class ExternalAccessRolesControllerTest { List userList = new ArrayList<>(); userList.add(user); EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); List appList = new ArrayList<>(); appList.add(app); expectedportalRestResponse.setStatus(PortalRestStatusEnum.ERROR); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulControllerTest.java index d6cb42a6..890319dc 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulControllerTest.java @@ -66,6 +66,7 @@ import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPRole; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.framework.MockitoTestSuite; import org.onap.portalapp.portal.service.AdminRolesService; import org.onap.portalapp.portal.service.AdminRolesServiceImpl; @@ -135,24 +136,24 @@ public class ExternalAppsRestfulControllerTest { app.setName("Test"); app.setImageUrl("test"); app.setNameSpace("com.test.app"); - app.setCentralAuth(true); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setRolesInAAF(true); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 10); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/FunctionalMenuControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/FunctionalMenuControllerTest.java index bee5d932..80099d57 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/FunctionalMenuControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/FunctionalMenuControllerTest.java @@ -292,7 +292,7 @@ public class FunctionalMenuControllerTest extends MockitoTestSuite { @Test public void getFunctionalMenuStaticInfoTest(){ String fnMenuStaticactualResponse = null; - String fnMenuStaticexpectedResponse = "{\"firstName\":\"test\",\"lastName\":\"test\",\"last_login\":\"09/08/2017 03:48:13 -0400 am\",\"userId\":\"guestT\",\"email\":\"test\"}"; + String fnMenuStaticexpectedResponse = "{\"firstName\":\"test\",\"lastName\":\"test\",\"last_login\":\"09/08/2017 03:48:13 -0400 am\",\"userId\":\"guestT\",\"isSystemUser\":\"false\",\"email\":\"test\"}"; String orgUserIdStr = null; EPUser user = mockUser.mockEPUser(); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/RoleManageControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/RoleManageControllerTest.java index b004a4a1..bbc842a6 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/RoleManageControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/RoleManageControllerTest.java @@ -73,6 +73,7 @@ import org.onap.portalapp.portal.domain.CentralV2RoleFunction; import org.onap.portalapp.portal.domain.CentralizedApp; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.ecomp.model.UploadRoleFunctionExtSystem; @@ -170,16 +171,18 @@ public class RoleManageControllerTest { @Test public void getRoleIfRoleIdNullTest() throws Exception { + EPApp app = mockApp(); + app.setRolesInAAF(true); PowerMockito.mockStatic(EPUserUtils.class); PowerMockito.mockStatic(EcompPortalUtils.class); EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true); - Mockito.when(appService.getApp((long) 1)).thenReturn(CentralApp()); - Mockito.when(adminRolesService.isAccountAdminOfApplication(user, CentralApp())).thenReturn(true); + Mockito.when(appService.getApp((long) 1)).thenReturn(app); + Mockito.when(adminRolesService.isAccountAdminOfApplication(user, app)).thenReturn(true); List apps = new ArrayList<>(); - apps.add(CentralApp()); - Mockito.when(externalAccessRolesService.getApp(CentralApp().getUebKey())).thenReturn(apps); + apps.add(app); + Mockito.when(externalAccessRolesService.getApp(app.getUebKey())).thenReturn(apps); ResponseEntity result = new ResponseEntity<>(HttpStatus.OK); Mockito.when(externalAccessRolesService.getNameSpaceIfExists(apps.get(0))).thenReturn(result); CentralV2Role answer = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role(); @@ -191,7 +194,7 @@ public class RoleManageControllerTest { PrintWriter writer = new PrintWriter(sw); Mockito.when(mockedResponse.getWriter()).thenReturn(writer); List appList = new ArrayList<>(); - appList.add(CentralApp()); + appList.add(app); ResponseEntity response = new ResponseEntity<>(HttpStatus.OK); Mockito.when(externalAccessRolesService.getNameSpaceIfExists(Matchers.anyObject())).thenReturn(response); Mockito.when(externalAccessRolesService.getApp(Matchers.anyString())).thenReturn(appList); @@ -241,23 +244,26 @@ public class RoleManageControllerTest { app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); + app.setModeOfIntegration("test"); + app.setAppAck(false); + app.setUsesCadi(false); return app; } @@ -265,7 +271,7 @@ public class RoleManageControllerTest { @Test public void getRolesTest() throws Exception { EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); PowerMockito.mockStatic(EPUserUtils.class); PowerMockito.mockStatic(EcompPortalUtils.class); EPUser user = mockUser.mockEPUser(); @@ -298,13 +304,16 @@ public class RoleManageControllerTest { @Test public void getRoleFunctionListTest() throws Exception { + EPApp app = mockApp(); + app.setRolesInAAF(true); PowerMockito.mockStatic(EPUserUtils.class); PowerMockito.mockStatic(EcompPortalUtils.class); EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true); - Mockito.when(adminRolesService.isAccountAdminOfApplication(user, CentralApp())).thenReturn(true); - Mockito.when(appService.getApp((long) 1)).thenReturn(CentralApp()); + Mockito.when(adminRolesService.isAccountAdminOfApplication(user, app)).thenReturn(true); + + Mockito.when(appService.getApp((long) 1)).thenReturn(app); List answer = new ArrayList<>(); Mockito.when(externalAccessRolesService.getRoleFuncList("test")).thenReturn(answer); StringWriter sw = new StringWriter(); @@ -326,13 +335,15 @@ public class RoleManageControllerTest { @Test public void saveRoleFunctionTest() throws Exception { + EPApp app = mockApp(); + app.setRolesInAAF(true); PowerMockito.mockStatic(EPUserUtils.class); PowerMockito.mockStatic(EcompPortalUtils.class); EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true); - Mockito.when(adminRolesService.isAccountAdminOfApplication(user, CentralApp())).thenReturn(true); - Mockito.when(appService.getApp((long) 1)).thenReturn(CentralApp()); + Mockito.when(adminRolesService.isAccountAdminOfApplication(user, app)).thenReturn(true); + Mockito.when(appService.getApp((long) 1)).thenReturn(app); Mockito.doNothing().when(roleFunctionListController).saveRoleFunction(mockedRequest, mockedResponse, "test"); CentralV2RoleFunction addNewFunc = new CentralV2RoleFunction(); addNewFunc.setCode("Test"); @@ -351,7 +362,7 @@ public class RoleManageControllerTest { List userList = new ArrayList<>(); userList.add(user); List appList = new ArrayList<>(); - appList.add(CentralApp()); + appList.add(app); Mockito.when(externalAccessRolesService.getUser("guestT")).thenReturn(userList); StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); @@ -430,14 +441,16 @@ public class RoleManageControllerTest { @Test public void removeRoleFunctionTest() throws Exception { + EPApp app = mockApp(); + app.setRolesInAAF(true); PowerMockito.mockStatic(EPUserUtils.class); PowerMockito.mockStatic(EcompPortalUtils.class); EPUser user = mockUser.mockEPUser(); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true); - Mockito.when(adminRolesService.isAccountAdminOfApplication(user, CentralApp())).thenReturn(true); + Mockito.when(adminRolesService.isAccountAdminOfApplication(user, app)).thenReturn(true); Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user); - Mockito.when(appService.getApp((long) 1)).thenReturn(CentralApp()); + Mockito.when(appService.getApp((long) 1)).thenReturn(app); String roleFun = "{\"name\":\"Test\",\"type\":\"Test\",\"action\":\"Test\", \"code\":\"Test\"}"; CentralV2RoleFunction roleFunction = mockCentralRoleFunction(); Mockito.when(externalAccessRolesService.getRoleFunction("Test|Test|Test", "test")).thenReturn(roleFunction); @@ -447,7 +460,7 @@ public class RoleManageControllerTest { Mockito.when(externalAccessRolesService.deleteCentralRoleFunction(Matchers.anyString(), Matchers.anyObject())) .thenReturn(true); List appList = new ArrayList<>(); - appList.add(CentralApp()); + appList.add(app); ResponseEntity response = new ResponseEntity<>(HttpStatus.OK); Mockito.when(externalAccessRolesService.getNameSpaceIfExists(Matchers.anyObject())).thenReturn(response); Mockito.when(externalAccessRolesService.getApp(Matchers.anyString())).thenReturn(appList); @@ -512,7 +525,7 @@ public class RoleManageControllerTest { @Test public void removeRoleFunctionIfAppNotCentralizedTest() throws Exception { EPApp app = mockApp(); - app.setCentralAuth(false); + app.setRolesInAAF(false); Mockito.when(appService.getApp((long) 1)).thenReturn(app); String roleFun = "{\"name\":\"Test\",\"code\":\"Test\"}"; roleManageController.removeRoleFunction(mockedRequest, mockedResponse, roleFun, (long) 1); @@ -1021,14 +1034,14 @@ public class RoleManageControllerTest { public EPApp CentralApp() { EPApp app = mockApp(); - app.setCentralAuth(true); + app.setRolesInAAF(true); app.setNameSpace("com.test"); return app; } public EPApp NonCentralApp() { EPApp app = mockApp(); - app.setCentralAuth(false); + app.setRolesInAAF(false); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java index 56f0e5ca..640411ef 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java @@ -50,29 +50,25 @@ public class EPAppTest { private static final String TEST="test"; public EPApp mockEPApp(EPApp epApp){ - epApp.setId(1l); epApp.setName(TEST); epApp.setImageUrl(TEST); - epApp.setDescription(TEST); - epApp.setNotes(TEST); - epApp.setUrl(TEST); - epApp.setAlternateUrl(TEST); + epApp.setAppDescription(TEST); + epApp.setAppNotes(TEST); + epApp.setLandingPage(TEST); + epApp.setAlternateLandingPage(TEST); epApp.setAppRestEndpoint(TEST); epApp.setMlAppName(TEST); epApp.setMlAppAdminId(TEST); epApp.setMotsId((long)1); - epApp.setUsername(TEST); - epApp.setAppPassword(TEST); + epApp.setAppBasicAuthUsername(TEST); + epApp.setAppBasicAuthPassword(TEST); epApp.setOpen(false); epApp.setEnabled(false); epApp.setUebTopicName(TEST); epApp.setUebSecret(TEST); - epApp.setAppType(1); - epApp.setCentralAuth(false); + epApp.setAppType(EpAppType.GUI); + epApp.setRolesInAAF(false); epApp.setNameSpace(TEST); - epApp.setRestrictedApp(true); - epApp.setRestrictedApp(false); - epApp.setAppType(null); epApp.setOpen(null); epApp.setThumbnail(TEST.getBytes()); epApp.setUebKey(TEST); @@ -86,116 +82,62 @@ public class EPAppTest { epApp1 = mockEPApp(epApp1); EPApp epApp=new EPApp(); - epApp.setId(epApp1.getId()); epApp.setName(epApp1.getName()); epApp.setImageUrl(epApp1.getImageUrl()); - epApp.setDescription(epApp1.getDescription()); - epApp.setNotes(epApp1.getNotes()); - epApp.setUrl(epApp1.getUrl()); - epApp.setAlternateUrl(epApp1.getAlternateUrl()); + epApp.setAppDescription(epApp1.getAppDescription()); + epApp.setAppNotes(epApp1.getAppNotes()); + epApp.setLandingPage(epApp1.getLandingPage()); + epApp.setAlternateLandingPage(epApp1.getAlternateLandingPage()); epApp.setAppRestEndpoint(epApp1.getAppRestEndpoint()); epApp.setMlAppName(epApp1.getMlAppName()); epApp.setMlAppAdminId(epApp1.getMlAppAdminId()); epApp.setMotsId(epApp1.getMotsId()); - epApp.setUsername(epApp1.getUsername()); - epApp.setAppPassword(epApp1.getAppPassword()); + epApp.setAppBasicAuthUsername(epApp1.getAppBasicAuthUsername()); + epApp.setAppBasicAuthPassword(epApp1.getAppBasicAuthPassword()); epApp.setOpen(epApp1.getOpen()); epApp.setEnabled(epApp1.getEnabled()); epApp.setUebTopicName(epApp1.getUebTopicName()); epApp.setUebSecret(epApp1.getUebSecret()); epApp.setAppType(epApp1.getAppType()); - epApp.setCentralAuth(epApp1.getCentralAuth()); + epApp.setRolesInAAF(epApp1.getRolesInAAF()); epApp.setNameSpace(epApp1.getNameSpace()); - epApp.setRestrictedApp(epApp1.isRestrictedApp()); epApp.setAppType(epApp1.getAppType()); epApp.setThumbnail(epApp1.getThumbnail()); epApp.setUebKey(epApp1.getUebKey()); - epApp.compareTo(epApp1); assertEquals(epApp.hashCode(), epApp1.hashCode()); - assertTrue(epApp.equals(epApp1)); assertFalse(epApp.equals(null)); assertEquals(epApp.getName(), TEST); - assertEquals(epApp.getId(), Long.valueOf(1l)); assertEquals(epApp.getImageUrl(), TEST); - assertEquals(epApp.getDescription(), TEST); - assertEquals(epApp.getNotes(), TEST); - assertEquals(epApp.getUrl(), TEST); - assertEquals(epApp.getAlternateUrl(), TEST); + assertEquals(epApp.getAppDescription(), TEST); + assertEquals(epApp.getAppNotes(), TEST); + assertEquals(epApp.getLandingPage(), TEST); + assertEquals(epApp.getAlternateLandingPage(), TEST); assertEquals(epApp.getAppRestEndpoint(), TEST); assertEquals(epApp.getMlAppName(), TEST); assertEquals(epApp.getMlAppAdminId(), TEST); assertEquals(epApp.getMotsId(), new Long(1)); - assertEquals(epApp.getUsername(), TEST); - assertEquals(epApp.getAppPassword(), TEST); + assertEquals(epApp.getAppBasicAuthUsername(), TEST); + assertEquals(epApp.getAppBasicAuthPassword(), TEST); assertEquals(epApp.getOpen(), false); assertEquals(epApp.getEnabled(), false); assertEquals(epApp.getUebTopicName(), TEST); assertEquals(epApp.getUebSecret(), TEST); assertEquals(epApp.getAppType(), Integer.valueOf(1)); - assertEquals(epApp.getCentralAuth(), false); + assertEquals(epApp.getRolesInAAF(), false); assertEquals(epApp.getNameSpace(), TEST); assertEquals(epApp.getUebKey(), TEST); assertEquals(epApp.getOpen(), false); assertEquals(epApp.isRestrictedApp(), false); assertEquals(epApp.hashCode(), epApp1.hashCode()); - assertTrue(epApp.equals(epApp1)); - //epApp.compareTo(epApp1); assertNotNull(epApp.toString()); epApp.setContactUs(new AppContactUs()); assertNotNull(epApp.getContactUs()); - - epApp.setUsername(null); - assertFalse(epApp.equals(epApp1)); - epApp.setUrl(null); - assertFalse(epApp.equals(epApp1)); - epApp.setUebTopicName(null); - assertFalse(epApp.equals(epApp1)); - - epApp.setUebSecret(null); - assertFalse(epApp.equals(epApp1)); - epApp.setUebKey(null); - assertFalse(epApp.equals(epApp1)); - epApp.setOpen(null); - assertFalse(epApp.equals(epApp1)); - epApp.setNotes(null); - assertFalse(epApp.equals(epApp1)); - epApp.setNameSpace(null); - assertFalse(epApp.equals(epApp1)); - - epApp.setName(null); - assertFalse(epApp.equals(epApp1)); - epApp.setMotsId(null); - assertFalse(epApp.equals(epApp1)); - epApp.setMlAppName(null); - assertFalse(epApp.equals(epApp1)); - epApp.setMlAppAdminId(null); - assertFalse(epApp.equals(epApp1)); - epApp.setImageUrl(null); - assertFalse(epApp.equals(epApp1)); - epApp.setEnabled(null); - assertFalse(epApp.equals(epApp1)); - epApp.setDescription(null); - assertFalse(epApp.equals(epApp1)); - epApp.setContactUs(null); - assertFalse(epApp.equals(epApp1)); - - epApp.setCentralAuth(null); - assertFalse(epApp.equals(epApp1)); - - epApp.setAppType(null); - assertFalse(epApp.equals(epApp1)); - epApp.setAppRestEndpoint(null); - assertFalse(epApp.equals(epApp1)); - epApp.setAppPassword(null); - assertFalse(epApp.equals(epApp1)); - - epApp.setAlternateUrl(null); - assertFalse(epApp.equals(epApp1)); + } } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPServiceCookieTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPServiceCookieTest.java new file mode 100644 index 00000000..27118a4c --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPServiceCookieTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2020 IBM 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.domain; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; + +public class EPServiceCookieTest { + EPServiceCookie ep=new EPServiceCookie(); + + @Test + public void testGetValue() throws NullPointerException{ + Map mymap = new HashMap<>(); + mymap.put("1", "one"); + ep.setValue(mymap); + assertNotNull(ep.getValue()); + assertTrue(ep.getValue().equals(mymap)); + } + +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java index 0923d033..eddbe418 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppTest.java @@ -53,16 +53,16 @@ public class EPUserAppTest { EPApp epApp = new EPApp(); epApp.setName("test"); epApp.setImageUrl("test"); - epApp.setDescription("test"); - epApp.setNotes("test"); - epApp.setUrl("test"); - epApp.setAlternateUrl("test"); + epApp.setAppDescription("test"); + epApp.setAppNotes("test"); + epApp.setLandingPage("test"); + epApp.setAlternateLandingPage("test"); epApp.setAppRestEndpoint("test"); epApp.setMlAppName("test"); epApp.setMlAppAdminId("test"); epApp.setMotsId((long)1); - epApp.setUsername("test"); - epApp.setAppPassword("test"); + epApp.setAppBasicAuthUsername("test"); + epApp.setAppBasicAuthPassword("test"); //Role @@ -90,16 +90,16 @@ public class EPUserAppTest { EPApp epApp = new EPApp(); epApp.setName("test"); epApp.setImageUrl("test"); - epApp.setDescription("test"); - epApp.setNotes("test"); - epApp.setUrl("test"); - epApp.setAlternateUrl("test"); + epApp.setAppDescription("test"); + epApp.setAppNotes("test"); + epApp.setLandingPage("test"); + epApp.setAlternateLandingPage("test"); epApp.setAppRestEndpoint("test"); epApp.setMlAppName("test"); epApp.setMlAppAdminId("test"); epApp.setMotsId((long)1); - epApp.setUsername("test"); - epApp.setAppPassword("test"); + epApp.setAppBasicAuthUsername("test"); + epApp.setAppBasicAuthPassword("test"); user.setApp(epApp); //Role @@ -152,16 +152,16 @@ public class EPUserAppTest { epApp.setId((long) 12345); epApp.setName("test"); epApp.setImageUrl("test"); - epApp.setDescription("test"); - epApp.setNotes("test"); - epApp.setUrl("test"); - epApp.setAlternateUrl("test"); + epApp.setAppDescription("test"); + epApp.setAppNotes("test"); + epApp.setLandingPage("test"); + epApp.setAlternateLandingPage("test"); epApp.setAppRestEndpoint("test"); epApp.setMlAppName("test"); epApp.setMlAppAdminId("test"); epApp.setMotsId((long)1); - epApp.setUsername("test"); - epApp.setAppPassword("test"); + epApp.setAppBasicAuthUsername("test"); + epApp.setAppBasicAuthPassword("test"); return epApp; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/DuplicateRecordExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/DuplicateRecordExceptionTest.java new file mode 100644 index 00000000..9154e8d0 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/DuplicateRecordExceptionTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2020 IBM 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.exceptions; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class DuplicateRecordExceptionTest { + @Test + public void Test1() + { + String s1 = "Duplicate Record"; + DuplicateRecordException mde=new DuplicateRecordException(s1); + assertEquals(mde.getMessage(),"Duplicate Record"); + + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NonCentralizedAppExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NonCentralizedAppExceptionTest.java index 7109b2d0..d2958437 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NonCentralizedAppExceptionTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NonCentralizedAppExceptionTest.java @@ -39,11 +39,14 @@ package org.onap.portalapp.portal.exceptions; import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class NonCentralizedAppExceptionTest { @Test public void TestException2() { String s1 = "Value1"; NonCentralizedAppException nca = new NonCentralizedAppException(s1); + assertEquals(nca.toString(),"Value1 is not Centralized Application"); } } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NotValidDataExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NotValidDataExceptionTest.java new file mode 100644 index 00000000..889b28f2 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/NotValidDataExceptionTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START============================================ + * ONAP Portal + * ===================================================================== + * Copyright (C) 2020 IBM 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.exceptions; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +public class NotValidDataExceptionTest { + + @Test + public void TestException2() { + String s1 = "data"; + NotValidDataException nca = new NotValidDataException(s1); + assertEquals(nca.toString(),"NotValidDataException{}: data"); + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/RoleFunctionExceptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/RoleFunctionExceptionTest.java new file mode 100644 index 00000000..db17e784 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/exceptions/RoleFunctionExceptionTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START============================================ + * ONAP Portal + * ===================================================================== + * Copyright (C) 2020 IBM 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.exceptions; + +import org.apache.commons.codec.DecoderException; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +public class RoleFunctionExceptionTest { + + @Test + public void TestRoleFunctionConstructor() + { + String s1 = "Rolefunction Exception Occured"; + String s2 = "value2"; + DecoderException e=new DecoderException(s2); + RoleFunctionException rfe=new RoleFunctionException(s1,e); + assertEquals(rfe.getMessage(),"Rolefunction Exception Occured"); + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptorTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptorTest.java index 81b4e64d..94d46506 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptorTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptorTest.java @@ -152,7 +152,7 @@ public class PortalResourceInterceptorTest { data.add("test/test"); List apps=new ArrayList<>(); EPApp app=new EPApp(); - app.setUsername("test"); + app.setAppBasicAuthUsername("test"); apps.add(app); when(request.getRequestURI()).thenReturn("test/portalApi/test/test"); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/RestObjectTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/RestObjectTest.java new file mode 100644 index 00000000..563135c5 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/RestObjectTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2020 IBM 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.scheduler; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class RestObjectTest { + RestObject rs=new RestObject(); + + @Test + public void testGetMethods() { + rs.setStatusCode(200); + rs.setUUID("1234"); + assertEquals(rs.getUUID(),"1234"); + assertEquals(rs.getStatusCode(),200); +// assertNull(rs.get()); + } + +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AdminRolesServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AdminRolesServiceImplTest.java index f14d3fd9..7f34583c 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AdminRolesServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AdminRolesServiceImplTest.java @@ -69,6 +69,7 @@ import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPRole; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.EPUserApp; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.domain.UserRole; import org.onap.portalapp.portal.transport.AppNameIdIsAdmin; import org.onap.portalapp.portal.transport.AppsListWithAdminRole; @@ -140,24 +141,24 @@ public class AdminRolesServiceImplTest { app.setName("Test"); app.setImageUrl("test"); app.setNameSpace("com.test.app"); - app.setCentralAuth(true); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setRolesInAAF(true); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java index acc25ac8..e5b7431e 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java @@ -55,6 +55,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalapp.portal.domain.AppContactUs; import org.onap.portalapp.portal.domain.EPApp; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.ecomp.model.AppCategoryFunctionsItem; import org.onap.portalapp.portal.ecomp.model.AppContactUsItem; import org.onap.portalapp.portal.framework.MockitoTestSuite; @@ -92,23 +93,23 @@ public class AppContactUsServiceImplTest { EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(true); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } @Test diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImplTest.java index a9747335..df73316b 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImplTest.java @@ -91,7 +91,7 @@ public class ApplicationsRestClientServiceImplTest { public void unt_get_failure() throws HTTPException{ EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.get(ApplicationsRestClientServiceImpl.class, 12L,"/path" ); Assert.assertNull(appservice); @@ -109,7 +109,7 @@ public class ApplicationsRestClientServiceImplTest { Mockito.when(response.getStatus()).thenReturn(HttpStatus.SC_OK); EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.get(ApplicationsRestClientServiceImpl.class, 12L,"/path" ); Assert.assertNull(appservice); @@ -127,7 +127,7 @@ public class ApplicationsRestClientServiceImplTest { Mockito.when(response.getStatus()).thenReturn(1); EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.get(ApplicationsRestClientServiceImpl.class, 12L,"/path" ); Assert.assertNull(appservice); @@ -139,7 +139,7 @@ public class ApplicationsRestClientServiceImplTest { PowerMockito.mockStatic(Object.class); EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.post(ApplicationsRestClientServiceImpl.class, 12L, Matchers.any() , "/path",Matchers.any()); Assert.assertNull(appservice); @@ -163,7 +163,7 @@ public class ApplicationsRestClientServiceImplTest { Mockito.when(response.getStatus()).thenReturn(HttpStatus.SC_OK); EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.post(ApplicationsRestClientServiceImpl.class, 12L,payload,"/path",SystemType.APPLICATION); Assert.assertNull(appservice); @@ -188,7 +188,7 @@ public class ApplicationsRestClientServiceImplTest { Mockito.when(response.getStatus()).thenReturn(HttpStatus.SC_OK); EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.post(ApplicationsRestClientServiceImpl.class, 12L,payload,"/path",SystemType.APPLICATION); Assert.assertNull(appservice); @@ -213,7 +213,7 @@ public class ApplicationsRestClientServiceImplTest { Mockito.when(response.getStatus()).thenReturn(1); EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.post(ApplicationsRestClientServiceImpl.class, 12L,payload,"/path",SystemType.APPLICATION); Assert.assertNull(appservice); @@ -232,7 +232,7 @@ public class ApplicationsRestClientServiceImplTest { Mockito.when(response.getStatus()).thenReturn(1); EPApp appTest=new EPApp(); appTest.setAppRestEndpoint("https"); - appTest.setAppPassword("testPassword"); + appTest.setAppBasicAuthPassword("testPassword"); Mockito.when(appsCacheService.getApp(Matchers.anyLong())).thenReturn(appTest); ApplicationsRestClientServiceImpl appservice=serviceImpl.get(ApplicationsRestClientServiceImpl.class, 12L,"/path" , Matchers.anyBoolean()); Assert.assertNull(appservice); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java index 6382bef4..a905ca81 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java @@ -42,6 +42,8 @@ import org.onap.portalapp.portal.domain.EPEndpoint; import org.onap.portalapp.portal.domain.EPEndpointAccount; import org.onap.portalapp.portal.framework.MockitoTestSuite; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.service.DataAccessServiceImpl; import org.onap.portalsdk.core.util.SystemProperties; @@ -51,7 +53,7 @@ import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({ CipherUtil.class , SystemProperties.class}) +@PrepareForTest({ CipherUtil.class , SystemProperties.class, KeyProperties.class, KeyConstants.class}) public class BasicAuthAccountServiceImplTest { @Mock DataAccessService dataAccessService = new DataAccessServiceImpl(); @@ -92,11 +94,12 @@ public class BasicAuthAccountServiceImplTest { @Test public void saveBasicAuthAccountTest_password() throws Exception{ PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); BasicAuthCredentials credentials = new BasicAuthCredentials(); credentials.setPassword("password"); String result = null; - Mockito.when(CipherUtil.encryptPKC("password", SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(result); + Mockito.when(CipherUtil.encryptPKC("password", KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(result); basicAuthAccountServiceImpl.saveBasicAuthAccount(credentials); } @@ -163,7 +166,8 @@ public class BasicAuthAccountServiceImplTest { @Test public void getAccountDataTest_password() throws Exception { PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); List list = new ArrayList<>(); BasicAuthCredentials basicAuthCredentials = new BasicAuthCredentials(); basicAuthCredentials.setPassword("password"); @@ -171,7 +175,7 @@ public class BasicAuthAccountServiceImplTest { Mockito.when((List) dataAccessService.getList(BasicAuthCredentials.class, null)) .thenReturn(list); String result = null; - Mockito.when(CipherUtil.decryptPKC("password", SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(result); + Mockito.when(CipherUtil.decryptPKC("password", KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(result); } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPAppCommonServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPAppCommonServiceImplTest.java index 1451693d..d00dc211 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPAppCommonServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPAppCommonServiceImplTest.java @@ -74,6 +74,7 @@ import org.onap.portalapp.portal.domain.EPUserAppsManualSortPreference; import org.onap.portalapp.portal.domain.EPUserAppsSortPreference; import org.onap.portalapp.portal.domain.EPWidgetsManualSortPreference; import org.onap.portalapp.portal.domain.EcompApp; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.domain.UserRole; import org.onap.portalapp.portal.domain.UserRoles; import org.onap.portalapp.portal.ecomp.model.AppCatalogItem; @@ -157,24 +158,24 @@ public class EPAppCommonServiceImplTest { EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); - app.setCentralAuth(true); + app.setRolesInAAF(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } @@ -439,7 +440,7 @@ public class EPAppCommonServiceImplTest { public void getRestrictedAppRolesTest() { EPUser user = mockUser.mockEPUser(); EPApp mockApp = mockApp(); - mockApp.setRestrictedApp(true); + mockApp.setAppType(EpAppType.HYPERLINK); user.setLoginId("guestT"); List expected = new ArrayList<>(); LocalRole localRole = new LocalRole(); @@ -458,7 +459,7 @@ public class EPAppCommonServiceImplTest { public void getPoralAppRolesTest() { EPUser user = mockUser.mockEPUser(); EPApp mockApp = mockApp(); - mockApp.setRestrictedApp(false); + mockApp.setAppType(EpAppType.GUI); mockApp.setId(1l); user.setLoginId("guestT"); List expected = new ArrayList<>(); @@ -477,7 +478,7 @@ public class EPAppCommonServiceImplTest { public void getNonPortalAndNonRestrictedAppRolesTest() { EPUser user = mockUser.mockEPUser(); EPApp mockApp = mockApp(); - mockApp.setRestrictedApp(false); + mockApp.setAppType(EpAppType.GUI); mockApp.setId(2l); user.setLoginId("guestT"); List expected = new ArrayList<>(); @@ -539,15 +540,15 @@ public class EPAppCommonServiceImplTest { List mockAppList = new ArrayList<>(); OnboardingApp onboardApp = new OnboardingApp(); onboardApp.setRestrictedApp(false); - onboardApp.name = "test1"; - onboardApp.url = "http://test.com"; - onboardApp.isOpen = false; - onboardApp.isEnabled = true; - onboardApp.username = "test123"; - onboardApp.appPassword = "test123"; + onboardApp.setAppName("test1"); + onboardApp.setLandingPage("http://test.com"); + onboardApp.setIsOpen(false); + onboardApp.setIsEnabled(true); + onboardApp.setAppBasicAuthUsername("test123"); + onboardApp.setAppBasicAuthPassword("test123"); List restrictionsList = new ArrayList(); - Criterion urlCrit = Restrictions.eq("url", onboardApp.url); - Criterion nameCrit = Restrictions.eq("name", onboardApp.name); + Criterion urlCrit = Restrictions.eq("url", onboardApp.getLandingPage()); + Criterion nameCrit = Restrictions.eq("name", onboardApp.getAppName()); Criterion orCrit = Restrictions.or(urlCrit, nameCrit); restrictionsList.add(orCrit); List uebList = new ArrayList<>(); @@ -573,42 +574,46 @@ public class EPAppCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setName("test1"); mockApp.setId(2l); - mockApp.setUrl("http://test.com"); - mockApp.setUsername("test123"); - mockApp.setAppPassword("test123"); - mockApp.setRestrictedApp(false); + mockApp.setLandingPage("http://test.com"); + mockApp.setAppBasicAuthUsername("test123"); + mockApp.setAppBasicAuthPassword("*******"); + mockApp.setAppType(EpAppType.GUI); mockApp.setEnabled(true); mockApp.setOpen(false); List mockAppList = new ArrayList<>(); mockAppList.add(mockApp); OnboardingApp onboardApp = new OnboardingApp(); onboardApp.setRestrictedApp(false); - onboardApp.name = "test1"; - onboardApp.id = 2l; - onboardApp.url = "http://test.com"; - onboardApp.restUrl = "http://test.com"; - onboardApp.isOpen = false; - onboardApp.isEnabled = true; - onboardApp.thumbnail = "test123imgthumbnail"; - onboardApp.username = "test123"; - onboardApp.appPassword = "test123"; - onboardApp.isCentralAuth=true; - onboardApp.myLoginsAppName="test123"; - onboardApp.myLoginsAppOwner="test123"; - onboardApp.nameSpace="com.test"; + onboardApp.setAppName("test1"); + onboardApp.setId(2l); + onboardApp.setLandingPage("http://test.com"); + onboardApp.setRestUrl("http://test.com"); + onboardApp.setIsOpen(false); + onboardApp.setIsEnabled (true); + onboardApp.setThumbnail("test123imgthumbnail"); + onboardApp.setAppBasicAuthUsername("test123"); + onboardApp.setAppBasicAuthPassword("*******"); + onboardApp.setRolesInAAF(true); + onboardApp.setMyLoginsAppName("test123"); + onboardApp.setMyLoginsAppOwner("test123"); + onboardApp.setNameSpace("com.test"); + onboardApp.setModeOfIntegration("sdk"); + onboardApp.setAppAck(true); + onboardApp.setUsesCadi(false); + onboardApp.setApplicationType("1"); List restrictionsList1 = new ArrayList(); - Criterion idCrit = Restrictions.eq("id", onboardApp.id); - Criterion urlCrit = Restrictions.eq("url", onboardApp.url); - Criterion nameCrit = Restrictions.eq("name", onboardApp.name); + Criterion idCrit = Restrictions.eq("id", onboardApp.getId()); + Criterion urlCrit = Restrictions.eq("url", onboardApp.getLandingPage()); + Criterion nameCrit = Restrictions.eq("name", onboardApp.getAppName()); Criterion orCrit = Restrictions.or(idCrit, urlCrit, nameCrit); restrictionsList1.add(orCrit); Mockito.when((List) dataAccessService.getList(EPApp.class, null, restrictionsList1, null)) .thenReturn(mockAppList); - Mockito.when((EPApp) session.get(EPApp.class, onboardApp.id)).thenReturn(mockApp); + Mockito.when((EPApp) session.get(EPApp.class, onboardApp.getId())).thenReturn(mockApp); String sql = "SELECT m.menu_id, m.column_num, m.text, m.parent_menu_id, m.url, m.active_yn " + "FROM fn_menu_functional m, fn_menu_functional_roles r " + "WHERE m.menu_id = r.menu_id " - + " AND r.app_id = '" + onboardApp.id + "' "; + + " AND r.app_id = '" + onboardApp.getId() + "' "; List roles = new ArrayList<>(); roles.add(1); roles.add(2); @@ -1268,8 +1273,8 @@ public class EPAppCommonServiceImplTest { OnboardingApp onboardingApp = new OnboardingApp(); onboardingApp.setRestrictedApp(true); - onboardingApp.isCentralAuth=false; - onboardingApp.isEnabled= true; + onboardingApp.setRolesInAAF(false); + onboardingApp.setIsEnabled(true); FieldsValidator actual = epAppCommonServiceImpl.addOnboardingApp(onboardingApp, epUser); assertEquals(expected.getHttpStatusCode(), actual.getHttpStatusCode()); } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLdapServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLdapServiceImplTest.java index bacd2a9e..3b1c2d2d 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLdapServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLdapServiceImplTest.java @@ -62,6 +62,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalsdk.core.command.support.SearchResult; import org.onap.portalsdk.core.service.support.ServiceLocator; @@ -109,24 +110,24 @@ public class EPLdapServiceImplTest { EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); - app.setCentralAuth(true); + app.setRolesInAAF(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLoginServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLoginServiceImplTest.java index efc23ac3..31973416 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLoginServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPLoginServiceImplTest.java @@ -57,6 +57,7 @@ import org.onap.portalapp.command.EPLoginBean; import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalapp.util.EPUserUtils; @@ -100,24 +101,24 @@ public class EPLoginServiceImplTest { app.setName("Test"); app.setImageUrl("test"); app.setNameSpace("com.test.app"); - app.setCentralAuth(true); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setRolesInAAF(true); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImplTest.java index 0331633c..3b1df407 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImplTest.java @@ -78,6 +78,7 @@ import org.onap.portalapp.portal.domain.EPAppRoleFunction; import org.onap.portalapp.portal.domain.EPRole; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.EPUserApp; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.ecomp.model.UploadRoleFunctionExtSystem; import org.onap.portalapp.portal.exceptions.InactiveApplicationException; import org.onap.portalapp.portal.exceptions.InvalidUserException; @@ -177,24 +178,24 @@ public class ExternalAccessRolesServiceImplTest { app.setName("Test"); app.setImageUrl("test"); app.setNameSpace("com.test.app"); - app.setCentralAuth(true); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setRolesInAAF(true); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 10); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } @@ -325,23 +326,23 @@ public class ExternalAccessRolesServiceImplTest { EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(true); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java index ae813152..bc8d4548 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java @@ -58,6 +58,8 @@ import org.onap.portalapp.portal.domain.MicroserviceData; import org.onap.portalapp.portal.domain.MicroserviceParameter; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.service.DataAccessServiceImpl; import org.onap.portalsdk.core.util.SystemProperties; @@ -66,7 +68,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({Criterion.class, Restrictions.class, CipherUtil.class, EPCommonSystemProperties.class, SystemProperties.class, Restrictions.class}) +@PrepareForTest({Criterion.class, Restrictions.class, CipherUtil.class, EPCommonSystemProperties.class, SystemProperties.class, KeyProperties.class, KeyConstants.class}) public class MicroserviceServiceImplTest { private static final String TEST="test"; @@ -150,6 +152,8 @@ public class MicroserviceServiceImplTest { PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(Restrictions.class); PowerMockito.mockStatic(Criterion.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); List microserviceParameters = new ArrayList<>(); MicroserviceData microserviceData = new MicroserviceData(); MicroserviceParameter microserviceParameter = new MicroserviceParameter(); @@ -168,8 +172,7 @@ public class MicroserviceServiceImplTest { Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l); restrictionsList2.add(serviceIdCriterion); Mockito.when((List) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters); - Mockito.when(CipherUtil.decryptPKC("xyz", - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn("abc"); + Mockito.when(CipherUtil.decryptPKC("xyz",KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn("abc"); List actual = microserviceServiceImpl.getMicroserviceData(); assertNotNull(actual); } @@ -181,6 +184,8 @@ public class MicroserviceServiceImplTest { PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(Restrictions.class); PowerMockito.mockStatic(Criterion.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); List microserviceParameters = new ArrayList<>(); MicroserviceData microserviceData = new MicroserviceData(); MicroserviceParameter microserviceParameter = new MicroserviceParameter(); @@ -199,8 +204,7 @@ public class MicroserviceServiceImplTest { Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l); restrictionsList2.add(serviceIdCriterion); Mockito.when((List) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters); - Mockito.when(CipherUtil.decryptPKC("xyz", - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenThrow(BadPaddingException.class); + Mockito.when(CipherUtil.decryptPKC("xyz",KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenThrow(BadPaddingException.class); List actual = microserviceServiceImpl.getMicroserviceData(); assertNotNull(actual); } @@ -220,10 +224,10 @@ public class MicroserviceServiceImplTest { PowerMockito.mockStatic(CipherUtil.class); Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l); restrictionsList.add(serviceIdCriterion); - PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(TEST); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(TEST); Mockito.when(CipherUtil.encryptPKC(TEST, TEST)).thenReturn(TEST); - Mockito.when((List) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList, null)).thenReturn(microserviceParameters); microserviceServiceImpl.updateMicroservice(1l, buildData()); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PersUserAppServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PersUserAppServiceImplTest.java index e763d6f8..904c7b82 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PersUserAppServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PersUserAppServiceImplTest.java @@ -53,6 +53,7 @@ import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.EPUserApp; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.domain.PersUserAppSelection; import org.onap.portalapp.portal.framework.MockitoTestSuite; import org.onap.portalapp.portal.service.AdminRolesService; @@ -88,23 +89,23 @@ public class PersUserAppServiceImplTest { EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(true); app.setEnabled(false); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java index eeaf29da..a89f87f5 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java @@ -64,6 +64,7 @@ import org.mockito.MockitoAnnotations; import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.transport.FieldsValidator; import org.onap.portalapp.portal.transport.PortalAdmin; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; @@ -127,24 +128,24 @@ public class PortalAdminServiceImplTest { app.setName("Test"); app.setImageUrl("test"); app.setNameSpace("com.test.app"); - app.setCentralAuth(true); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setRolesInAAF(true); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java index 736f8341..5846fa9f 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java @@ -81,6 +81,7 @@ import org.onap.portalapp.portal.domain.EPUserAppCatalogRoles; import org.onap.portalapp.portal.domain.EPUserAppRoles; import org.onap.portalapp.portal.domain.EPUserAppRolesRequest; import org.onap.portalapp.portal.domain.EPUserAppRolesRequestDetail; +import org.onap.portalapp.portal.domain.EpAppType; import org.onap.portalapp.portal.domain.ExternalSystemAccess; import org.onap.portalapp.portal.transport.*; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; @@ -168,24 +169,24 @@ public class UserRolesCommonServiceImplTest { EPApp app = new EPApp(); app.setName("Test"); app.setImageUrl("test"); - app.setDescription("test"); - app.setNotes("test"); - app.setUrl("test"); + app.setAppDescription("test"); + app.setAppNotes("test"); + app.setLandingPage("test"); app.setId((long) 1); app.setAppRestEndpoint("test"); - app.setAlternateUrl("test"); + app.setAlternateLandingPage("test"); app.setName("test"); app.setMlAppName("test"); app.setMlAppAdminId("test"); - app.setUsername("test"); - app.setAppPassword("test"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("test"); app.setOpen(false); app.setEnabled(false); - app.setCentralAuth(true); + app.setRolesInAAF(true); app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.setAppType(1); + app.setAppType(EpAppType.GUI); return app; } @@ -261,7 +262,7 @@ public class UserRolesCommonServiceImplTest { EPUser user = mockUser.mockEPUser(); user.setId(1l); EPApp mockApp = mockApp(); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); EPRole mockEPRole = new EPRole(); mockEPRole.setId(1l); mockEPRole.setName("test1"); @@ -356,7 +357,7 @@ public class UserRolesCommonServiceImplTest { mockEpUserList.add(user); EPApp mockApp = mockApp(); mockApp.setId(2l); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp); List mockRoleInAppForUserList = new ArrayList<>(); RoleInAppForUser mockRoleInAppForUser = new RoleInAppForUser(); @@ -524,7 +525,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setNameSpace("com.test.com"); mockApp.setId(1l); - mockApp.setCentralAuth(true); + mockApp.setRolesInAAF(true); Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp); Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true); AppWithRolesForUser mockWithRolesForUser = new AppWithRolesForUser(); @@ -698,7 +699,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setNameSpace("com.test.com"); mockApp.setId(2l); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp); Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true); AppWithRolesForUser mockWithRolesForUser = new AppWithRolesForUser(); @@ -831,7 +832,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setNameSpace("com.test.com"); mockApp.setId(1l); - mockApp.setCentralAuth(true); + mockApp.setRolesInAAF(true); Mockito.when(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()).thenReturn(true); ExternalSystemUser externalSystemUser = new ExternalSystemUser(); List mockExternalSystemRoleApprovalList = new ArrayList<>(); @@ -999,7 +1000,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); ExternalSystemUser externalSystemUser = new ExternalSystemUser(); List mockExternalSystemRoleApprovalList = new ArrayList<>(); ExternalSystemRoleApproval mockExternalSystemRoleApproval = new ExternalSystemRoleApproval(); @@ -1187,7 +1188,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(1l); mockApp.setEnabled(true); - mockApp.setCentralAuth(true); + mockApp.setRolesInAAF(true); EPUser user = mockUser.mockEPUser(); EPUser user2 = mockUser.mockEPUser(); user2.setActive(true); @@ -1263,7 +1264,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp); List mockUserApplicationRolesNonCentralizedList = new ArrayList<>(); UserApplicationRoles mockUserApplicationRoles = new UserApplicationRoles(); @@ -1318,7 +1319,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); EPUser user = mockUser.mockEPUser(); AppWithRolesForUser appWithRolesForUser = new AppWithRolesForUser(); List mockRoleInAppForUserList = new ArrayList<>(); @@ -1371,7 +1372,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); List expected = new ArrayList<>(); EPRole epRole = new EPRole(); epRole.setAppId(mockApp.getId()); @@ -1400,7 +1401,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); EPUser user = mockUser.mockEPUser(); List expected = new ArrayList<>(); EPUserApp epUserApp = new EPUserApp(); @@ -1426,7 +1427,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); EPUser user = mockUser.mockEPUser(); List expected = new ArrayList<>(); EPUserAppCatalogRoles epUserAppCatalogRoles = new EPUserAppCatalogRoles(); @@ -1458,7 +1459,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); EPUser user = mockUser.mockEPUser(); List expected = new ArrayList<>(); EPUserApp epUserApp = new EPUserApp(); @@ -1488,7 +1489,7 @@ public class UserRolesCommonServiceImplTest { EPApp mockApp2 = mockApp(); mockApp.setId(2l); mockApp.setEnabled(true); - mockApp.setCentralAuth(false); + mockApp.setRolesInAAF(false); EPUser user = mockUser.mockEPUser(); List mockEpAppList = new ArrayList<>(); mockEpAppList.add(mockApp); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java index 708f446a..5cb61b26 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java @@ -82,13 +82,13 @@ public class SessionCommunicationTest { app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.isCentralAuth = true; - app.isEnabled = true; - app.isOpen =false; - app.name = "test"; - app.restUrl ="http://localhost:1234"; - app.username = "test"; - app.appPassword = "xyz"; + app.setRolesInAAF(true); + app.setIsEnabled(true); + app.setIsOpen(false); + app.setAppName("test"); + app.setRestUrl("http://localhost:1234"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("xyz"); URL u = PowerMockito.mock(URL.class); HttpURLConnection huc = PowerMockito.mock(HttpURLConnection.class); String url = "http://localhost:1234/sessionTimeOuts"; @@ -106,16 +106,16 @@ public class SessionCommunicationTest { app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.isCentralAuth = true; - app.isEnabled = true; - app.isOpen =false; - app.name = "test"; - app.restUrl ="http://localhost:1234"; - app.username = "test"; - app.appPassword = ""; + app.setRolesInAAF(true); + app.setIsEnabled(true); + app.setIsOpen(false); + app.setAppName("test"); + app.setRestUrl("http://localhost:1234"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword(""); EPApp epApp = new EPApp(); - epApp.setUsername("test"); - epApp.setAppPassword("xyz1234"); + epApp.setAppBasicAuthUsername("test"); + epApp.setAppBasicAuthPassword("xyz1234"); PowerMockito.mockStatic(CipherUtil.class); PowerMockito.when(CipherUtil.decryptPKC(Matchers.anyString(),Matchers.anyString())).thenReturn("test"); Mockito.when(appsCacheService.getApp(1L)).thenReturn(epApp); @@ -136,13 +136,13 @@ public class SessionCommunicationTest { app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.isCentralAuth = true; - app.isEnabled = true; - app.isOpen =false; - app.name = "test"; - app.restUrl ="http://localhost:1234"; - app.username = "test"; - app.appPassword = "xyz"; + app.setRolesInAAF(true); + app.setIsEnabled(true); + app.setIsOpen(false); + app.setAppName("test"); + app.setRestUrl("http://localhost:1234"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("xyz"); URL u = PowerMockito.mock(URL.class); HttpURLConnection huc = PowerMockito.mock(HttpURLConnection.class); String url = "http://localhost:1234/sessionTimeOuts"; @@ -161,13 +161,13 @@ public class SessionCommunicationTest { app.setUebKey("test"); app.setUebSecret("test"); app.setUebTopicName("test"); - app.isCentralAuth = true; - app.isEnabled = true; - app.isOpen =false; - app.name = "test"; - app.restUrl ="http://localhost:1234"; - app.username = "test"; - app.appPassword = "xyz"; + app.setRolesInAAF(true); + app.setIsEnabled(true); + app.setIsOpen(false); + app.setAppName("test"); + app.setRestUrl("http://localhost:1234"); + app.setAppBasicAuthUsername("test"); + app.setAppBasicAuthPassword("xyz"); URL u = PowerMockito.mock(URL.class); HttpURLConnection huc = PowerMockito.mock(HttpURLConnection.class); String url = "http://localhost:1234/sessionTimeOuts"; diff --git a/ecomp-portal-BE-os/pom.xml b/ecomp-portal-BE-os/pom.xml index 4ad50dfd..4bc54036 100644 --- a/ecomp-portal-BE-os/pom.xml +++ b/ecomp-portal-BE-os/pom.xml @@ -5,7 +5,7 @@ org.onap.portal onap-portal-parent - 3.3.0 + 3.4.0 portal-be-os @@ -251,21 +251,7 @@ spring-test ${springframework.version} - - org.springframework.boot - spring-boot-starter - 1.3.0.RELEASE - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - - + org.hibernate @@ -314,27 +300,8 @@ tiles-jsp 3.0.5 - - org.apache.cxf - cxf-rt-rs-client - 3.0.0-milestone1 - - - com.fasterxml.jackson.core - jackson-annotations - 2.8.10 - - - com.fasterxml.jackson.core - jackson-core - 2.8.10 - - - com.fasterxml.jackson.core - jackson-databind - 2.8.10 - + com.fasterxml classmate @@ -629,11 +596,6 @@ 1.8.5 test - - commons-beanutils - commons-beanutils - 1.9.3 - org.mitre diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ECOMPLogoutController.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ECOMPLogoutController.java index 54fcf3af..eaf3a133 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ECOMPLogoutController.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ECOMPLogoutController.java @@ -52,7 +52,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.servlet.ModelAndView; @@ -69,7 +69,7 @@ public class ECOMPLogoutController extends EPUnRestrictedBaseController { EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECOMPLogoutController.class); @EPAuditLog - @RequestMapping(value = { "/logout.htm" }, method = RequestMethod.GET) + @GetMapping(value = { "/logout.htm" }) public ModelAndView logOut(HttpServletRequest request, HttpServletResponse response) throws Exception { diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/AppsOSController.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/AppsOSController.java index 1715864a..a64b0299 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/AppsOSController.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/AppsOSController.java @@ -39,12 +39,7 @@ package org.onap.portalapp.portal.controller; import java.util.HashMap; import java.util.Map; -import java.util.Set; import javax.servlet.http.HttpServletRequest; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; import org.json.JSONObject; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java index 028ae68a..9a2d3389 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/ExternalAppsRestfulController.java @@ -9,7 +9,7 @@ * 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 @@ -44,7 +44,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onap.portalapp.controller.EPRestrictedRESTfulBaseController; -import org.onap.portalapp.portal.controller.ExternalAppsRestfulController; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.logging.aop.EPAuditLog; import org.onap.portalapp.portal.service.AdminRolesService; @@ -63,7 +62,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -84,7 +83,7 @@ public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseContro @Autowired AdminRolesService adminRolesService; - @RequestMapping(value={"/getFavorites"}, method = RequestMethod.GET,produces = "application/json") + @GetMapping(value={"/getFavorites"}, produces = "application/json") public List getFavoritesForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { String loginId = ""; String userAgent = ""; @@ -109,7 +108,7 @@ public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseContro return favorites; } - @RequestMapping(value={"/functionalMenuItemsForUser"}, method = RequestMethod.GET,produces = "application/json") + @GetMapping(value={"/functionalMenuItemsForUser"}, produces = "application/json") public List getFunctionalMenuItemsForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { String loginId = ""; String userAgent = ""; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/interceptor/SessionTimeoutInterceptor.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/interceptor/SessionTimeoutInterceptor.java index 689b25f2..8a3bee62 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/interceptor/SessionTimeoutInterceptor.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/interceptor/SessionTimeoutInterceptor.java @@ -42,7 +42,6 @@ import javax.servlet.http.HttpServletResponse; import org.onap.portalapp.authentication.LoginStrategy; import org.onap.portalapp.portal.domain.EPUser; -import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalapp.util.EPUserUtils; import org.onap.portalapp.util.SessionCookieUtil; import org.onap.portalsdk.core.controller.FusionBaseController; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAspect.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAspect.java index 9cd18453..000e48ef 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAspect.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAspect.java @@ -41,11 +41,7 @@ import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; -import org.onap.portalapp.portal.logging.aop.EPAuditLog; -import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice; -import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.transport.FieldsValidator; -import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum; import org.springframework.beans.factory.annotation.Autowired; 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 0e9932e0..479564f5 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 @@ -113,7 +113,7 @@ public class SearchServiceImpl implements SearchService { resultOfSearch.addAll(resultOfAdditionalSearch); } resultOfSearch.addAll(resultOfSearchUserId); - resultOfSearch.stream().distinct().collect(Collectors.toList()); + resultOfSearch = resultOfSearch.stream().distinct().collect(Collectors.toList()); resultOfSearch = this.cutSearchResultToMaximumSize(resultOfSearch); ObjectMapper mapper = new ObjectMapper(); String result = "[]"; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/TicketEventServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/TicketEventServiceImpl.java index 71c2b1ea..e92b7120 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/TicketEventServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/TicketEventServiceImpl.java @@ -39,7 +39,6 @@ */ package org.onap.portalapp.portal.service; -import org.onap.portalapp.portal.service.TicketEventService; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.stereotype.Service; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/utils/EPSystemProperties.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/utils/EPSystemProperties.java index 1e0f5836..45b3a2c9 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/utils/EPSystemProperties.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/utils/EPSystemProperties.java @@ -10,7 +10,7 @@ * 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, @@ -37,7 +37,6 @@ */ package org.onap.portalapp.portal.utils; -import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySources; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/service/RemoteWebServiceCallServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/service/RemoteWebServiceCallServiceImpl.java index a24a6b4c..c0f944e9 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/service/RemoteWebServiceCallServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/service/RemoteWebServiceCallServiceImpl.java @@ -38,13 +38,12 @@ package org.onap.portalapp.service; import java.util.List; - import org.onap.portalapp.portal.domain.EPApp; -import org.onap.portalapp.service.RemoteWebServiceCallService; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.WebServiceCallServiceImpl; -import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -68,11 +67,10 @@ public class RemoteWebServiceCallServiceImpl extends WebServiceCallServiceImpl i logger.warn(EELFLoggerDelegate.errorLogger, "Failed to find application with UEB key " + requestUebKey); return false; } - - String encryptedPwdDB = appRecord.getAppPassword(); - String appUserName = appRecord.getUsername(); - String decryptedPwd = CipherUtil.decryptPKC(encryptedPwdDB, - secretKey == null ? SystemProperties.getProperty(SystemProperties.Decryption_Key) : secretKey); + + String encryptedPwdDB = appRecord.getAppBasicAuthPassword(); + String appUserName = appRecord.getAppBasicAuthUsername(); + String decryptedPwd = CipherUtil.decryptPKC(encryptedPwdDB,secretKey == null ? KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY) : secretKey); if (decryptedPwd.equals(requestPassword) && appUserName.equals(requestAppName)) return true; else diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/util/SessionCookieUtil.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/util/SessionCookieUtil.java index c00533b6..05765021 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/util/SessionCookieUtil.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/util/SessionCookieUtil.java @@ -40,15 +40,11 @@ package org.onap.portalapp.util; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; 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.onap.portalsdk.core.web.support.AppUtils; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; public class SessionCookieUtil extends CommonSessionCookieUtil{ @@ -77,7 +73,7 @@ public class SessionCookieUtil extends CommonSessionCookieUtil{ HttpServletResponse response,String userId) throws Exception { logger.info("************** session cookie util set up UserId cookie begins"); userId = CipherUtil.encrypt(userId, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); Cookie cookie1 = new Cookie(USER_ID, userId); cookie1.setSecure(true); cookie1.setMaxAge(cookieMaxAge); @@ -98,7 +94,7 @@ public class SessionCookieUtil extends CommonSessionCookieUtil{ userIdcookie = cookie; if(userIdcookie!=null){ userId = CipherUtil.decrypt(userIdcookie.getValue(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } logger.info("************** session cookie util set up EP cookie completed"); diff --git a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties index 041458d3..a3aa565f 100644 --- a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties +++ b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties @@ -40,7 +40,7 @@ db.driver = org.mariadb.jdbc.Driver #db.connectionURL = jdbc:mariadb:failover://localhost:3306/ecomp_portal #db.userName = XXXX #db.password = XXXX -db.connectionURL = jdbc:mariadb:failover://localhost:3306/portal_2_6_os +db.connectionURL = jdbc:mariadb:failover://localhost:3306/portal_3_2_os db.userName = root db.password = root # is the db.password property encrypted? @@ -145,13 +145,13 @@ window_width_threshold_right_menu = 1350 external_system_notification_url= https://jira.onap.org/browse/ # External Access System Basic Auth Credentials & Rest endpoint(These credentials doesn't work as these are place holders for now) -ext_central_access_user_name = m00468@portal.onap.org -ext_central_access_password = dR2NABMkxPaFbIbym87ZwQ== -ext_central_access_url = https://aaftest.test.onap.org:8095/proxy/authz/ +ext_central_access_user_name = aaf_admin@people.osaaf.org +ext_central_access_password = CkmGguWw+Yn0yzqximmSExkOSJ7BdKvOTHFmTMg9Yvc= +ext_central_access_url = https://aaf-service:31110/authz/ ext_central_access_user_domain = @csp.onap.org # External Central Auth system access -remote_centralized_system_access = false +remote_centralized_system_access = true #left menu with root value or non-root portal_left_menu = non-root \ No newline at end of file diff --git a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java index 88ccf5d1..1f346459 100644 --- a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java @@ -57,6 +57,8 @@ import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.framework.MockitoTestSuite; import org.onap.portalapp.service.RemoteWebServiceCallServiceImpl; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; @@ -64,7 +66,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({ CipherUtil.class , SystemProperties.class}) +@PrepareForTest({ CipherUtil.class , SystemProperties.class, KeyProperties.class, KeyConstants.class}) public class RemoteWebServiceCallServiceImplTest { @@ -93,17 +95,17 @@ public class RemoteWebServiceCallServiceImplTest { public void verifyRESTCredentialTest() throws Exception { PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); + app.setAppBasicAuthPassword("password"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList); String secretKey = null; - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); - Mockito.when(CipherUtil.decryptPKC("password", - secretKey == null ? null : secretKey)).thenReturn("pwd"); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); + Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd"); assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","requestPassword")); } @@ -111,18 +113,18 @@ public class RemoteWebServiceCallServiceImplTest { public void verifyRESTCredentialExceptionTest() throws Exception { PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList); String secretKey = null; - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); - Mockito.when(CipherUtil.decryptPKC("password", - secretKey == null ? null : secretKey)).thenReturn("pwd"); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); + Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd"); assertTrue(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd")); } @@ -131,17 +133,18 @@ public class RemoteWebServiceCallServiceImplTest { { PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null); String secretKey = null; - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); - Mockito.when(CipherUtil.decryptPKC("password", - secretKey == null ? null : secretKey)).thenReturn("pwd"); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); + Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd"); assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd")); } @@ -160,8 +163,8 @@ public class RemoteWebServiceCallServiceImplTest { // String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null); assertFalse(remoteWebServiceCallServiceImpl.verifyAppKeyCredential("test")); @@ -175,8 +178,8 @@ public class RemoteWebServiceCallServiceImplTest { String criteria= " where ueb_key = 'test'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList); assertTrue(remoteWebServiceCallServiceImpl.verifyAppKeyCredential("test")); diff --git a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/scheduler/SessionMgtRegistryTest.java b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/scheduler/SessionMgtRegistryTest.java new file mode 100644 index 00000000..dcd5881b --- /dev/null +++ b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/scheduler/SessionMgtRegistryTest.java @@ -0,0 +1,60 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : Portal + * ================================================================================ + * Copyright (C) 2020 IBM 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. + * 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. + * ============LICENSE_END========================================================= + */ +package org.onap.portalapp.scheduler; + +import static org.junit.Assert.assertNotNull; +import java.text.ParseException; +import java.util.HashMap; +import java.util.Map; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.portalapp.service.sessionmgt.TimeoutHandler; +import org.springframework.scheduling.quartz.JobDetailFactoryBean; + +public class SessionMgtRegistryTest { + + @Mock + JobDetailFactoryBean job; + @Mock + TimeoutHandler lj; + @InjectMocks + SessionMgtRegistry lr; + + String groupName = "AppGroup"; + String jobName = "LogJob"; + @Before + public void initialize(){ + MockitoAnnotations.initMocks(this); + } + @Test + public void jobDetailFactoryBeantest() throws ParseException{ + + Map map = new HashMap(); + map.put("units", "bytes"); + job.setJobClass(TimeoutHandler.class); + job.setJobDataAsMap(map); + job.setGroup(groupName); + job.setName(jobName); + assertNotNull(lr.jobDetailFactoryBean()); + } +} diff --git a/ecomp-portal-FE-os/pom.xml b/ecomp-portal-FE-os/pom.xml index 735ce79e..29154e82 100644 --- a/ecomp-portal-FE-os/pom.xml +++ b/ecomp-portal-FE-os/pom.xml @@ -5,7 +5,7 @@ org.onap.portal onap-portal-parent - 3.3.0 + 3.4.0 portal-FE-os diff --git a/ecomp-portal-widget-ms/common-widgets/pom.xml b/ecomp-portal-widget-ms/common-widgets/pom.xml index 2fdc2f82..7844390a 100644 --- a/ecomp-portal-widget-ms/common-widgets/pom.xml +++ b/ecomp-portal-widget-ms/common-widgets/pom.xml @@ -6,7 +6,7 @@ org.onap.portal widget-ms-parent - 3.3.0 + 3.4.0 common-widgets diff --git a/ecomp-portal-widget-ms/pom.xml b/ecomp-portal-widget-ms/pom.xml index 553535d5..913ac445 100644 --- a/ecomp-portal-widget-ms/pom.xml +++ b/ecomp-portal-widget-ms/pom.xml @@ -6,7 +6,7 @@ org.onap.portal onap-portal-parent - 3.3.0 + 3.4.0 widget-ms-parent diff --git a/ecomp-portal-widget-ms/widget-ms/pom.xml b/ecomp-portal-widget-ms/widget-ms/pom.xml index 4095388c..50a285c2 100644 --- a/ecomp-portal-widget-ms/widget-ms/pom.xml +++ b/ecomp-portal-widget-ms/widget-ms/pom.xml @@ -7,13 +7,13 @@ org.springframework.boot spring-boot-starter-parent - 1.5.11.RELEASE + 2.2.5.RELEASE org.onap.portal widget-ms - 3.3.0 + 3.4.0 jar widget-microservice @@ -22,10 +22,10 @@ UTF-8 UTF-8 1.8 - 4.3.11.Final + 5.4.14.Final false - 0.7.6.201602180812 + 0.8.2 @@ -68,7 +68,7 @@ org.hibernate hibernate-core - + ${hibernate.version} org.springframework.boot @@ -96,7 +96,7 @@ com.github.ulisesbocchio jasypt-spring-boot-starter - 1.9 + 2.1.0 org.jsoup @@ -109,7 +109,7 @@ dom4j dom4j - + 1.6.1 jaxme @@ -151,7 +151,7 @@ org.apache.tomcat.embed tomcat-embed-core - 8.5.28 + 9.0.33 ch.qos.logback @@ -181,7 +181,7 @@ org.springframework.security spring-security-web - 4.2.13.RELEASE + 5.2.3.RELEASE org.projectlombok diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/DatabaseFileUploadController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/DatabaseFileUploadController.java index acdde23b..dc8cb20d 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/DatabaseFileUploadController.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/DatabaseFileUploadController.java @@ -11,8 +11,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -24,7 +23,7 @@ public class DatabaseFileUploadController { private static final Logger logger = LoggerFactory.getLogger(DatabaseFileUploadController.class); @ResponseBody - @RequestMapping(value = "/microservices/markup/{widgetId}", method = RequestMethod.GET) + @GetMapping(value = "/microservices/markup/{widgetId}") public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){ String markup = null; try{ @@ -37,7 +36,7 @@ public class DatabaseFileUploadController { } @ResponseBody - @RequestMapping(value = "/microservices/{widgetId}/controller.js", method = RequestMethod.GET) + @GetMapping(value = "/microservices/{widgetId}/controller.js") public String getWidgetController(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){ String controller = null; try{ @@ -50,7 +49,7 @@ public class DatabaseFileUploadController { } @ResponseBody - @RequestMapping(value = "/microservices/{widgetId}/framework.js", method = RequestMethod.GET) + @GetMapping(value = "/microservices/{widgetId}/framework.js") public String getWidgetFramework(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){ String framework = null; @@ -64,7 +63,7 @@ public class DatabaseFileUploadController { } @ResponseBody - @RequestMapping(value = "/microservices/{widgetId}/styles.css", method = RequestMethod.GET) + @GetMapping(value = "/microservices/{widgetId}/styles.css") public String getWidgetCSS(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){ String css = null; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/HealthController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/HealthController.java index 6814f75a..1eb2c966 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/HealthController.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/HealthController.java @@ -3,14 +3,13 @@ package org.onap.portalapp.widget.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; - + @RestController public class HealthController { - @RequestMapping(value = { "/health" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/health" }, produces = "application/json") public HealthStatus getWidgetCatalog(HttpServletRequest request, HttpServletResponse response) { return new HealthStatus("ok"); } diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java index b1450b6d..1896a4f8 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java @@ -4,7 +4,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onap.portalapp.widget.domain.ValidationRespond; @@ -21,8 +21,10 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.client.RestTemplate; @@ -37,12 +39,12 @@ public class WidgetsCatalogController { @Value("${server.port}") String port; - @Value("${server.contextPath}") + @Value("${server.servlet.context-path}") String context; - @Value("${security.user.name}") + @Value("${spring.security.user.name}") String security_user; - @Value("${security.user.password}") + @Value("${spring.security.user.password}") String security_pass; @Autowired @@ -59,7 +61,7 @@ public class WidgetsCatalogController { private static final Logger logger = LoggerFactory.getLogger(WidgetsCatalogController.class); @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/microservices/widgetCatalog" }, produces = "application/json") public List getWidgetCatalog(HttpServletRequest request, HttpServletResponse response ,@RequestHeader(value="Authorization") String auth) throws IOException{ @@ -79,7 +81,7 @@ public class WidgetsCatalogController { } @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{loginName}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/microservices/widgetCatalog/{loginName}" }, produces = "application/json") public List getUserWidgetCatalog(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginName") String loginName, @RequestHeader(value="Authorization") String auth) throws IOException { List widgetCatalog = null; @@ -98,7 +100,7 @@ public class WidgetsCatalogController { } @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, produces = "application/json") public void updateWidgetCatalog(HttpServletRequest request, HttpServletResponse response, @RequestBody WidgetCatalog newWidgetCatalog, @PathVariable("widgetId") long widgetId, @RequestHeader(value="Authorization") String auth) throws IOException { @@ -117,7 +119,7 @@ public class WidgetsCatalogController { } @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/microservices/widgetCatalog" }, produces = "application/json") public ValidationRespond saveWidgetCatalog(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value="Authorization") String auth, @RequestParam("file") MultipartFile file, @RequestParam("widget") String widget) throws IOException { @@ -148,7 +150,7 @@ public class WidgetsCatalogController { } @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, produces = "application/json") public ValidationRespond updateWidgetCatalogwithFiles(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value="Authorization") String auth, @RequestParam("file") MultipartFile file, @RequestParam("widget") String widget, @PathVariable("widgetId") long widgetId) throws IOException { logger.debug("microserivces updating with files {}", widgetId); @@ -176,8 +178,7 @@ public class WidgetsCatalogController { } @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, method = { - RequestMethod.DELETE }, produces = "application/json") + @DeleteMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, produces = "application/json") public void deleteOnboardingWidget(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId, @RequestHeader(value="Authorization") String auth) throws IOException{ if(!util.authorization(auth, security_user, security_pass)){ @@ -196,7 +197,7 @@ public class WidgetsCatalogController { } @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/parameters/{widgetId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/microservices/widgetCatalog/parameters/{widgetId}" }, produces = "application/json") public Long getServiceIdByWidget(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") Long widgetId, @RequestHeader(value="Authorization") String auth) throws IOException { @@ -217,7 +218,7 @@ public class WidgetsCatalogController { @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/service/{serviceId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/microservices/widgetCatalog/service/{serviceId}" }, produces = "application/json") public List getWidgetByServiceId(HttpServletRequest request, HttpServletResponse response, @PathVariable("serviceId") Long serviceId, @RequestHeader(value="Authorization") String auth) throws IOException { List list = new ArrayList<>(); @@ -237,7 +238,7 @@ public class WidgetsCatalogController { @ResponseBody - @RequestMapping(value = { "/microservices/download/{widgetId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/microservices/download/{widgetId}" }, produces = "application/json") public byte[] getWidgetZipFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId, @RequestHeader(value="Authorization") String auth) throws Exception { byte[] byteFile = null; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java index 212826cd..46ee814c 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java @@ -21,7 +21,7 @@ public class App implements Serializable{ @Id @Column(name = "APP_ID") - @GeneratedValue(strategy=GenerationType.AUTO) + @GeneratedValue(strategy=GenerationType.IDENTITY) @Digits(integer = 11, fraction = 0) private Long appId; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java index 43e7b2b0..2ed49ab4 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java @@ -26,7 +26,7 @@ public class MicroserviceData { @Id @Column(name = "id") @Digits(integer = 11, fraction = 0) - @GeneratedValue(strategy=GenerationType.AUTO) + @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @Column(name = "name") diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java index 7207d0ae..cd9236da 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java @@ -24,7 +24,7 @@ public class MicroserviceParameter { @Id @Column(name = "id") - @GeneratedValue(strategy=GenerationType.AUTO) + @GeneratedValue(strategy=GenerationType.IDENTITY) @Digits(integer = 11, fraction = 0) private Long id; 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 aae9bfed..173a1430 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 @@ -33,7 +33,7 @@ public class RoleApp implements Serializable{ @Id @Column(name = "ROLE_ID") - @GeneratedValue(strategy=GenerationType.AUTO) + @GeneratedValue(strategy=GenerationType.IDENTITY) @Digits(integer = 11, fraction = 0) private Long roleId; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java index 1dc0582c..a822c5a2 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java @@ -30,7 +30,7 @@ public class WidgetCatalog{ @Id @Column(name = "widget_id") - @GeneratedValue(strategy=GenerationType.AUTO) + @GeneratedValue(strategy=GenerationType.IDENTITY) @Digits(integer = 11, fraction = 0) private long id; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java index b52631f1..ac25077b 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java @@ -6,7 +6,7 @@ import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; -import org.springframework.orm.hibernate4.LocalSessionFactoryBean; +import org.springframework.orm.hibernate5.LocalSessionFactoryBean; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.transaction.PlatformTransactionManager; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java index fed70ad9..a02667de 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java @@ -41,7 +41,7 @@ public class MicroserviceServiceImpl implements MicroserviceService{ Transaction tx = session.beginTransaction(); session.save(newService); tx.commit(); - session.flush(); +// session.flush(); session.close(); } catch(Exception e){ @@ -58,7 +58,7 @@ public class MicroserviceServiceImpl implements MicroserviceService{ Transaction tx = session.beginTransaction(); session.save(newParameter); tx.commit(); - session.flush(); +// session.flush(); session.close(); } catch(Exception e){ @@ -77,7 +77,7 @@ public class MicroserviceServiceImpl implements MicroserviceService{ List services = criteria.list(); logger.debug("MicroserviceServiceImpl.getMicroserviceByName: result={}", services); - session.flush(); +// session.flush(); session.close(); return (services.size() > 0) ? services.get(0).getId() : null; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java index 59180d37..f5558e2e 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java @@ -191,7 +191,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { Transaction tx = session.beginTransaction(); session.save(newWidgetCatalog); tx.commit(); - session.flush(); + //session.flush(); session.close(); updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles()); } @@ -217,7 +217,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { Transaction tx = session.beginTransaction(); session.update(newWidgetCatalog); tx.commit(); - session.flush(); + //session.flush(); session.close(); updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles()); }catch(Exception e){ @@ -268,7 +268,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { List widgets = criteria.list(); logger.debug("WidgetCatalogServiceImpl.getWidgetIdByName: result={}", widgets); - session.flush(); +// session.flush(); session.close(); return (widgets.size() > 0) ? true : false; diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties b/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties index 42483b7f..82b26d6e 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties +++ b/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties @@ -1,22 +1,22 @@ ## General App Properties -server.contextPath=/widget +server.servlet.context-path=/widget server.port=9082 -spring.http.multipart.max-file-size=128MB -spring.http.multipart.max-request-size=128MB +spring.servlet.multipart.max-file-size=128MB +spring.servlet.multipart.max-request-size=128MB microservice.widget.location=/tmp ## App DB Properties spring.datasource.url=jdbc:mariadb://localhost:3306/portal spring.datasource.username=root -spring.datasource.password=root +spring.datasource.password=welcome2ibm spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect spring.database.driver.classname=org.mariadb.jdbc.Driver spring.jpa.show-sql=false spring.jpa.properties.hibernate.format_sql=false ## Basic Authentication Properties -security.user.name=widget_user -security.user.password=ENC(IjywcRnI9+nuVEh9+OFFiRWAjBT1n718) +spring.security.user.name=widget_user +spring.security.user.password=ENC(IjywcRnI9+nuVEh9+OFFiRWAjBT1n718) account.user.name=portal account.user.password=6APqvG4AU2rfLgCvMdySwQ== diff --git a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java index 933710d2..2d1fd273 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java +++ b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java @@ -59,6 +59,7 @@ import org.mockito.MockitoAnnotations; import org.onap.portalapp.widget.domain.App; import org.onap.portalapp.widget.domain.RoleApp; import org.onap.portalapp.widget.domain.WidgetCatalog; +import org.hibernate.query.NativeQuery; public class WidgetCatalogServiceImplTest { @@ -75,7 +76,7 @@ public class WidgetCatalogServiceImplTest { Criteria criteria; @Mock - SQLQuery query; + NativeQuery query; @Before public void init() { diff --git a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java index d3dc1cbf..0d01ee50 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java +++ b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java @@ -134,7 +134,7 @@ public class WidgetsCatalogControllerTest { List list = new ArrayList(); WidgetCatalog widget = new WidgetCatalog(); list.add(widget); - Mockito.when(widgetService.getWidgetCatalog()).thenReturn(list); + Mockito.lenient().when(widgetService.getWidgetCatalog()).thenReturn(list); mockMvc.perform(get("/microservices/widgetCatalog/")) .andExpect(status().isBadRequest()); @@ -148,7 +148,7 @@ public class WidgetsCatalogControllerTest { widget.setId(1); widget.setName("junit"); list.add(widget); - Mockito.when(widgetService.getUserWidgetCatalog("test")).thenReturn(list); + Mockito.lenient().when(widgetService.getUserWidgetCatalog("test")).thenReturn(list); String security_user = "user"; String security_pass = "password"; @@ -170,7 +170,7 @@ public class WidgetsCatalogControllerTest { widget.setId(1); widget.setName("junit"); list.add(widget); - Mockito.when(widgetService.getUserWidgetCatalog("test")).thenReturn(list); + Mockito.lenient().when(widgetService.getUserWidgetCatalog("test")).thenReturn(list); String security_user = "user"; String security_pass = "password"; @@ -190,7 +190,7 @@ public class WidgetsCatalogControllerTest { @Test public void saveWidgetCatalog_ValidAuthorization_NoError() throws Exception { ValidationRespond respond = new ValidationRespond(true, null); - Mockito.when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond); + Mockito.lenient().when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond); String security_user = "user"; String security_pass = "password"; @@ -211,7 +211,7 @@ public class WidgetsCatalogControllerTest { @Test public void saveWidgetCatalog_Authorization_Error() throws Exception { ValidationRespond respond = new ValidationRespond(true, null); - Mockito.when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond); + Mockito.lenient().when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond); String security_user = "user"; String security_pass = "password"; @@ -270,7 +270,7 @@ public class WidgetsCatalogControllerTest { @Test public void updateWidgetCatalogwithFiles_ValidAuthorization_NoError() throws Exception { ValidationRespond respond = new ValidationRespond(true, null); - Mockito.when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond); + Mockito.lenient().when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond); String security_user = "user"; String security_pass = "password"; @@ -420,7 +420,7 @@ public class WidgetsCatalogControllerTest { widget.setId(1); widget.setName("junit"); list.add(widget); - Mockito.when(widgetService.getWidgetsByServiceId(serviceId)).thenReturn(list); + Mockito.lenient().when(widgetService.getWidgetsByServiceId(serviceId)).thenReturn(list); String security_user = "user"; String security_pass = "password"; @@ -462,7 +462,7 @@ public class WidgetsCatalogControllerTest { String wrong_pass = "wrong"; Long widgetId = new Long(1); byte[] bytes="Test".getBytes(); - Mockito.when(storageService.getWidgetCatalogContent(widgetId)).thenReturn(bytes); + Mockito.lenient().when(storageService.getWidgetCatalogContent(widgetId)).thenReturn(bytes); ReflectionTestUtils.setField(controller, "security_user", security_user, String.class); ReflectionTestUtils.setField(controller, "security_pass", security_pass, String.class); diff --git a/pom.xml b/pom.xml index 19d8c34e..e4ccbdef 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.onap.portal onap-portal-parent - 3.3.0 + 3.4.0 pom portal @@ -28,19 +28,20 @@ 0 - 2.6.0 + 3.3.0-SNAPSHOT 4.3.24.RELEASE 4.2.13.RELEASE 4.3.11.Final 2.8.11.4 - 0.7.6.201602180812 + 0.8.1 UTF-8 UTF-8 **/test/**/*,**/tests/**/* false true + false - +
+ {{browserCompatibilityMsg}} +
diff --git a/portal-FE-os/src/app/app.component.scss b/portal-FE-os/src/app/app.component.scss index 7a773398..e739496d 100644 --- a/portal-FE-os/src/app/app.component.scss +++ b/portal-FE-os/src/app/app.component.scss @@ -34,4 +34,14 @@ * ============LICENSE_END============================================ * * - */ \ No newline at end of file + */ + + .diaplay-banner{ + margin-top: 14px; + background-color: yellow; + font-weight: bold; + position: fixed; + z-index: 9999; + margin-left: 34em; + height: 24px; +} \ No newline at end of file diff --git a/portal-FE-os/src/app/app.component.ts b/portal-FE-os/src/app/app.component.ts index dbfb568f..389153bd 100644 --- a/portal-FE-os/src/app/app.component.ts +++ b/portal-FE-os/src/app/app.component.ts @@ -35,13 +35,49 @@ * * */ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) -export class AppComponent { - -} +export class AppComponent implements OnInit { + diaplayBanner : boolean = false; + api = environment.api; + browserCompatibilityMsg: string; + + ngOnInit() { + this.diaplayBanner = false; + this.browserCompatibilityMsg = this.api.browserCompatibilityMsg; + this.getBrowserName(); + } + + /** + * Identify Browser + */ + getBrowserName() { + const agent = window.navigator.userAgent.toLowerCase(); + switch (true) { + case agent.indexOf('edge') > -1: + return 'edge'; + case agent.indexOf('opr') > -1 && !!(window).opr: + this.diaplayBanner = true; + return 'opera'; + case agent.indexOf('chrome') > -1 && !!(window).chrome: + return 'chrome'; + case agent.indexOf('trident') > -1: + this.diaplayBanner = true; + return 'ie'; + case agent.indexOf('firefox') > -1: + return 'firefox'; + case agent.indexOf('safari') > -1: + this.diaplayBanner = true; + return 'safari'; + default: + this.diaplayBanner = true; + return 'other'; + } + } +} \ No newline at end of file diff --git a/portal-FE-common/src/app/layout/components/search-users/search-users.component.html b/portal-FE-os/src/app/layout/components/search-users/search-users.component.html similarity index 94% rename from portal-FE-common/src/app/layout/components/search-users/search-users.component.html rename to portal-FE-os/src/app/layout/components/search-users/search-users.component.html index 03624491..4c318f9f 100644 --- a/portal-FE-common/src/app/layout/components/search-users/search-users.component.html +++ b/portal-FE-os/src/app/layout/components/search-users/search-users.component.html @@ -67,4 +67,7 @@ + +
+

{{message}} Or Click Here to add New User!

\ No newline at end of file diff --git a/portal-FE-common/src/app/layout/components/search-users/search-users.component.scss b/portal-FE-os/src/app/layout/components/search-users/search-users.component.scss similarity index 100% rename from portal-FE-common/src/app/layout/components/search-users/search-users.component.scss rename to portal-FE-os/src/app/layout/components/search-users/search-users.component.scss diff --git a/portal-FE-common/src/app/layout/components/search-users/search-users.component.spec.ts b/portal-FE-os/src/app/layout/components/search-users/search-users.component.spec.ts similarity index 100% rename from portal-FE-common/src/app/layout/components/search-users/search-users.component.spec.ts rename to portal-FE-os/src/app/layout/components/search-users/search-users.component.spec.ts diff --git a/portal-FE-common/src/app/layout/components/search-users/search-users.component.ts b/portal-FE-os/src/app/layout/components/search-users/search-users.component.ts similarity index 91% rename from portal-FE-common/src/app/layout/components/search-users/search-users.component.ts rename to portal-FE-os/src/app/layout/components/search-users/search-users.component.ts index b93ffd61..10e4e041 100644 --- a/portal-FE-common/src/app/layout/components/search-users/search-users.component.ts +++ b/portal-FE-os/src/app/layout/components/search-users/search-users.component.ts @@ -56,6 +56,7 @@ export class SearchUsersComponent implements OnInit { @ViewChild(MatSort) sort: MatSort; @ViewChild(MatPaginator) paginator: MatPaginator; @Output() passBackSelectedUser: EventEmitter = new EventEmitter(); + @Output() userNotFoundFlag = new EventEmitter(); searchString: string; txtResults = 'result'; searchUsersResults: any; @@ -65,6 +66,8 @@ export class SearchUsersComponent implements OnInit { selectedUser: any; displayedColumns: string[] = ['firstName']; dataSourceMap = new MatTableDataSource(this.searchUsersResults); + submitted = false; + message = " No users found with your query. Please change your search and try again."; ngOnInit() { this.searchString = ''; @@ -77,6 +80,7 @@ export class SearchUsersComponent implements OnInit { this.passBackSelectedUser.emit(systemUser); } + noUserFlag: boolean = false; searchUsers() { if (!this.isSystemUser) { this.isLoading = true; @@ -85,11 +89,10 @@ export class SearchUsersComponent implements OnInit { this.userService.searchUsers(this.searchString).subscribe((_data: PortalAdmin) => { this.searchUsersResults = _data; if (this.searchUsersResults == null || this.searchUsersResults.length == 0) { - const modelRef = this.ngModal.open(ConfirmationModalComponent) - modelRef.componentInstance.title = "Confirmation"; - modelRef.componentInstance.message = " No users found with your query. Please change your search and try again." + this.noUserFlag = true; this.isLoading = false; } else { + this.noUserFlag = false; this.showUserTable = true; this.isLoading = false; this.dataSourceMap = new MatTableDataSource(this.searchUsersResults); @@ -104,4 +107,9 @@ export class SearchUsersComponent implements OnInit { this.passBackSelectedUser.emit(this.selectedUser); } + addNewUser() { + console.log("Emit the value to parent"); + this.userNotFoundFlag.emit(true); + } + } diff --git a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html index 7fc35e44..bd9d69b6 100644 --- a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html +++ b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html @@ -113,6 +113,6 @@ diff --git a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts index bea0fcdb..33d2b331 100644 --- a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts +++ b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts @@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MustMatch } from 'src/app/shared/helpers/must-match-validator'; import { UsersService } from 'src/app/shared/services'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; @Component({ selector: 'app-user-details-form', @@ -13,9 +14,10 @@ export class UserDetailsFormComponent implements OnInit { addNewUserForm: FormGroup; submitted = false; - constructor(private formBuilder: FormBuilder, + constructor(private formBuilder: FormBuilder, private usersService: UsersService, - public activeModal: NgbActiveModal) { } + public activeModal: NgbActiveModal, + public ngbModal: NgbModal) { } ngOnInit() { this.addNewUserForm = this.formBuilder.group({ @@ -24,7 +26,7 @@ export class UserDetailsFormComponent implements OnInit { lastName: ['', Validators.required], email: ['', [Validators.required, Validators.email]], loginId: ['', Validators.required], - loginPwd: ['', [Validators.required, Validators.minLength(6)]], + loginPwd: ['', Validators.required], confirmPassword: ['', Validators.required] }, { validator: MustMatch('loginPwd', 'confirmPassword') @@ -44,7 +46,17 @@ export class UserDetailsFormComponent implements OnInit { console.log("New user Json : " + JSON.stringify(this.addNewUserForm.value)); console.log("Get Raw value : " + this.addNewUserForm.getRawValue()); let newUserFormData = JSON.stringify(this.addNewUserForm.getRawValue()); - this.usersService.addNewUser(newUserFormData); + this.usersService.addNewUser(newUserFormData).subscribe(result => { + console.log("Result : ", result); + const modalSuccess = this.ngbModal.open(ConfirmationModalComponent); + modalSuccess.componentInstance.title = "Success"; + modalSuccess.componentInstance.message = 'User added Successfully!'; + }, error => { + console.log("Error : ", error); + const modalErrorRef = this.ngbModal.open(ConfirmationModalComponent); + modalErrorRef.componentInstance.title = "Error"; + modalErrorRef.componentInstance.message = 'Something went wrong. Error Message: ' + error.message; + }) this.activeModal.close(); } diff --git a/portal-FE-os/src/environments/environment.prod.ts b/portal-FE-os/src/environments/environment.prod.ts index db6b5bf5..7cc34da5 100644 --- a/portal-FE-os/src/environments/environment.prod.ts +++ b/portal-FE-os/src/environments/environment.prod.ts @@ -125,7 +125,8 @@ export const environment = { "footerLogoImagePath": "", "footerLogoText": "", "intraSearcLink": "", - "extraSearcLink": "https://wiki.onap.org/dosearchsite.action?cql=siteSearch+~+searchStringPlaceHolder&queryString=searchStringPlaceHolder" + "extraSearcLink": "https://wiki.onap.org/dosearchsite.action?cql=siteSearch+~+searchStringPlaceHolder&queryString=searchStringPlaceHolder", + "browserCompatibilityMsg": "This Application is best viewed on Firefox, Chrome and Edge." }, "getAccessUrl": "", "getAccessName":"", diff --git a/portal-FE-os/src/environments/environment.ts b/portal-FE-os/src/environments/environment.ts index 0482c20c..d412522f 100644 --- a/portal-FE-os/src/environments/environment.ts +++ b/portal-FE-os/src/environments/environment.ts @@ -129,7 +129,8 @@ export const environment = { "footerLogoImagePath": "", "footerLogoText": "", "intraSearcLink": "", - "extraSearcLink": "https://wiki.onap.org/dosearchsite.action?cql=siteSearch+~+searchStringPlaceHolder&queryString=searchStringPlaceHolder" + "extraSearcLink": "https://wiki.onap.org/dosearchsite.action?cql=siteSearch+~+searchStringPlaceHolder&queryString=searchStringPlaceHolder", + "browserCompatibilityMsg": "This Application is best viewed on Firefox, Chrome and Edge." }, "getAccessUrl": "", "getAccessName": "", diff --git a/portal-FE-os/src/favicon.ico b/portal-FE-os/src/favicon.ico index d2c5e0fc..cb712ebd 100644 Binary files a/portal-FE-os/src/favicon.ico and b/portal-FE-os/src/favicon.ico differ