use of org.xwiki.extension.xar.job.diff.DocumentVersionReference in project xwiki-platform by xwiki.
the class DiffXarJob method diff.
private void diff(XWikiDocument document, ExtensionId extensionId) {
if (getRequest().isVerbose()) {
this.logger.info("Computing differences for document [{}]", document.getDocumentReferenceWithLocale());
}
// Use the extension id as the document version.
XWikiDocument previousDocument = document.duplicate(new DocumentVersionReference(document.getDocumentReference(), extensionId));
XWikiContext xcontext = this.xcontextProvider.get();
try {
XWikiDocument nextDocument = xcontext.getWiki().getDocument(document.getDocumentReferenceWithLocale(), xcontext);
if (nextDocument.isNew()) {
nextDocument = null;
}
maybeAddDocumentDiff(this.documentDiffBuilder.diff(previousDocument, nextDocument));
} catch (XWikiException e) {
this.logger.error("Failed to get document [{}] from the database.", document.getDocumentReference(), e);
}
}
use of org.xwiki.extension.xar.job.diff.DocumentVersionReference in project xwiki-platform by xwiki.
the class XarInstalledExtensionRepository method getXarInstalledExtensions.
/**
* @param reference the reference of the document
* @return the extension owners of the passed document
* @since 8.1M2
*/
public Collection<XarInstalledExtension> getXarInstalledExtensions(DocumentReference reference) {
if (reference instanceof DocumentVersionReference) {
DocumentVersionReference versionReference = (DocumentVersionReference) reference;
if (versionReference.getVersion() instanceof ExtensionId) {
ExtensionId extensionId = (ExtensionId) versionReference.getVersion();
if (extensionId != null) {
return Arrays.asList((XarInstalledExtension) getInstalledExtension(extensionId));
}
}
}
Collection<XarInstalledExtension> wikiExtensions = this.documents.get(reference.getLocale() == null ? new DocumentReference(reference, Locale.ROOT) : reference);
Collection<XarInstalledExtension> rootExtensions = this.rootDocuments.get(reference.getLocalDocumentReference().getLocale() == null ? new LocalDocumentReference(reference.getLocalDocumentReference(), Locale.ROOT) : reference.getLocalDocumentReference());
List<XarInstalledExtension> allExtensions = new ArrayList<>();
if (wikiExtensions != null) {
allExtensions.addAll(wikiExtensions);
}
if (rootExtensions != null) {
allExtensions.addAll(rootExtensions);
}
return allExtensions;
}
Aggregations