<?xml version="1.0" encoding="UTF-8"?>
<!--

    The contents of this file are subject to the license and copyright
    detailed in the LICENSE and NOTICE files at the root of the source
    tree and available online at

    http://www.dspace.org/license/

-->


<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

    <map:components>

        <map:transformers>
            <map:transformer name="VersionHistoryForm" src="org.dspace.app.xmlui.aspect.versioning.VersionHistoryForm"/>
            <map:transformer name="VersionItemForm" src="org.dspace.app.xmlui.aspect.versioning.VersionItemForm"/>
            <map:transformer name="DeleteVersionsConfirm"
                             src="org.dspace.app.xmlui.aspect.versioning.DeleteVersionsConfirm"/>
            <map:transformer name="RestoreVersionForm" src="org.dspace.app.xmlui.aspect.versioning.RestoreVersionForm"/>
            <map:transformer name="Navigation"
                             src="org.dspace.app.xmlui.aspect.versioning.Navigation"/>
            <map:transformer name="VersionUpdateForm" src="org.dspace.app.xmlui.aspect.versioning.VersionUpdateForm"/>
            <map:transformer name="VersionNoticeTransformer" src="org.dspace.app.xmlui.aspect.versioning.VersionNoticeTransformer"/>
        </map:transformers>

        <map:matchers default="wildcard">
            <map:matcher name="HandleTypeMatcher" src="org.dspace.app.xmlui.aspect.general.HandleTypeMatcher"/>
            <map:matcher name="HandleAuthorizedMatcher" src="org.dspace.app.xmlui.aspect.general.HandleAuthorizedMatcher"/>
        </map:matchers>

        <map:selectors>
            <map:selector name="AuthenticatedSelector" src="org.dspace.app.xmlui.aspect.general.AuthenticatedSelector"/>
        </map:selectors>
    </map:components>


    <map:flow language="javascript">
        <map:script src="versioning.js"/>
    </map:flow>

    <map:pipelines>

        <map:pipeline>


            <map:select type="AuthenticatedSelector">
                <map:when test="eperson">
                    <map:match pattern="item/version">
                        <map:match type="request" pattern="versioning-continue">
                            <map:call continuation="{1}"/>
                        </map:match>

                        <map:match type="request" pattern="itemID">
                            <map:call function="startCreateNewVersionItem"/>
                        </map:match>
                    </map:match>

                    <map:match pattern="item/versionhistory">
                        <map:match type="request" pattern="versioning-continue">
                            <map:call continuation="{1}"/>
                        </map:match>

                        <map:match type="request" pattern="itemID">
                            <map:call function="startVersionHistoryItem"/>
                        </map:match>
                    </map:match>
                </map:when>
                <map:otherwise>
                    <map:match pattern="item/version">
                        <map:act type="StartAuthentication"/>
                    </map:match>

                    <map:match pattern="item/versionhistory">
                        <map:act type="StartAuthentication"/>
                    </map:match>
                </map:otherwise>
            </map:select>

            <map:generate/>

            <map:select type="AuthenticatedSelector">
                <map:when test="eperson">
                    <map:transform type="Navigation">
                        <map:parameter name="itemID" value="{flow-attribute:itemID}"/>
                    </map:transform>

                    <map:match pattern="item/version/create">
                        <map:transform type="VersionItemForm">
                            <map:parameter name="itemID" value="{flow-attribute:itemID}"/>
                            <map:parameter name="summary" value="{flow-attribute:summary}"/>
                        </map:transform>
                    </map:match>


                    <map:match pattern="item/versionhistory/show">
                        <map:transform type="VersionHistoryForm">
                            <map:parameter name="itemID" value="{flow-attribute:itemID}"/>
                        </map:transform>
                    </map:match>

                    <map:match pattern="item/versionhistory/delete">
                        <map:transform type="DeleteVersionsConfirm">
                            <map:parameter name="versionIDs" value="{flow-attribute:versionIDs}"/>
                        </map:transform>
                    </map:match>

                    <map:match pattern="item/versionhistory/restore">
                        <map:transform type="RestoreVersionForm">
                            <map:parameter name="itemID" value="{flow-attribute:itemID}"/>
                            <map:parameter name="versionID" value="{flow-attribute:versionID}"/>
                        </map:transform>
                    </map:match>

                    <map:match pattern="item/versionhistory/update">
                        <map:transform type="VersionUpdateForm">
                            <map:parameter name="itemID" value="{flow-attribute:itemID}"/>
                            <map:parameter name="versionID" value="{flow-attribute:versionID}"/>
                        </map:transform>
                    </map:match>
                </map:when>
            </map:select>

            <map:match pattern="handle/*/*">
                <map:match type="HandleAuthorizedMatcher" pattern="READ">
                    <map:match type="HandleTypeMatcher" pattern="item">
                        <map:transform type="VersionNoticeTransformer" />

                        <map:transform type="VersionHistoryForm"/>
                    </map:match>
                </map:match>
            </map:match>


            <map:serialize type="xml"/>
        </map:pipeline>


    </map:pipelines>

</map:sitemap>
