Hi,
nochmal wegen den vererbten Berechtigungen. Ich habs jetzt genauso mit dem Back-Traversieren implementiert, und es scheint auch gut zu funktionieren. Obs eine bessere bzw. elegantere Lösung gibt weiß ich nicht.
Hier der Code, falls es jemanden interessiert (ist aber noch nicht zu 100% getestet, war eher auf die Schnelle):
String getRoles(StoreElement node, String defaultVal) {
StringBuffer result = new StringBuffer();
metaData = node.getMeta();
perms = metaData.get("roles").getEditor().get(null);
roles = perms.getAllowedExplicit("access");
if (roles != null && roles.size() > 0) {
//Do nothing, roles contains now the Set with the allowed roles
} else {
parent = node.getParent();
int limit = 10; //Just to prevent the while loop from running infinite (who knows what can happen 🙂
int cnt = 0; //We have anyway an maxium sitestore tree depth of 7
while (parent != null) {
metaData = parent.getMeta();
perms = metaData.get("roles").getEditor().get(null);
roles = perms.getAllowedExplicit("access");
if (roles != null && roles.size() > 0) {
//roles contains now the Set with the allowed roles
break;
}
cnt++;
if (cnt > limit) {
break;
}
parent = parent.getParent();
}
}
if (roles != null && roles.size() > 0) {
cnt = 0;
for (iter = roles.iterator(); iter.hasNext();) {
if (cnt > 0) {
result.append(",");
}
String role = iter.next();
result.append(role.substring("/epintegration".length()+1));
cnt++;
}
return result.toString();
} else {
return defaultVal;
}
}