Search in sources :

Example 76 with EntityReference

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));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 77 with EntityReference

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));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 78 with EntityReference

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));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 79 with EntityReference

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));
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) Test(org.junit.Test)

Example 80 with EntityReference

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);
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) RegexEntityReference(org.xwiki.model.reference.RegexEntityReference) DocumentReference(org.xwiki.model.reference.DocumentReference) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject)

Aggregations

EntityReference (org.xwiki.model.reference.EntityReference)338 Test (org.junit.Test)157 DocumentReference (org.xwiki.model.reference.DocumentReference)107 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)39 BaseObject (com.xpn.xwiki.objects.BaseObject)38 ArrayList (java.util.ArrayList)27 XWikiContext (com.xpn.xwiki.XWikiContext)24 WikiReference (org.xwiki.model.reference.WikiReference)24 SpaceReference (org.xwiki.model.reference.SpaceReference)23 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)18 XWikiException (com.xpn.xwiki.XWikiException)17 EntityType (org.xwiki.model.EntityType)11 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)10 EntityReferenceProvider (org.xwiki.model.reference.EntityReferenceProvider)9 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)8 XDOM (org.xwiki.rendering.block.XDOM)8 URL (java.net.URL)7 AttachmentReference (org.xwiki.model.reference.AttachmentReference)7 HashMap (java.util.HashMap)6 Before (org.junit.Before)6