@Override public void renameLinks( DocumentReference documentReference, DocumentReference oldLinkTarget, DocumentReference newLinkTarget) { boolean popLevelProgress = false; try { XWikiContext xcontext = this.xcontextProvider.get(); XWikiDocument document = xcontext.getWiki().getDocument(documentReference, xcontext); List<Locale> locales = document.getTranslationLocales(xcontext); this.progressManager.pushLevelProgress(1 + locales.size(), this); popLevelProgress = true; // Update the default locale instance. this.progressManager.startStep(this); renameLinks(document, oldLinkTarget, newLinkTarget); // Update the translations. for (Locale locale : locales) { this.progressManager.startStep(this); renameLinks(document.getTranslatedDocument(locale, xcontext), oldLinkTarget, newLinkTarget); } } catch (XWikiException e) { this.logger.error( "Failed to rename the links that target [{}] from [{}].", oldLinkTarget, documentReference, e); } finally { if (popLevelProgress) { this.progressManager.popLevelProgress(this); } } }
@Override public void beginWikiDocument(String name, FilterEventParameters parameters) throws FilterException { super.beginWikiDocument(name, parameters); DocumentReference reference = new DocumentReference(this.currentReference); XWikiContext xcontext = this.xcontextProvider.get(); XWikiDocument defaultDocument; try { defaultDocument = xcontext.getWiki().getDocument(reference, xcontext); } catch (XWikiException e) { throw new FilterException("Failed to get document [" + reference + "]", e); } // Default document locale this.documentLocaleParser.write(defaultDocument, this.filter, this.properties); List<Locale> locales; try { locales = defaultDocument.getTranslationLocales(xcontext); } catch (XWikiException e) { throw new FilterException("Failed to get translations of document [" + reference + "]", e); } // Translations for (Locale locale : locales) { try { XWikiDocument translationDocument = defaultDocument.getTranslatedDocument(locale, xcontext); this.documentLocaleParser.write(translationDocument, this.filter, this.properties); } catch (XWikiException e) { throw new FilterException( "Failed to get document [" + reference + "] for locale [" + locale + "]", e); } } }