- /*
- @RequestMapping(value = {"/portalApi/queryUsers"}, method = RequestMethod.GET, produces = "application/json")
- @PreAuthorize("hasRole('System_Administrator') and hasRole('Account_Administrator')")
- public String getPhoneBookSearchResult(Principal principal, @RequestParam("search") String searchString,
- HttpServletResponse response) {
- FnUser user = fnUserService.loadUserByUsername(principal.getName());
-
- String searchResult = null;
- if (!adminRolesService.isSuperAdmin(user) && !adminRolesService.isAccountAdmin(user)
- && !adminRolesService.isRoleAdmin(user)) {
- EcompPortalUtils.setBadPermissions(user, response, "getPhoneBookSearchResult");
- } else {
- searchString = searchString.trim();
- if (searchString.length() > 2) {
- searchResult = searchService.searchUsersInPhoneBook(searchString);
- } else {
- logger.info(EELFLoggerDelegate.errorLogger,
- "getPhoneBookSearchResult - too short search string: " + searchString);
- }
- }
- EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/queryUsers", "result =", searchResult);
-
- return searchResult;
- }
-
-
- @RequestMapping(value = {"/portalApi/adminAppsRoles"}, method = {
- RequestMethod.GET}, produces = "application/json")
- public AppsListWithAdminRole getAppsWithAdminRoleStateForUser(Principal principal,
- @RequestParam("user") String orgUserId, HttpServletResponse response) {
-
- FnUser user = fnUserService.loadUserByUsername(principal.getName());
-
- AppsListWithAdminRole result = null;
- if (!adminRolesService.isSuperAdmin(user)) {
- EcompPortalUtils.setBadPermissions(user, response, "getAppsWithAdminRoleStateForUser");
- } else {
- if (EcompPortalUtils.legitimateUserId(orgUserId)) {
- result = adminRolesService.getAppsWithAdminRoleStateForUser(orgUserId);
- } else {
- logger.info(EELFLoggerDelegate.errorLogger,
- "getAppsWithAdminRoleStateForUser - parms error, no Organization User ID");
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- }
- }
-
- StringBuilder adminAppRoles = new StringBuilder();
- if (result != null) {
- if (!result.appsRoles.isEmpty()) {
- adminAppRoles.append("User '" + result.orgUserId + "' has admin role to the apps = {");
- for (AppNameIdIsAdmin adminAppRole : result.appsRoles) {
- if (adminAppRole.isAdmin) {
- adminAppRoles.append(adminAppRole.appName + ", ");
- }
- }
- adminAppRoles.append("}.");
- } else {
- adminAppRoles.append("User '" + result.orgUserId + "' has no Apps with Admin Role.");
- }
- } else {
- logger.error(EELFLoggerDelegate.errorLogger,
- "putAppWithUserRoleStateForUser: getAppsWithAdminRoleStateForUser result is null");
- }
-
- logger.info(EELFLoggerDelegate.errorLogger, adminAppRoles.toString());
-
- EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/adminAppsRoles", "get result =", result);
-
- return result;
- }
-
- @RequestMapping(value = {"/portalApi/adminAppsRoles"}, method = {
- RequestMethod.PUT}, produces = "application/json")
- public FieldsValidator putAppsWithAdminRoleStateForUser(Principal principal,
- @RequestBody AppsListWithAdminRole newAppsListWithAdminRoles, HttpServletResponse response) {
-
- // newAppsListWithAdminRoles.appsRoles
- FieldsValidator fieldsValidator = new FieldsValidator();
- StringBuilder newAppRoles = new StringBuilder();
- if (newAppsListWithAdminRoles != null) {
- if (!newAppsListWithAdminRoles.appsRoles.isEmpty()) {
- newAppRoles
- .append("User '" + newAppsListWithAdminRoles.orgUserId
- + "' has admin role to the apps = { ");
- for (AppNameIdIsAdmin adminAppRole : newAppsListWithAdminRoles.appsRoles) {
- if (adminAppRole.isAdmin) {
- newAppRoles.append(adminAppRole.appName + " ,");
- }
- }
- newAppRoles.deleteCharAt(newAppRoles.length() - 1);
- newAppRoles.append("}.");
- } else {
- newAppRoles.append("User '" + newAppsListWithAdminRoles.orgUserId
- + "' has no Apps with Admin Role.");
- }
- } else {
- logger.error(EELFLoggerDelegate.errorLogger,
- "putAppWithUserRoleStateForUser: putAppsWithAdminRoleStateForUser result is null");
- fieldsValidator.setHttpStatusCode((long) HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
-
- logger.info(EELFLoggerDelegate.errorLogger, newAppRoles.toString());
-
- FnUser user = fnUserService.loadUserByUsername(principal.getName());
-
- boolean changesApplied = false;
-
- if (!adminRolesService.isSuperAdmin(user)) {
- EcompPortalUtils.setBadPermissions(user, response, "putAppsWithAdminRoleStateForUser");
- } else {
- changesApplied = adminRolesService.setAppsWithAdminRoleStateForUser(newAppsListWithAdminRoles);
- AuditLog auditLog = new AuditLog();
- auditLog.setUserId(user.getId());
- auditLog.setActivityCode(EcompAuditLog.CD_ACTIVITY_UPDATE_ACCOUNT_ADMIN);
- if (newAppsListWithAdminRoles != null) {
- auditLog.setAffectedRecordId(newAppsListWithAdminRoles.orgUserId);
- }
- auditLog.setComments(
- EcompPortalUtils
- .truncateString(newAppRoles.toString(), PortalConstants.AUDIT_LOG_COMMENT_SIZE));
- auditService.logActivity(auditLog, null);
-
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- if (newAppsListWithAdminRoles != null) {
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage(
- "UserRolesController.putAppsWithAdminRoleStateForUser",
- EcompAuditLog.CD_ACTIVITY_UPDATE_ACCOUNT_ADMIN, user.getOrgUserId(),
- newAppsListWithAdminRoles.orgUserId, newAppRoles.toString()));
- }
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
- }
- EcompPortalUtils
- .logAndSerializeObject(logger, "/portalApi/adminAppsRoles", "put result =", changesApplied);
-
- return fieldsValidator;
- }
+ /*
+ @RequestMapping(value = {"/portalApi/queryUsers"}, method = RequestMethod.GET, produces = "application/json")
+ @PreAuthorize("hasRole('System_Administrator') and hasRole('Account_Administrator')")
+ public String getPhoneBookSearchResult(Principal principal, @RequestParam("search") String searchString,
+ HttpServletResponse response) {
+ FnUser user = fnUserService.loadUserByUsername(principal.getName());
+
+ String searchResult = null;
+ if (!adminRolesService.isSuperAdmin(user) && !adminRolesService.isAccountAdmin(user)
+ && !adminRolesService.isRoleAdmin(user)) {
+ EcompPortalUtils.setBadPermissions(user, response, "getPhoneBookSearchResult");
+ } else {
+ searchString = searchString.trim();
+ if (searchString.length() > 2) {
+ searchResult = searchService.searchUsersInPhoneBook(searchString);
+ } else {
+ logger.info(EELFLoggerDelegate.errorLogger,
+ "getPhoneBookSearchResult - too short search string: " + searchString);
+ }
+ }
+ EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/queryUsers", "result =", searchResult);
+
+ return searchResult;
+ }
+
+
+ @RequestMapping(value = {"/portalApi/adminAppsRoles"}, method = {
+ RequestMethod.GET}, produces = "application/json")
+ public AppsListWithAdminRole getAppsWithAdminRoleStateForUser(Principal principal,
+ @RequestParam("user") String orgUserId, HttpServletResponse response) {
+
+ FnUser user = fnUserService.loadUserByUsername(principal.getName());
+
+ AppsListWithAdminRole result = null;
+ if (!adminRolesService.isSuperAdmin(user)) {
+ EcompPortalUtils.setBadPermissions(user, response, "getAppsWithAdminRoleStateForUser");
+ } else {
+ if (EcompPortalUtils.legitimateUserId(orgUserId)) {
+ result = adminRolesService.getAppsWithAdminRoleStateForUser(orgUserId);
+ } else {
+ logger.info(EELFLoggerDelegate.errorLogger,
+ "getAppsWithAdminRoleStateForUser - parms error, no Organization User ID");
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ }
+ }
+
+ StringBuilder adminAppRoles = new StringBuilder();
+ if (result != null) {
+ if (!result.appsRoles.isEmpty()) {
+ adminAppRoles.append("User '" + result.orgUserId + "' has admin role to the apps = {");
+ for (AppNameIdIsAdmin adminAppRole : result.appsRoles) {
+ if (adminAppRole.isAdmin) {
+ adminAppRoles.append(adminAppRole.appName + ", ");
+ }
+ }
+ adminAppRoles.append("}.");
+ } else {
+ adminAppRoles.append("User '" + result.orgUserId + "' has no Apps with Admin Role.");
+ }
+ } else {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "putAppWithUserRoleStateForUser: getAppsWithAdminRoleStateForUser result is null");
+ }
+
+ logger.info(EELFLoggerDelegate.errorLogger, adminAppRoles.toString());
+
+ EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/adminAppsRoles", "get result =", result);
+
+ return result;
+ }