<?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/

-->

<!--
  
  The Submission Aspect is responsible for submitting new items to DSpace repository.
  
-->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

  <map:components>
    <map:transformers>
      <map:transformer name="Navigation" src="org.dspace.app.xmlui.aspect.submission.Navigation"/>
      <map:transformer name="CollectionViewer" src="org.dspace.app.xmlui.aspect.submission.CollectionViewer"/>
      <map:transformer name="Submissions" src="org.dspace.app.xmlui.aspect.submission.Submissions"/>
      
      <map:transformer name="StepTransformer" src="org.dspace.app.xmlui.aspect.submission.StepTransformer"/>
      
      <map:transformer name="SelectCollectionStep" src="org.dspace.app.xmlui.aspect.submission.submit.SelectCollectionStep"/>
      <map:transformer name="ResumeStep" src="org.dspace.app.xmlui.aspect.submission.submit.ResumeStep"/>
      <map:transformer name="SaveOrRemoveStep" src="org.dspace.app.xmlui.aspect.submission.submit.SaveOrRemoveStep"/>
      <map:transformer name="RemovedStep" src="org.dspace.app.xmlui.aspect.submission.submit.RemovedStep"/>
      <map:transformer name="CompletedStep" src="org.dspace.app.xmlui.aspect.submission.submit.CompletedStep"/>
      <map:transformer name="ControlledVocabularyTransformer" src="org.dspace.app.xmlui.aspect.submission.ControlledVocabularyTransformer"/>
    </map:transformers>
    
    <map:selectors>
      <map:selector name="AuthenticatedSelector" src="org.dspace.app.xmlui.aspect.general.AuthenticatedSelector"/>
    </map:selectors>
    
    <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:matcher name="regexp" src="org.apache.cocoon.matching.RegexpURIMatcher"/>
    </map:matchers>
    
    <map:actions>
      <map:action name="RemoveSubmissionsAction" src="org.dspace.app.xmlui.aspect.submission.submit.RemoveSubmissionsAction"/>
    </map:actions>
    
  </map:components>
  
  
  <map:flow language="javascript">
    <map:script src="submission.js"/>
  </map:flow>
  
  <map:pipelines>
    <map:pipeline>
    
      <!-- Make sure the user is atleast logged in -->
      <map:select type="AuthenticatedSelector">
        <map:when test="eperson">
          
          <!--
              There are two major flows that are present in the submissions & workflow
              aspects, one for new submissions to the repository, and another for reviewing
              those submissions in a 3-stage workflow processes. Below are the starting
              points and re-entry points for those workflows.
              
              /submit               -> New submissions that have not selected a collection yet.
              /handle/*/*/submit    -> Submitting a new item to the repository.
              /handle/*/*/workflow  -> Performing workflow tasks to review submissions.
              -->
          
          <!-- Start a new submission, unscoped -->
          <map:match pattern="submit">
              <map:call function="doSubmission"/>
          </map:match>
          
          <!-- Continue creating a new submission, unscoped -->
          <map:match pattern="submit/*.continue">
             <map:call continuation="{1}"/>
          </map:match>
          
          <!-- Start a new submission to specific collection -->
          <map:match pattern="handle/*/*/submit">
            <map:call function="doSubmission">
              <map:parameter name="handle" value="{1}/{2}"/>
            </map:call>
          </map:match>
          
          <!-- Continue an existing submission-->
          <map:match pattern="handle/*/*/submit/*.continue">
             <map:call continuation="{3}"/>
          </map:match>
          

          <map:match pattern="handle/*/*/workflow_edit_metadata">
            <map:call function="doWorkflowEditMetadata">
              <map:parameter name="handle" value="{1}/{2}"/>
            </map:call>
            </map:match>

          
          <map:generate/>

          
          <map:transform type="Navigation"/>
          
          
          
          <!--
              To make it easier to start a submission this component
              will add a link to the collection homepage for submitting
              new items to the collection.
              -->
          <map:match pattern="handle/*/*">
            <map:match type="HandleTypeMatcher" pattern="collection">
               <map:match type="HandleAuthorizedMatcher" pattern="READ">
                 <map:transform type="CollectionViewer"/>
               </map:match>
             </map:match>
          </map:match>
          
          <!--
              The submissions page provides a list of all submission
              related tasks/items/thingys. It is used by both those
              who are submitting new items to dspace and those who are
              reviewing those submissions.
              -->
          <map:match pattern="submissions">
            <!---->
            <!--<map:match type="request" pattern="submit_take_tasks">-->
              <!--<map:act type="ClaimTasksAction"/>-->
            <!--</map:match>-->
            <!---->
            <!--<map:match type="request" pattern="submit_return_tasks">-->
              <!--<map:act type="UnclaimTasksAction"/>-->
            <!--</map:match>-->

            <map:match type="request" pattern="submit_submissions_remove">
              <map:act type="RemoveSubmissionsAction"/>
            </map:match>
             
            <map:transform type="Submissions"/>
          </map:match>
          
          
          
          
          
          <!--
           
              Flow pages Steps
              
              -->
          <map:match type="WildcardParameterMatcher" pattern="true">
            <map:parameter name="parameter-name" value="flow"/>
            <map:parameter name="flow" value="{flow-attribute:flow}"/>

            <!-- Submission related steps -->
            
            <!--
                This step will ask the user to select a collection they want
                to submit an item to. It is not part of the 'proper' submission
                steps in that it is not displayed in the progress list and is
                often skipped because the user has already selected a collection.
                -->
            <map:match pattern="submit/selectCollectionStep">
              <map:transform type="SelectCollectionStep">
                <map:parameter name="handle" value="{flow-attribute:handle}"/>
              </map:transform>
            </map:match>
          
            <!--
              This is just a continuation of the submission workflow. The generic
              submission step transformer determines which step we are on
              and forwards to the appropriate step transformer class to
              generate the necessary DRI!
            -->
            <map:match pattern="handle/*/*/submit/continue">
              <map:transform type="StepTransformer">
                <map:parameter name="id" value="{flow-attribute:id}"/>
                <map:parameter name="step" value="{flow-attribute:step}"/>
                <map:parameter name="transformer" value="{flow-attribute:transformer}"/>
                <map:parameter name="error" value="{flow-attribute:error}"/>
                <map:parameter name="error_fields" value="{flow-attribute:error_fields}"/>
                <map:parameter name="handle" value="{1}/{2}"/>
              </map:transform>
            </map:match>
          
            <!--
                This step is used when resuming unfinished submissions, the user is
                taken here after clicking the link from the submissions page.
                -->
            <map:match pattern="handle/*/*/submit/resumeStep">
              <map:transform type="ResumeStep">
                <map:parameter name="id" value="{flow-attribute:id}"/>
                <map:parameter name="step" value="{flow-attribute:step}"/>
              </map:transform>
            </map:match>
              
            <!--
                This step is used throughout the submission processes for when
                even the user clicks save / cancel. At this page they are asked
                if they would like to keep the submission or remove it.
                -->
            <map:match pattern="handle/*/*/submit/saveOrRemoveStep">
              <map:transform type="SaveOrRemoveStep">
                <map:parameter name="id" value="{flow-attribute:id}"/>
                <map:parameter name="step" value="{flow-attribute:step}"/>
              </map:transform>
            </map:match>
          
            <!--
                This is step is a confirmation page that the submission was
                successfully removed from the system.
                -->
            <map:match pattern="handle/*/*/submit/removedStep">
              <map:transform type="RemovedStep"/>
            </map:match>
            
            <!--
                This step is merely a confirmation page letting the user
                know that they have completed submitting a new item to dspace.
                -->
            <map:match pattern="handle/*/*/submit/completedStep">
              <map:transform type="CompletedStep">
                <map:parameter name="handle" value="{flow-attribute:handle}"/>
              </map:transform>
            </map:match>
            
          </map:match> <!-- flow match-->
          
          <!-- javascript libraries and utils for choice/authority-control -->
          <map:match type="regexp" pattern="(^submit)|(^handle/.*/submit)|(^handle/.*/workflow)">
            <map:transform type="IncludePageMeta">
              <map:parameter name="javascript.static#1" value="loadJQuery.js"/>
              <map:parameter name="javascript.static#2" value="static/js/vocabulary-support.js"/>
              <map:parameter name="javascript.static#3" value="static/js/scriptaculous/prototype.js"/>
              <map:parameter name="javascript.static#4" value="static/js/scriptaculous/effects.js"/>
              <map:parameter name="javascript.static#5" value="static/js/scriptaculous/builder.js"/>
              <map:parameter name="javascript.static#6" value="static/js/scriptaculous/controls.js"/>
              <map:parameter name="javascript.static#7" value="static/js/choice-support.js"/>
            </map:transform>
          </map:match>

            <map:match pattern="controlled-vocabulary-dialog">
                <map:transform type="ControlledVocabularyTransformer"/>
            </map:match>

          <map:serialize type="xml"/>
          
        </map:when>
        <map:otherwise>
          
          <!-- non-authenticated users -->
          <map:generate/>
          
          <!--
              If the user is going to the submissions page and they are
              not logged in then ask them to login first. This will also
              handle cases where user's sessions are timed out, after logging
              back in they will be able to resume their flow.
              -->
          <map:match pattern="submissions">
            <map:act type="StartAuthentication"/>
          </map:match>

          <map:match pattern="submit">
            <map:act type="StartAuthentication"/>
          </map:match>

          <map:match pattern="handle/*/*/submit">
            <map:act type="StartAuthentication"/>
          </map:match>
    
          <map:serialize/>
          
        </map:otherwise>
      </map:select>

    </map:pipeline>
  </map:pipelines>
  
  
</map:sitemap>
