use of org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestAccessRule in project xwiki-platform by xwiki.
the class TestAccessRuleFactory method getNewInstance.
@Override
TestAccessRule getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) {
EntityReference userRef = parser.getResolver().resolve(attributes.getValue("name"), DefaultTestDocument.TYPE, new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, parent.getReference().getRoot()));
Boolean allow = name.startsWith("allow");
String type = attributes.getValue("type");
String user = parser.getSerializer().serialize(userRef);
Boolean isUser = name.endsWith("User");
if (type != null) {
Right right = Right.toRight(type);
new DefaultTestAccessRule(user, userRef, right, allow, isUser, parent);
} else {
EntityType parentType = parent.getType();
if (parentType == EntityType.WIKI && ((TestWiki) parent).isMainWiki()) {
// Null here means root (or farm)
parentType = null;
}
for (Right right : Right.getEnabledRights(parentType)) {
if (right != Right.CREATOR) {
new DefaultTestAccessRule(user, userRef, right, allow, isUser, parent);
}
}
}
return null;
}
Aggregations