Move a document
Introduction
The move operation is performed on the subtree corresponding to a given document id and a given area.
We have to :
- compute a new id (to not overwrite an already existing file)
- move the contents (xml file)
- move the resources
- move the policies
- move the revisions
- move the rcml files
- move the workflow for the new documents
- move the node (with the subtree) in the site tree
Implementation
It is implemented in a sequence of usecases to get all needed parameters, and uses the task concept to execute some ant task
To perform the different operations on the desired subtree, we used the visitor pattern
Parameters
Required parameters:
- the area for the source document
- the document id for the source document
- the area for the destination document
- the document id for the destination document
- the task id
usecase
They are implemented in the usecase sitmap (core)
Cut screen
URL :
{document-URL}?lenya.usecase=cut&lenya.step=showscreen
usecase sitemap:
<map:match pattern="cut" type="usecase"> <map:match pattern="showscreen" type="step"> <map:generate src="content/info/cut.xsp" type="serverpages"/> <map:transform src="xslt/info/cut.xsl"/> <map:call resource="style-cms-page"/> </map:match> </map:match>
The parameters for the source are get with the serverpage through the page envelope input module. A form (build with the xslt transformation) sends then the parameters as request parameters with the new URL.
Cut confirmation
URL :
{document-URL}?lenya.usecase=cut&lenya.step=cut&...{source parameters}
usecase sitemap:
<map:match pattern="cut" type="usecase"> <map:match pattern="cut" type="step"> <map:act type="session-propagator"> <map:parameter name="org.apache.lenya.cms.info.firstdocid" value="{request-param:documentid}"/> <map:parameter name="org.apache.lenya.cms.info.firstarea" value="{request-param:area}"/> <map:parameter name="org.apache.lenya.cms.info.cutdocumentid" value="{request-param:documentid}"/> <map:parameter name="org.apache.lenya.cms.info.action" value="{request-param:action}"/> <map:redirect-to uri="{request:requestURI}"/> </map:act> </map:match> </map:match>
The source parameters are saved in the session with the org.apache.cocoon.acting.SessionPropagatorAction
The parameter org.apache.lenya.cms.info.cutdocumentid is used to change the representation of the cutted node in the info sitetree.
Paste screen
URL :
{document-URL}?lenya.usecase=paste&lenya.step=showscreen
usecase sitemap (Core):
<map:match pattern="paste" type="usecase"> <map:match pattern="showscreen" type="step"> <map:generate src="content/info/paste.xsp" type="serverpages"/> <map:transform src="xslt/info/paste.xsl"/> <map:call resource="style-cms-page"/> </map:match> </map:match>
The parameters for the destination are get with the serverpage through the page envelope input module. Parameters needed by the access controller are also get with this serverpage through the access control input module. The parameters for the source are get from the session with the serverpage . A form (build with the xslt transformation) sends then the parameters as request parameters with the new URL.
Paste confirmation
URL :
{document-URL}?lenya.usecase=paste&lenya.step=paste&...{parameters}
usecase sitemap (Core):
<map:match pattern="paste" type="usecase"> <map:match pattern="paste" type="step"> <map:select type="request-parameter"> <map:parameter name="parameter-name" value="task-id"/> <map:when test="moveDocument"> <map:act type="session-propagator"> <map:parameter name="org.apache.lenya.cms.info.firstdocid" value=""/> <map:parameter name="org.apache.lenya.cms.info.cutdocumentid" value=""/> </map:act> </map:when> <map:otherwise> <map:act type="session-propagator"> <map:parameter name="org.apache.lenya.cms.info.cutdocumentid" value=""/> </map:act> </map:otherwise> </map:select> <map:act type="task"> <map:redirect-to session="true" uri="{request:requestURI}"/> </map:act> </map:match> </map:match>
The action org.apache.lenya.cms.cocoon.acting.TaskAction calls the execution of the ant task.
The parameter org.apache.lenya.cms.info.cutdocumentid is set to "", because the cutted node is no more present.
Ant Task
The ant target moveDocument
is in the publication :
{publication}/config/tasks/targets.xml
and depends on the different targets
-
firstareaproperties
, to set the needed properties dependent of the source area -
secareaproperties
, to set the needed properties dependent of the destination area -
newcopydocumentid
, to compute the unique destination id -
firstdocumentpath
, to compute the directory of the source contents (Needed for the revisions and the rcml files) -
secdocumentpath
, to compute the directory of the destination contents (Needed for the revisions and the rcml files) -
move
, to execute the different move operations
For more information about the Ant task, see the documentation Ant Task and the Javadocs.