Hallo Sebastian,
folgende Beispielklasse (ohne Imports) zeigt an, auf welchen Elementen im PageStore eine Gruppe geerbte Rechte hat:
public class ServerGroups {
public static void main(String... args)
throws MaximumNumberOfSessionsExceededException, IOException,
AuthenticationException, LockException, ElementDeletedException {
Connection con = ConnectionManager.getConnection("localhost", 1088,
ConnectionManager.SOCKET_MODE, "Admin", "Admin");
con.connect();
Project pr = con.getProjectById(7);
List<Group> groups = pr.getGroups();
UserService us2 = pr.getUserService();
PageStoreRoot pageStore = (PageStoreRoot) us2.getStore(
Store.Type.PAGESTORE, false);
for (Group gr : groups) {
System.out.println("\n--------------" + gr.getName()
+ "--------------");
getRightsRecursively(pageStore, gr);
}
con.disconnect();
}
public static void getRightsRecursively(StoreElement d, Group gr) {
Iterator<StoreElement> storeElementIterator = (Iterator<StoreElement>) d
.getChildren().iterator();
StoreElement theProvider = null;
while (storeElementIterator.hasNext()) {
theProvider = storeElementIterator.next();
if (theProvider instanceof Page
|| theProvider instanceof PageFolder) {
if (theProvider.isFolder()) {
getRightsRecursively(theProvider, gr);
if (checkPermission(theProvider, gr)) {
System.out.println("Group " + "'" + gr.getName() + "'"
+ " has inherited permissions on PageFolder "
+ "'" + theProvider.getName() + "'");
}
} else {
if (checkPermission(theProvider, gr)) {
System.out.println("Group " + "'" + gr.getName() + "'"
+ " has inherited permissions on Page " + "'"
+ theProvider.getName() + "'");
}
}
}
}
}
public static boolean checkPermission(StoreElement id, Group gr) {
boolean b = false;
if (id.getInheritedPrincipalPermissions().contains(gr)) {
b = true;
}
return b;
}
}
Freundliche Grüße
Ismail