From 1683d7929869d7d5f9bda1ffad0ace619c507ce0 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Wed, 23 Aug 2017 15:46:44 -0400 Subject: Repair role-centralization features in EPSDK Issue: PORTAL-21 Change-Id: Icf276482609734d3aa24f04ae0a8135021a3d305 Signed-off-by: Christopher Lott (cl778h) --- .../controller/core/ProfileController.java | 12 ++ .../main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml | 4 + .../scripts/DS2-controllers/admin-controller.js | 93 ++++++-------- .../modals/role-fun-role-del-confirm.html | 6 +- .../ds2-admin/modals/role-functions-modal.html | 8 +- .../DS2-view-models/ds2-admin/role-function.html | 110 +++++++++-------- .../scripts/DS2-view-models/ds2-admin/role.html | 134 ++++++++------------- .../DS2-view-models/ds2-admin/role_list.html | 17 +-- .../ds2-profile/modals/role-add.html | 63 +++++----- .../src/main/webapp/app/fusion/styles/ecomp.css | 5 +- .../core/service/LoginServiceCentralizedImpl.java | 13 ++ .../core/service/RestApiRequestBuilder.java | 4 +- .../core/service/RoleServiceCentralizedAccess.java | 10 +- .../core/onboarding/rest/RestWebServiceClient.java | 7 +- 14 files changed, 236 insertions(+), 250 deletions(-) diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java index f4132a9e..2f17ac68 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java @@ -28,6 +28,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.json.JSONObject; import org.openecomp.portalsdk.core.controller.RestrictedBaseController; @@ -37,6 +38,7 @@ import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.openecomp.portalsdk.core.service.RoleService; import org.openecomp.portalsdk.core.service.UserProfileService; import org.openecomp.portalsdk.core.service.UserService; +import org.openecomp.portalsdk.core.util.SystemProperties; import org.openecomp.portalsdk.core.web.support.AppUtils; import org.openecomp.portalsdk.core.web.support.JsonMessage; import org.openecomp.portalsdk.core.web.support.UserUtils; @@ -254,6 +256,11 @@ public class ProfileController extends RestrictedBaseController { domainUser.removeRole(role.getId()); service.saveUser(domainUser); + /*If adding new roles on the current logged in user, we need to update the user value in session*/ + if(UserUtils.getUserId(request)==Integer.valueOf(profileId)){ + HttpSession session = request.getSession(true); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), domainUser); + } logger.info(EELFLoggerDelegate.auditLogger, "Remove role " + role.getId() + " from user " + profileId); response.setCharacterEncoding("UTF-8"); @@ -294,6 +301,11 @@ public class ProfileController extends RestrictedBaseController { User domainUser = (User) userService.getUser(profileId); domainUser.addRole(role); service.saveUser(domainUser); + /*If removing roles on the current logged in user, we need to update the user value in session*/ + if(UserUtils.getUserId(request)==Integer.valueOf(profileId)){ + HttpSession session = request.getSession(true); + session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), domainUser); + } logger.info(EELFLoggerDelegate.auditLogger, "Add new role " + role.getName() + " to user " + profileId); response.setCharacterEncoding("UTF-8"); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml index e569972a..098a5857 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml @@ -385,5 +385,9 @@ select orgUserId from User where id = :user_id + + + select id from User where orgUserId = :orgUserId + diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-controller.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-controller.js index d7adaf36..dc59b6c7 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-controller.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/admin-controller.js @@ -7,17 +7,21 @@ appDS2.controller('adminController', function($scope, $http,AdminService, $modal $scope.nextSort=""; $scope.showLoader = false; $scope.tableData=[]; + $scope.showLoader=false; $scope.routeRoleId = $routeParams.roleId; $scope.regions = []; /*function*/ $scope.getFunctionList = function(){ $scope.tableData.length=0; + $scope.showLoader=true; AdminService.getRoleFunctionList().then(function(data){ var j = data; $scope.data = JSON.parse(j.data); $scope.tableData =JSON.parse($scope.data.availableRoleFunctions); },function(error){ console.log("failed"); + }).finally(function() { + $scope.showLoader=false; // Always execute this on both error and success }); } @@ -605,29 +609,6 @@ appDS2.controller('adminController', function($scope, $http,AdminService, $modal } - /*$scope.showItemDetails = function(cacheName,key) { - $http.get("jcs_admin/showItemDetails?keyName="+key+"&cacheName="+cacheName).success(function(response){ - var message = "CacheName: "+ response.cacheName - +"\nkey: "+response.key - +"\nIS_SPOOL: "+response.attr.IS_SPOOL - +"\nIS_LATERAL: "+response.attr.IS_LATERAL - +"\nIS_REMOTE: "+response.attr.IS_REMOTE - +"\nIS_ETERNAL: "+response.attr.IS_ETERNAL - +"\nversion: "+response.attr.version - +"\nmaxLifeSeconds: "+response.attr.maxLifeSeconds - +"\nmaxIdleTimeSeconds: "+response.attr.maxIdleTimeSeconds - +"\nsize: "+response.attr.size - +"\ncreateTime: "+response.attr.createTime - +"\nlastAccessTime: "+response.attr.lastAccessTime - +"\nidleTime: "+response.attr.idleTime - +"\ntimeToLiveSeconds: "+response.attr.timeToLiveSeconds - +"\nisSpool: "+response.attr.isSpool - +"\nisLateral: "+response.attr.isLateral - +"\nisRemote: "+response.attr.isRemote - +"\nisEternal: "+response.attr.isEternal; - modalService.showSuccess('',message);}); - };*/ - $scope.showItemDetails = function(cacheName, key){ AdminService.showItemDetails(cacheName, key).then(function(msg){ @@ -695,35 +676,38 @@ appDS2.controller('adminController', function($scope, $http,AdminService, $modal } $scope.roleFnInit = function(){ + $scope.showLoader=true; AdminService.getRole($routeParams.roleId).then(function(data){ - - var j = data; - $scope.data = JSON.parse(j.data); - $scope.role =JSON.parse($scope.data.role); - - $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); - $scope.availableRoleFunctions=[]; - - if($scope.ociavailableRoleFunctions) - angular.forEach($scope.ociavailableRoleFunctions, function(a,i){ - var availableRoleFunction = a; - availableRoleFunction.selected = false; - angular.forEach($scope.role.roleFunctions, function(b,j){ - if(a.code === b.code) { - availableRoleFunction.selected = true; - } - }); - $scope.availableRoleFunctions.push(availableRoleFunction); - }); - - - $scope.ociavailableRoles=JSON.parse($scope.data.availableRoles); - $scope.availableRoles=[]; - - },function(error){ - console.log("roleControllerDS2 failed: " + error); - reloadPageOnce(); - }); + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.role =JSON.parse($scope.data.role); + + $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); + $scope.availableRoleFunctions=[]; + + if($scope.ociavailableRoleFunctions) + angular.forEach($scope.ociavailableRoleFunctions, function(a,i){ + var availableRoleFunction = a; + availableRoleFunction.selected = false; + angular.forEach($scope.role.roleFunctions, function(b,j){ + if(a.code === b.code) { + availableRoleFunction.selected = true; + } + }); + $scope.availableRoleFunctions.push(availableRoleFunction); + }); + + + $scope.ociavailableRoles=JSON.parse($scope.data.availableRoles); + $scope.availableRoles=[]; + + },function(error){ + console.log("roleControllerDS2 failed: " + error); + reloadPageOnce(); + }).finally(function() { + $scope.showLoader=false; // Always execute this on both error and success + }); } // updating roles on role list page after deletion of a role @@ -740,7 +724,7 @@ appDS2.controller('adminController', function($scope, $http,AdminService, $modal $scope.saveRole = function() { var errorMsg; - + $scope.showLoader=true; if($scope.role.id == null || $scope.role.id == undefined ){ $scope.role = { 'id':null, @@ -828,7 +812,9 @@ appDS2.controller('adminController', function($scope, $http,AdminService, $modal } },function(error){ console.log("error msg"); - }) + }).finally(function() { + $scope.showLoader=false; // Always execute this on both error and success + }); } } @@ -838,6 +824,7 @@ appDS2.controller('adminController', function($scope, $http,AdminService, $modal templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-functions-modal.html', controller: ModalInstanceCtrl, sizeClass: 'modal-large', + windowClass:"modal-docked", resolve: { items: function () { var message = { diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-fun-role-del-confirm.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-fun-role-del-confirm.html index f293152c..322c6624 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-fun-role-del-confirm.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-admin/modals/role-fun-role-del-confirm.html @@ -1,17 +1,17 @@
-