summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src/main/java')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleController.java34
1 files changed, 18 insertions, 16 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleController.java
index 52dedd46..d555ba46 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleController.java
@@ -84,8 +84,6 @@ public class RoleController extends RestrictedBaseController {
@Autowired
private RoleService roleService;
- private String viewName;
-
@RequestMapping(value = { "/role" }, method = RequestMethod.GET)
public ModelAndView role(HttpServletRequest request) throws IOException {
Map<String, Object> model = new HashMap<>();
@@ -133,6 +131,14 @@ public class RoleController extends RestrictedBaseController {
}
+ private void trowIfUserRoleExist(String roleName, String userId) throws IOException, SecurityException
+ {
+ List<Role> roles = roleService.getAvailableRoles(userId);
+ for (Role existRole : roles)
+ if (existRole.getName().equalsIgnoreCase(roleName))
+ throw new SecurityException("role already exists: " + existRole.getName());
+ }
+
/**
* Creates a new role or updates an existing role.
*
@@ -167,11 +173,8 @@ public class RoleController extends RestrictedBaseController {
domainRole.setPriority(role.getPriority());
} else {
doAuditLog("saveRole: creating new role", role.getName());
- // check for existing role of same name
- List<Role> roles = roleService.getAvailableRoles(user.getOrgUserId());
- for (Role existRole : roles)
- if (existRole.getName().equalsIgnoreCase(role.getName()))
- throw new Exception("role already exists: " + existRole.getName());
+
+ trowIfUserRoleExist(role.getName(),user.getOrgUserId());
domainRole = new Role();
domainRole.setName(role.getName());
@@ -371,13 +374,12 @@ public class RoleController extends RestrictedBaseController {
}
@Override
- public String getViewName() {
- return viewName;
- }
-
- @Override
- public void setViewName(String viewName) {
- this.viewName = viewName;
- }
-
+ public String getViewName() {
+ return viewName;
+ }
+
+ @Override
+ public void setViewName(String viewName) {
+ this.viewName = viewName;
+ }
}