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);
}
}
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);
}
}
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;
}
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));
}
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;
}
Aggregations