public void loadData() throws RemoteException, Exception { ResourceAdmin rsAd = regUserRole .getRegistryUserRoleContent() .getRegistryUserManagerContainer() .getRegistryData() .getResourceAdmin(); if (changePermissionWizPage1 != null) { ArrayList<RegistryResourceNode> list = changePermissionWizPage1.selectedItemList(); for (int i = 0; i < list.size(); i++) { ArrayList<Role> resourceInfo = rsAd.getPermissionPerResource(list.get(i).getRegistryResourcePath()); for (int j = 0; j < resourceInfo.size(); j++) { roleData = getRoleData(resourceInfo.get(j).getRole(), list.get(i).getRegistryResourcePath()); ArrayList<String> permissionListPerRole = resourceInfo.get(j).getAssignedPermission(); for (int k = 0; k < permissionListPerRole.size(); k++) { if (permissionListPerRole.get(k).equals("Read")) { roleData.setReadPerm(true); } if (permissionListPerRole.get(k).equals("Write")) { roleData.setWritePerm(true); } if (permissionListPerRole.get(k).equals("Delete")) { roleData.setDeletePerm(true); } if (permissionListPerRole.get(k).equals("Authorize")) { roleData.setAuthPerm(true); } } } } } }
public void setAssignedPermissionsToRole() throws Exception { int readCount = 0; int writeCount = 0; int deleteCount = 0; int authCount = 0; String selectedRole = regUserRole.getUserRoleName(); ResourceAdmin rsAd = regUserRole .getRegistryUserRoleContent() .getRegistryUserManagerContainer() .getRegistryData() .getResourceAdmin(); if (changePermissionWizPage1 != null) { ArrayList<RegistryResourceNode> list = changePermissionWizPage1.selectedItemList(); for (int i = 0; i < list.size(); i++) { ArrayList<String> permissionAssigned = rsAd.getPermissionListPerResource(list.get(i).getRegistryResourcePath(), selectedRole); RoleData roleD = new RoleData(selectedRole, list.get(i).getRegistryResourcePath()); for (int j = 0; j < permissionAssigned.size(); j++) { if (permissionAssigned.get(j).equals("Read")) { readCount++; roleD.setReadPerm(true); } if (permissionAssigned.get(j).equals("Write")) { writeCount++; roleD.setWritePerm(true); } if (permissionAssigned.get(j).equals("Delete")) { deleteCount++; roleD.setDeletePerm(true); } if (permissionAssigned.get(j).equals("Authorize")) { authCount++; roleD.setAuthPerm(true); } } if (selectedPermissions.isEmpty()) { selectedPermissions.add(roleD); } else { for (int j = 0; j < selectedPermissions.size(); j++) { if (selectedPermissions .get(j) .getResourcePath() .equals(list.get(i).getRegistryResourcePath())) { selectedPermissions.remove(j); selectedPermissions.add(j, roleD); } else { selectedPermissions.add(roleD); } } } } if (readCount == list.size()) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Read")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(true); } } } else if (readCount == 0) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Read")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(false); } } } else { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Read")) { checkBoxes.get(k).setGrayed(true); checkBoxes.get(k).setSelection(true); } } } if (writeCount == list.size()) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Write")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(true); } } } else if (writeCount == 0) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Write")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(false); } } } else { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Write")) { checkBoxes.get(k).setGrayed(true); checkBoxes.get(k).setSelection(true); } } } if (deleteCount == list.size()) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Delete")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(true); } } } else if (deleteCount == 0) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Delete")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(false); } } } else { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Delete")) { checkBoxes.get(k).setGrayed(true); checkBoxes.get(k).setSelection(true); } } } if (authCount == list.size()) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Authorize")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(true); } } } else if (authCount == 0) { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Authorize")) { checkBoxes.get(k).setGrayed(false); checkBoxes.get(k).setSelection(false); } } } else { for (int k = 0; k < checkBoxes.size(); k++) { if (checkBoxes.get(k).getText().equals("Authorize")) { checkBoxes.get(k).setGrayed(true); checkBoxes.get(k).setSelection(true); } } } } }