use of org.xwiki.model.reference.LocalDocumentReference in project xwiki-platform by xwiki.
the class XarExtensionPlan method getNextXarExtension.
public LocalExtension getNextXarExtension(DocumentReference documentReference) {
WikiReference wikiReference = documentReference.getWikiReference();
LocalDocumentReference localDocumentReference = new LocalDocumentReference(documentReference);
return getNextXarExtension(wikiReference.getName(), localDocumentReference);
}
use of org.xwiki.model.reference.LocalDocumentReference in project xwiki-platform by xwiki.
the class XarExtensionPlan method getPreviousXarExtension.
public XarInstalledExtension getPreviousXarExtension(DocumentReference documentReference) {
String wiki = documentReference.getWikiReference().getName();
LocalDocumentReference localDocumentReference = new LocalDocumentReference(documentReference);
return getPreviousXarExtension(wiki, localDocumentReference);
}
use of org.xwiki.model.reference.LocalDocumentReference in project xwiki-platform by xwiki.
the class DocumentMergeImporter method merge.
private XarEntryMergeResult merge(String comment, XWikiDocument currentDocument, XWikiDocument previousDocument, XWikiDocument nextDocument, PackageConfiguration configuration) throws Exception {
XWikiContext xcontext = this.xcontextProvider.get();
// 3 ways merge
XWikiDocument mergedDocument = currentDocument.clone();
MergeConfiguration mergeConfiguration = new MergeConfiguration();
mergeConfiguration.setProvidedVersionsModifiables(true);
MergeResult documentMergeResult;
try {
documentMergeResult = mergedDocument.merge(previousDocument, nextDocument, mergeConfiguration, xcontext);
} catch (Exception e) {
// Unexpected error, lets behave as if there was a conflict
documentMergeResult = new MergeResult();
documentMergeResult.getLog().error("Unexpected exception thrown. Usually means there is a bug in the merge.", e);
documentMergeResult.setModified(true);
}
documentMergeResult.getLog().log(this.logger);
XWikiDocument documentToSave;
if (documentMergeResult.isModified() || !documentMergeResult.getLog().getLogsFrom(LogLevel.ERROR).isEmpty()) {
documentToSave = askDocumentToSave(currentDocument, previousDocument, nextDocument, mergedDocument, configuration, documentMergeResult);
if (documentToSave != currentDocument) {
saveDocument(documentToSave, comment, false, configuration);
}
}
return new XarEntryMergeResult(new XarEntry(new LocalDocumentReference(mergedDocument.getDocumentReferenceWithLocale())), documentMergeResult);
}
use of org.xwiki.model.reference.LocalDocumentReference in project xwiki-platform by xwiki.
the class DefaultModelBridgeTest method testCheckXObjectPresenceWithPresentXObject.
@Test
public void testCheckXObjectPresenceWithPresentXObject() throws Exception {
XWikiDocument document = mock(XWikiDocument.class);
List<String> xObjectTypes = Arrays.asList("type1");
DocumentReference documentReferenceFromDocumentXObjects = mock(DocumentReference.class);
Map<DocumentReference, List<BaseObject>> documentXObjects = new HashMap<DocumentReference, List<BaseObject>>() {
{
put(documentReferenceFromDocumentXObjects, Collections.EMPTY_LIST);
}
};
DocumentReference resolvedType1 = mock(DocumentReference.class);
LocalDocumentReference localDocumentReferenceType1 = mock(LocalDocumentReference.class);
when(resolvedType1.getLocalDocumentReference()).thenReturn(localDocumentReferenceType1);
when(this.documentReferenceResolver.resolve(eq("type1"))).thenReturn(resolvedType1);
when(document.getXObjects()).thenReturn(documentXObjects);
when(documentReferenceFromDocumentXObjects.getLocalDocumentReference()).thenReturn(localDocumentReferenceType1);
assertTrue(this.mocker.getComponentUnderTest().checkXObjectPresence(xObjectTypes, document));
}
use of org.xwiki.model.reference.LocalDocumentReference in project xwiki-platform by xwiki.
the class SendMailConfigClassDocumentConfigurationSourceTest method getPropertyWhenNoSendMailConfigClassXObject.
@Test
public void getPropertyWhenNoSendMailConfigClassXObject() throws Exception {
Cache<Object> cache = mock(Cache.class);
CacheManager cacheManager = this.mocker.getInstance(CacheManager.class);
when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(cache);
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("wiki");
LocalDocumentReference classReference = new LocalDocumentReference("Mail", "SendMailConfigClass");
XWikiDocument document = mock(XWikiDocument.class);
when(document.getXObject(classReference)).thenReturn(null);
DocumentReference documentReference = new DocumentReference("wiki", "Mail", "MailConfig");
XWiki xwiki = mock(XWiki.class);
when(xwiki.getDocument(eq(documentReference), any(XWikiContext.class))).thenReturn(document);
XWikiContext xcontext = mock(XWikiContext.class);
when(xcontext.getWiki()).thenReturn(xwiki);
Provider<XWikiContext> xcontextProvider = this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xcontextProvider.get()).thenReturn(xcontext);
assertEquals("defaultValue", this.mocker.getComponentUnderTest().getProperty("key", "defaultValue"));
}
Aggregations