use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class RegexEntityReferenceTest method testExact.
@Test
public void testExact() {
EntityReference wikiReference = new RegexEntityReference(Pattern.compile(REFERENCETOMATCH.getWikiReference().getName(), Pattern.LITERAL), EntityType.WIKI);
EntityReference spaceReference = new RegexEntityReference(Pattern.compile(REFERENCETOMATCH.getLastSpaceReference().getName(), Pattern.LITERAL), EntityType.SPACE, wikiReference);
EntityReference reference = new RegexEntityReference(Pattern.compile(REFERENCETOMATCH.getName(), Pattern.LITERAL), EntityType.DOCUMENT, spaceReference);
Assert.assertTrue(reference.equals(REFERENCETOMATCH));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class RegexEntityReferenceTest method testPattern.
@Test
public void testPattern() {
EntityReference reference = new RegexEntityReference(Pattern.compile("p.*"), EntityType.DOCUMENT);
Assert.assertTrue(reference.equals(REFERENCETOMATCH));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class RegexEntityReferenceTest method testWithNonRegexParent.
@Test
public void testWithNonRegexParent() {
EntityReference reference = new RegexEntityReference(Pattern.compile("space"), EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI));
Assert.assertTrue(reference.equals(REFERENCETOMATCH));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class RegexEntityReferenceTest method testWithOnlyPage.
@Test
public void testWithOnlyPage() {
EntityReference reference = new RegexEntityReference(Pattern.compile(REFERENCETOMATCH.getName(), Pattern.LITERAL), EntityType.DOCUMENT);
Assert.assertTrue(reference.equals(REFERENCETOMATCH));
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class XWiki method protectUserPage.
public void protectUserPage(String userName, String userRights, XWikiDocument doc, XWikiContext context) throws XWikiException {
DocumentReference rightClassReference = getRightsClass(context).getDocumentReference();
EntityReference relativeRightClassReference = rightClassReference.removeParent(rightClassReference.getWikiReference());
// Allow users to edit their own profiles
BaseObject newuserrightsobject = doc.newXObject(relativeRightClassReference, context);
newuserrightsobject.setLargeStringValue("users", userName);
newuserrightsobject.setStringValue("levels", userRights);
newuserrightsobject.setIntValue("allow", 1);
}
Aggregations