Search in sources :

Example 26 with LocalDocumentReference

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

the class AbstractDocumentConfigurationSource method getBaseObject.

protected BaseObject getBaseObject() throws XWikiException {
    DocumentReference documentReference = getFailsafeDocumentReference();
    LocalDocumentReference classReference = getFailsafeClassReference();
    if (documentReference != null && classReference != null) {
        XWikiContext xcontext = this.xcontextProvider.get();
        XWikiDocument document = xcontext.getWiki().getDocument(getDocumentReference(), xcontext);
        return document.getXObject(classReference);
    }
    return null;
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) XWikiContext(com.xpn.xwiki.XWikiContext) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 27 with LocalDocumentReference

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

the class AbstractXWikiPreferencesConfigurationSource method getBaseObject.

protected BaseObject getBaseObject(String language) throws XWikiException {
    XWikiContext xcontext = this.xcontextProvider.get();
    if (xcontext != null && xcontext.getWiki() != null) {
        DocumentReference documentReference = getFailsafeDocumentReference();
        LocalDocumentReference classReference = getFailsafeClassReference();
        if (documentReference != null && classReference != null) {
            XWikiDocument document = xcontext.getWiki().getDocument(getDocumentReference(), xcontext);
            return getBaseObject(document, language);
        }
    }
    return null;
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) XWikiContext(com.xpn.xwiki.XWikiContext) DocumentReference(org.xwiki.model.reference.DocumentReference) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference)

Example 28 with LocalDocumentReference

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

the class XAROutputFilterStream method beginWikiDocument.

@Override
public void beginWikiDocument(String name, FilterEventParameters parameters) throws FilterException {
    this.currentDocument = name;
    this.currentDocumentParameters = parameters;
    this.currentDocumentReference = new LocalDocumentReference(this.currentDocument, this.currentSpaceReference);
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference)

Example 29 with LocalDocumentReference

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

the class DocumentLocaleReader method sendBeginWikiDocumentLocale.

private void sendBeginWikiDocumentLocale(XARInputFilter proxyFilter, boolean force) throws FilterException {
    if (force || (this.currentDocumentReference != null && this.currentDocumentLocale != null)) {
        LocalDocumentReference reference = new LocalDocumentReference(this.currentDocumentReference, this.currentDocumentLocale);
        if (this.properties.getEntities() != null && !this.properties.getEntities().matches(reference)) {
            throw new SkipEntityException(reference);
        }
        sendBeginWikiDocument(proxyFilter, force);
        if (canSendBeginWikiDocumentLocale(force)) {
            if (!this.properties.isWithHistory()) {
                this.currentDocumentLocaleParameters.remove(XWikiWikiDocumentFilter.PARAMETER_JRCSREVISIONS);
            }
            proxyFilter.beginWikiDocumentLocale(this.currentDocumentLocale, this.currentDocumentLocaleParameters);
            this.sentBeginWikiDocumentLocale = true;
        }
    }
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference)

Example 30 with LocalDocumentReference

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

the class XWikiMessageToolBridgeTest method before.

@Before
public void before() throws Exception {
    Locale.setDefault(Locale.ROOT);
    // checking
    this.preferencesDocumentReference = new DocumentReference(this.oldcore.getXWikiContext().getWikiId(), "XWiki", "XWikiPreferences");
    XWikiDocument preferencesDocument = new XWikiDocument(this.preferencesDocumentReference);
    BaseObject preferencesObject = new BaseObject();
    preferencesObject.setXClassReference(new LocalDocumentReference("XWiki", "XWikiPreferences"));
    preferencesDocument.addXObject(preferencesObject);
    preferencesDocument.setSyntax(Syntax.PLAIN_1_0);
    this.oldcore.getSpyXWiki().saveDocument(preferencesDocument, "", this.oldcore.getXWikiContext());
    this.defaultWikiTranslationReference = new DocumentReference(this.oldcore.getXWikiContext().getWikiId(), "XWiki", "Translations");
    XWikiDocument defaultWikiTranslation = new XWikiDocument(this.defaultWikiTranslationReference);
    defaultWikiTranslation.setSyntax(Syntax.PLAIN_1_0);
    this.oldcore.getSpyXWiki().saveDocument(defaultWikiTranslation, "", this.oldcore.getXWikiContext());
    // MessageTool
    this.tool = new XWikiMessageTool(this.oldcore.getMocker().<ContextualLocalizationManager>getInstance(ContextualLocalizationManager.class));
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) ContextualLocalizationManager(org.xwiki.localization.ContextualLocalizationManager) DocumentReference(org.xwiki.model.reference.DocumentReference) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject) Before(org.junit.Before)

Aggregations

LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)58 Test (org.junit.Test)28 DocumentReference (org.xwiki.model.reference.DocumentReference)25 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)23 BaseObject (com.xpn.xwiki.objects.BaseObject)19 XWikiContext (com.xpn.xwiki.XWikiContext)10 EntityReference (org.xwiki.model.reference.EntityReference)10 ArrayList (java.util.ArrayList)8 ViewPage (org.xwiki.test.ui.po.ViewPage)6 Page (org.xwiki.rest.model.jaxb.Page)5 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)4 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)4 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)4 Event (org.xwiki.observation.event.Event)4 XWiki (com.xpn.xwiki.XWiki)3 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)2 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)2 Principal (java.security.Principal)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2