From e3a3dfefab76dc570dc7d674d122f0432aa005a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Cotiug=C4=83?= Date: Sun, 7 Nov 2021 20:35:02 +0200 Subject: [PATCH] Step 5 post import fixes is not understandable enough #33 * use the number of total Confluence pages counted at the space analyze step * minor code refactoring to use the profile script service and get data from profile --- .../Confluence/Tools/CheckInvalidParents.xml | 16 ++--- .../Confluence/Tools/CheckParents.xml | 16 ++--- .../Tools/DetectPageNameTooLong.xml | 17 ++--- .../Confluence/Tools/LongPageNames.xml | 71 ++++++++----------- 4 files changed, 44 insertions(+), 76 deletions(-) diff --git a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckInvalidParents.xml b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckInvalidParents.xml index 6a29da6..3d3e999 100644 --- a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckInvalidParents.xml +++ b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckInvalidParents.xml @@ -40,19 +40,11 @@ println """= ${services.localization.render('confluence.migrator.postImportFixes.checkInvalidParents')} =""" def escapetool = new org.xwiki.velocity.tools.EscapeTool() -def space = null -def activeProfileDoc = null -def activeProfileObj = xwiki.getDocument('Confluence.Migrator.Profiles.WebHome').getObject('Confluence.Tools.ActiveMigrationProfileClass') -if (activeProfileObj != null) { - def activeProfile = activeProfileObj.getProperty('profile').value - if(activeProfile) { - activeProfileDoc = xwiki.getDocument(activeProfile); - def profileObj = xwiki.getDocument(activeProfile).getObject('Confluence.Tools.MigrationProfileClass') - space = profileObj.getProperty('space').value - } -} +def activeProfile = services.confluencemigrator.profile.activeProfile +def activeProfileDoc = xwiki.getDocument(activeProfile) +def space = activeProfileDoc.getValue('space') +def nb = activeProfileDoc.getValue('totalPages') -def nb = 10 if (request.space) space = request.space if (request.nb) diff --git a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckParents.xml b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckParents.xml index 82d502e..fad65cb 100644 --- a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckParents.xml +++ b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/CheckParents.xml @@ -40,19 +40,11 @@ println """= ${services.localization.render('confluence.migrator.postImportFixes.checkParents')} =""" def escapetool = new org.xwiki.velocity.tools.EscapeTool() -def space = null -def activeProfileDoc = null -def activeProfileObj = xwiki.getDocument('Confluence.Migrator.Profiles.WebHome').getObject('Confluence.Tools.ActiveMigrationProfileClass') -if (activeProfileObj != null) { - def activeProfile = activeProfileObj.getProperty('profile').value - if(activeProfile) { - activeProfileDoc = xwiki.getDocument(activeProfile); - def profileObj = xwiki.getDocument(activeProfile).getObject('Confluence.Tools.MigrationProfileClass') - space = profileObj.getProperty('space').value - } -} +def activeProfile = services.confluencemigrator.profile.activeProfile +def activeProfileDoc = xwiki.getDocument(activeProfile) +def space = activeProfileDoc.getValue('space') +def nb = activeProfileDoc.getValue('totalPages') -def nb = 10 def fixParents = request.fixParents == 'true' def buttonClassNames = 'button ' if(request.space && request.space.trim() != '') { diff --git a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/DetectPageNameTooLong.xml b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/DetectPageNameTooLong.xml index 3f4c84c..cc011c1 100644 --- a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/DetectPageNameTooLong.xml +++ b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/DetectPageNameTooLong.xml @@ -39,18 +39,11 @@ {{groovy}} println """= ${services.localization.render('confluence.migrator.postImportFixes.detectLongPages')} =""" def escapetool = new org.xwiki.velocity.tools.EscapeTool() -def space = null -def activeProfileDoc = null -def activeProfileObj = xwiki.getDocument('Confluence.Migrator.Profiles.WebHome').getObject('Confluence.Tools.ActiveMigrationProfileClass') -if (activeProfileObj != null) { - def activeProfile = activeProfileObj.getProperty('profile').value - if(activeProfile) { - activeProfileDoc = xwiki.getDocument(activeProfile); - def profileObj = xwiki.getDocument(activeProfile).getObject('Confluence.Tools.MigrationProfileClass') - space = profileObj.getProperty('space').value - } -} -def nb = 10 + +def activeProfile = services.confluencemigrator.profile.activeProfile +def activeProfileDoc = xwiki.getDocument(activeProfile) +def space = activeProfileDoc.getValue('space') +def nb = activeProfileDoc.getValue('totalPages') def maxlength = 30 if (request.space) space = request.space diff --git a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/LongPageNames.xml b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/LongPageNames.xml index 7cd6a5f..f94da49 100644 --- a/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/LongPageNames.xml +++ b/application-confluence-migrator-ui/src/main/resources/Confluence/Tools/LongPageNames.xml @@ -42,6 +42,12 @@ def maxLength = 25 def log = services.logging.getLogger(doc.fullName) + + def activeProfile = services.confluencemigrator.profile.activeProfile + def activeProfileDoc = xwiki.getDocument(activeProfile) + def space = activeProfileDoc.getValue('space') + def nb = activeProfileDoc.getValue('totalPages') + public getNameProposal(name, space, log, newNameList, maxLength) { def splitname = name.replaceAll("/","_").replaceAll("[.]","_").replaceAll(" _ ", "_").replaceAll("[^\\dA-Za-z_ ]"," ").replaceAll('_', " ")replaceAll("\\s+"," ").split(' ') def newname = splitname[0] @@ -137,8 +143,6 @@ } try { - def space = 'KHNYG'; - def nb = 1000; def testRun = 1; if (request.nb) { @@ -159,44 +163,31 @@ {{velocity}} = $services.localization.render('confluence.migrator.postImportFixes.longNamesHandling') = #if ("$request.confirm" != 'true') - #set ($space = '') - #set ($activeProfileObj = $xwiki.getDocument('Confluence.Migrator.Profiles.WebHome').getObject('Confluence.Tools.ActiveMigrationProfileClass')) - #if ($activeProfileObj) - #set ($activeProfile = $activeProfileObj.getValue('profile')) - #if ($activeProfile) - #set ($activeProfileDoc = $xwiki.getDocument($activeProfile)) - #set ($profileObj = $xwiki.getDocument($activeProfile).getObject('Confluence.Tools.MigrationProfileClass')) - #set ($space = $profileObj.getValue('space')) - #end - #end - #if ($request.space) - #set ($space = $request.space) - #end - #set($nb = "100") - #if($request.nb) - #set($nb = $request.nb) - #end -{{html clean=false}} -<form action="" method="post" class="xform"> -<dl> - <dt> - <label for="space">$escapetool.xml($services.localization.render('confluence.migrator.parents.space'))</label> - <span class="xHint">$escapetool.xml($services.localization.render('confluence.migrator.parents.space.hint'))</span> - </dt> - <dd> - <input type="text" name="space" value="$escapetool.xml($space)" /> - </dd> - <dt> - <label for="nb">$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb'))</label> - <span class="xHint">$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb.hint'))</span> - </dt> - <dd> - <input type="text" name="nb" value="$escapetool.xml($nb)" size="10" /> - </dd> -</dl> -<input name="submit" type="submit" value="Go" class="button" /> -</form> -{{/html}} + #set ($activeProfile = $services.confluencemigrator.profile.activeProfile) + #set ($activeProfileDoc = $xwiki.getDocument($activeProfile)) + #set ($space = $activeProfileDoc.getValue('space')) + #set ($nb = $activeProfileDoc.getValue('totalPages')) + {{html clean=false}} + <form action="" method="post" class="xform"> + <dl> + <dt> + <label for="space">$escapetool.xml($services.localization.render('confluence.migrator.parents.space'))</label> + <span class="xHint">$escapetool.xml($services.localization.render('confluence.migrator.parents.space.hint'))</span> + </dt> + <dd> + <input type="text" name="space" value="$escapetool.xml($space)" /> + </dd> + <dt> + <label for="nb">$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb'))</label> + <span class="xHint">$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb.hint'))</span> + </dt> + <dd> + <input type="text" name="nb" value="$escapetool.xml($nb)" size="10" /> + </dd> + </dl> + <input name="submit" type="submit" value="Go" class="button" /> + </form> + {{/html}} #else $response.sendRedirect($doc.getURL("view")) #end