Search in sources :

Example 1 with XWikiSpace

use of com.xpn.xwiki.doc.XWikiSpace in project xwiki-platform by xwiki.

the class R72001XWIKI12228DataMigration method createSpaces.

private void createSpaces(Collection<SpaceReference> spaces, boolean hidden, Session session) {
    // Create spaces in the xwikispace table
    for (SpaceReference spaceReference : spaces) {
        XWikiSpace space = new XWikiSpace(spaceReference);
        space.setHidden(hidden);
        session.save(space);
    }
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) XWikiSpace(com.xpn.xwiki.doc.XWikiSpace)

Example 2 with XWikiSpace

use of com.xpn.xwiki.doc.XWikiSpace in project xwiki-platform by xwiki.

the class XWikiHibernateStore method makeSpaceVisible.

private void makeSpaceVisible(SpaceReference spaceReference, Session session) {
    XWikiSpace space = loadXWikiSpace(spaceReference, session);
    makeSpaceVisible(space, session);
}
Also used : XWikiSpace(com.xpn.xwiki.doc.XWikiSpace)

Example 3 with XWikiSpace

use of com.xpn.xwiki.doc.XWikiSpace 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);
        }
    }
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) XWikiSpace(com.xpn.xwiki.doc.XWikiSpace)

Example 4 with XWikiSpace

use of com.xpn.xwiki.doc.XWikiSpace 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);
    }
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) XWikiSpace(com.xpn.xwiki.doc.XWikiSpace)

Aggregations

XWikiSpace (com.xpn.xwiki.doc.XWikiSpace)4 SpaceReference (org.xwiki.model.reference.SpaceReference)3