Skip to content

Commit

Permalink
Step 5 post import fixes is not understandable enough #33
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
acotiuga committed Nov 7, 2021
1 parent 8046157 commit e3a3dfe
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() != '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@
<content>{{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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -137,8 +143,6 @@
}

try {
def space = 'KHNYG';
def nb = 1000;
def testRun = 1;

if (request.nb) {
Expand All @@ -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}}
&lt;form action="" method="post" class="xform"&gt;
&lt;dl&gt;
&lt;dt&gt;
&lt;label for="space"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.space'))&lt;/label&gt;
&lt;span class="xHint"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.space.hint'))&lt;/span&gt;
&lt;/dt&gt;
&lt;dd&gt;
&lt;input type="text" name="space" value="$escapetool.xml($space)" /&gt;
&lt;/dd&gt;
&lt;dt&gt;
&lt;label for="nb"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb'))&lt;/label&gt;
&lt;span class="xHint"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb.hint'))&lt;/span&gt;
&lt;/dt&gt;
&lt;dd&gt;
&lt;input type="text" name="nb" value="$escapetool.xml($nb)" size="10" /&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;input name="submit" type="submit" value="Go" class="button" /&gt;
&lt;/form&gt;
{{/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}}
&lt;form action="" method="post" class="xform"&gt;
&lt;dl&gt;
&lt;dt&gt;
&lt;label for="space"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.space'))&lt;/label&gt;
&lt;span class="xHint"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.space.hint'))&lt;/span&gt;
&lt;/dt&gt;
&lt;dd&gt;
&lt;input type="text" name="space" value="$escapetool.xml($space)" /&gt;
&lt;/dd&gt;
&lt;dt&gt;
&lt;label for="nb"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb'))&lt;/label&gt;
&lt;span class="xHint"&gt;$escapetool.xml($services.localization.render('confluence.migrator.parents.pagesnb.hint'))&lt;/span&gt;
&lt;/dt&gt;
&lt;dd&gt;
&lt;input type="text" name="nb" value="$escapetool.xml($nb)" size="10" /&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;input name="submit" type="submit" value="Go" class="button" /&gt;
&lt;/form&gt;
{{/html}}
#else
$response.sendRedirect($doc.getURL("view"))
#end
Expand Down

0 comments on commit e3a3dfe

Please sign in to comment.