Search in sources :

Example 1 with DocumentStatus

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;
}
Also used : DocumentStatus(org.xwiki.extension.distribution.internal.DocumentsModifiedDuringDistributionListener.DocumentStatus) TreeMap(java.util.TreeMap) Map(java.util.Map) TreeMap(java.util.TreeMap) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 DocumentStatus (org.xwiki.extension.distribution.internal.DocumentsModifiedDuringDistributionListener.DocumentStatus)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1