use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class DefaultReferenceSpaceReferenceResolverTest method testResolveWithExplicitSpaceReference.
@Test
public void testResolveWithExplicitSpaceReference() {
SpaceReference reference = this.resolver.resolve(null, new SpaceReference("space", new WikiReference("wiki")));
Assert.assertEquals("space", reference.getName());
Assert.assertEquals("wiki", reference.getWikiReference().getName());
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class ModelScriptServiceTest method createSpaceReference.
@Test
public void createSpaceReference() {
Assert.assertEquals(new SpaceReference("space", new WikiReference("wiki")), this.service.createSpaceReference("space", this.service.createWikiReference("wiki")));
SpaceReference spaceReference = new SpaceReference("C", new SpaceReference("B", new SpaceReference("A", new WikiReference("wiki"))));
Assert.assertEquals(spaceReference, this.service.createSpaceReference(Arrays.asList("A", "B", "C"), this.service.createWikiReference("wiki")));
Assert.assertEquals(spaceReference, this.service.createSpaceReference(spaceReference.getName(), (SpaceReference) spaceReference.getParent()));
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class DefaultSpaceReferenceProvider method get.
@Override
public SpaceReference get() {
if (this.cachedReference == null) {
EntityReference reference = this.provider.getDefaultReference(EntityType.SPACE);
// Add wikis
reference = reference.appendParent(this.wikiReferenceProvider.get());
this.cachedReference = new SpaceReference(reference);
}
return this.cachedReference;
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class XWikiHibernateStore method maybeMakeSpaceHidden.
private void maybeMakeSpaceHidden(SpaceReference spaceReference, String modifiedDocument, Session session) {
XWikiSpace space = loadXWikiSpace(spaceReference, session);
// The space is supposed to exist
if (space == null) {
this.logger.warn("Space [{}] does not exist. Usually means the spaces table is not in sync with the documents table.", spaceReference);
return;
}
// If the space is already hidden return
if (space.isHidden()) {
return;
}
if (calculateHiddenStatus(spaceReference, modifiedDocument, session)) {
// Make the space hidden
space.setHidden(true);
session.update(space);
// Update space parent
if (spaceReference.getParent() instanceof SpaceReference) {
maybeMakeSpaceHidden((SpaceReference) spaceReference.getParent(), modifiedDocument, session);
}
}
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class XWikiHibernateStore method maybeDeleteXWikiSpace.
private void maybeDeleteXWikiSpace(SpaceReference spaceReference, String deletedDocument, Session session) {
if (countAllDocuments(spaceReference, session, "fullName <> ? AND (language IS NULL OR language = '')", deletedDocument) == 0) {
// The document was the last document in the space
XWikiSpace space = new XWikiSpace(spaceReference, this);
session.delete(space);
// Update parent
if (spaceReference.getParent() instanceof SpaceReference) {
maybeDeleteXWikiSpace((SpaceReference) spaceReference.getParent(), deletedDocument, session);
}
} else {
// Update space hidden property if needed
maybeMakeSpaceHidden(spaceReference, deletedDocument, session);
}
}
Aggregations