public void removeEveryOneFromRole(String SearchPath) throws RemoteException { if ((this.cmService != null) && (banonymous == false)) { BaseClass admins[] = new BaseClass[] {}; BaseClass[] existingMembers; ArrayList<BaseClass> members = new ArrayList<BaseClass>(); Role role = null; // Retrieve the capability, including policies admins = this.cmService.query( new SearchPathMultipleObject(SearchPath), new PropEnum[] {PropEnum.searchPath, PropEnum.members, PropEnum.defaultName}, new Sort[] {}, new QueryOptions()); role = (Role) admins[0]; // Store existing members if (role.getMembers().getValue() != null) { existingMembers = role.getMembers().getValue(); for (BaseClass member : existingMembers) if (!member.getSearchPath().getValue().equals("CAMID(\"::Everyone\")")) members.add(member); } if (role != null) { // Update the role information in the content store role.setMembers(new BaseClassArrayProp()); role.getMembers().setValue(members.toArray(new BaseClass[members.size()])); this.cmService.update(new BaseClass[] {role}, new UpdateOptions()); } } }
public void addUserOrGroupToRole(String SearchPath, String RoleSearchPath) throws RemoteException { if ((this.cmService != null) && (banonymous == false)) { BaseClass userresults[] = new BaseClass[] {}; BaseClass admins[] = new BaseClass[] {}; BaseClass[] existingMembers; ArrayList<BaseClass> members = new ArrayList<BaseClass>(); Role role = null; System.out.println("Searching for user in cognos repository: "); userresults = this.cmService.query( new SearchPathMultipleObject(SearchPath), new PropEnum[] {PropEnum.searchPath}, new Sort[] {}, new QueryOptions()); if ((userresults != null) && (userresults.length > 0)) { System.out.println(userresults[0].getSearchPath().getValue()); } // Retrieve the capability, including policies admins = this.cmService.query( new SearchPathMultipleObject(RoleSearchPath), new PropEnum[] { PropEnum.searchPath, PropEnum.members, PropEnum.policies, PropEnum.defaultName }, new Sort[] {}, new QueryOptions()); role = (Role) admins[0]; // Store existing members if (role.getMembers().getValue() != null) { existingMembers = role.getMembers().getValue(); for (BaseClass member : existingMembers) if (!member.getSearchPath().getValue().equals("CAMID(\"::Everyone\")") && !member .getSearchPath() .getValue() .equals(userresults[0].getSearchPath().getValue())) members.add(member); } // Add admins to list members.add(userresults[0]); if ((role != null) && (userresults.length > 0) && (userresults[0] != null)) { // Update the role information in the content store role.setMembers(new BaseClassArrayProp()); role.getMembers().setValue(members.toArray(new BaseClass[members.size()])); this.cmService.update(new BaseClass[] {role}, new UpdateOptions()); } } }