Search in sources :

Example 31 with EntityReference

use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.

the class AbstractEntityJobWithChecks method getEntities.

protected void getEntities(Collection<EntityReference> entityReferences) {
    this.progressManager.pushLevelProgress(entityReferences.size(), this);
    try {
        for (EntityReference entityReference : entityReferences) {
            if (this.status.isCanceled()) {
                break;
            } else {
                this.progressManager.startStep(this);
                getEntities(entityReference);
                this.progressManager.endStep(this);
            }
        }
    } finally {
        this.progressManager.popLevelProgress(this);
    }
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference)

Example 32 with EntityReference

use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.

the class AbstractEntityJobWithChecks method runInternal.

@Override
protected void runInternal() throws Exception {
    progressManager.pushLevelProgress(2, this);
    try {
        Collection<EntityReference> entityReferences = this.request.getEntityReferences();
        if (entityReferences != null) {
            // Get the list of concerned entities
            progressManager.startStep(this);
            getEntities(entityReferences);
            // Send the event
            DocumentsDeletingEvent event = new DocumentsDeletingEvent();
            observationManager.notify(event, this, concernedEntities);
            // Stop the job if some listener has canceled the action
            if (event.isCanceled()) {
                return;
            }
            // Process
            progressManager.startStep(this);
            setContextUser();
            process(entityReferences);
        }
    } finally {
        progressManager.popLevelProgress(this);
    }
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) DocumentsDeletingEvent(org.xwiki.bridge.event.DocumentsDeletingEvent)

Example 33 with EntityReference

use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.

the class RefactoringScriptService method getCurrentWikiReference.

private WikiReference getCurrentWikiReference() {
    WikiReference result = null;
    EntityReference currentEntityReference = this.modelContext.getCurrentEntityReference();
    if (currentEntityReference != null) {
        EntityReference wikiEntityReference = this.modelContext.getCurrentEntityReference().extractReference(EntityType.WIKI);
        if (wikiEntityReference != null) {
            result = new WikiReference(wikiEntityReference);
        }
    }
    return result;
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) WikiReference(org.xwiki.model.reference.WikiReference)

Example 34 with EntityReference

use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.

the class DefaultResourceReferenceEntityReferenceResolverTest method before.

@Before
public void before() throws Exception {
    this.currentEntityReferenceResolver = this.mocker.registerMockComponent(EntityReferenceResolver.TYPE_STRING, "current");
    this.currentDocumentProvider = this.mocker.registerMockComponent(new DefaultParameterizedType(null, Provider.class, DocumentReference.class), "current");
    when(this.currentDocumentProvider.get()).thenReturn(new DocumentReference(CURRENT_WIKI, CURRENT_SPACE, CURRENT_PAGE));
    this.bridge = this.mocker.registerMockComponent(DocumentAccessBridge.class);
    when(this.bridge.exists(any(DocumentReference.class))).then(new Answer<Boolean>() {

        @Override
        public Boolean answer(InvocationOnMock invocation) throws Throwable {
            return existingDocuments.contains(invocation.getArguments()[0]);
        }
    });
    this.defaultEntityProvider = this.mocker.registerMockComponent(EntityReferenceProvider.class);
    when(this.defaultEntityProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(new EntityReference(DEFAULT_PAGE, EntityType.DOCUMENT));
}
Also used : EntityReferenceProvider(org.xwiki.model.reference.EntityReferenceProvider) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) EntityReference(org.xwiki.model.reference.EntityReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Example 35 with EntityReference

use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.

the class Utils method getSpaceReference.

/**
 * @param spaces the space hierarchy
 * @param wikiName the name of the wiki
 * @return the space reference
 */
public static SpaceReference getSpaceReference(List<String> spaces, String wikiName) {
    EntityReference parentReference = new WikiReference(wikiName);
    SpaceReference spaceReference = null;
    for (String space : spaces) {
        spaceReference = new SpaceReference(space, parentReference);
        parentReference = spaceReference;
    }
    return spaceReference;
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) EntityReference(org.xwiki.model.reference.EntityReference) WikiReference(org.xwiki.model.reference.WikiReference)

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