Merge "Fix NPE & other issues"
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / service / UserRolesCommonServiceImpl.java
index db86005..7a7f9ee 100644 (file)
@@ -1086,7 +1086,6 @@ public class UserRolesCommonServiceImpl  {
                                                }
                                        }
                                }
-                                       
                                applyChangesToUserAppRolesForMyLoginsRequest(user, appId);
 
                                Boolean systemUser = (newAppRolesForUser.getIsSystemUser() != null ? newAppRolesForUser.getIsSystemUser() : false);
@@ -1114,7 +1113,10 @@ public class UserRolesCommonServiceImpl  {
                                }
                                else{   // if centralized app
                                if (app.getRolesInAAF()) {
-                                       if (!app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
+                               
+                                       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<RoleInAppForUser> roleAppUserList = rolesInAppForUser.roles;
                                        if (EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) {
-                                               
                                                // Apply changes in external Access system
                                                updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList,
                                                                epRequestValue,false,rolesGotDeletedFromApprover,checkIfUserisOnlyRoleAdmin);
@@ -1145,7 +1146,7 @@ public class UserRolesCommonServiceImpl  {
                                        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);
                                                }
@@ -1653,6 +1654,7 @@ public class UserRolesCommonServiceImpl  {
                                                // 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);
                                                }