use of org.xwiki.extension.distribution.internal.DocumentsModifiedDuringDistributionListener.DocumentStatus in project xwiki-platform by xwiki.
the class DistributionInternalScriptService method getModifiedDocumentsTree.
/**
* @return the document modified during the Distribution Wizard execution
* @since 5.4RC1
*/
public Map<String, Map<String, Map<String, Map<String, DocumentStatus>>>> getModifiedDocumentsTree() {
Map<DocumentReference, DocumentStatus> documents = ((DocumentsModifiedDuringDistributionListener) this.modifiedDocumentsListener).getDocuments().get(this.xcontextProvider.get().getWikiId());
Map<String, Map<String, Map<String, Map<String, DocumentStatus>>>> tree = new TreeMap<>();
if (documents != null) {
for (Map.Entry<DocumentReference, DocumentStatus> document : documents.entrySet()) {
DocumentReference reference = document.getKey();
String wiki = reference.getWikiReference().getName();
// TODO: add support for subspaces
String space = reference.getLastSpaceReference().getName();
String page = reference.getName();
String locale = reference.getLocale() != null ? reference.getLocale().toString() : "";
Map<String, Map<String, Map<String, DocumentStatus>>> spaces = tree.get(wiki);
if (spaces == null) {
spaces = new TreeMap<>();
tree.put(wiki, spaces);
}
Map<String, Map<String, DocumentStatus>> pages = spaces.get(space);
if (pages == null) {
pages = new TreeMap<>();
spaces.put(space, pages);
}
Map<String, DocumentStatus> locales = pages.get(page);
if (locales == null) {
locales = new TreeMap<>();
pages.put(page, locales);
}
locales.put(locale, document.getValue());
}
}
return tree;
}
Aggregations