use of com.xpn.xwiki.doc.DocumentRevisionProvider in project xwiki-platform by xwiki.
the class DefaultDocumentRevisionProvider method getRevision.
@Override
public XWikiDocument getRevision(DocumentReference reference, String revision) throws XWikiException {
// Parse the version
String revisionPrefix = null;
if (revision != null) {
int revisionPrefixIndex = revision.indexOf(':');
if (revisionPrefixIndex > 0) {
revisionPrefix = revision.substring(0, revisionPrefixIndex);
}
}
String shortRevision;
if (revisionPrefix != null) {
shortRevision = revision.substring(revisionPrefix.length() + 1);
} else {
shortRevision = revision;
}
// Find the provider
DocumentRevisionProvider provider = this.databaseDocumentRevisionProvider;
if (revisionPrefix != null) {
ComponentManager componentManager = this.componentManagerProvider.get();
if (componentManager.hasComponent(DocumentRevisionProvider.class, revisionPrefix)) {
try {
provider = componentManager.getInstance(DocumentRevisionProvider.class, revisionPrefix);
} catch (ComponentLookupException e) {
throw new XWikiException("Failed to get revision provider for revision [" + revision + "]", e);
}
}
}
// Load the document revision
return provider.getRevision(reference, shortRevision);
}
Aggregations