<?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 ViewArtifacts Aspect is responsible for viewing communities /
collections / items / and bitstreams
-->

<!-- Added request-item support
	Original Concept, JSPUI version:    Universidade do Minho   at www.uminho.pt
    Sponsorship of XMLUI version:    Instituto Oceanográfico de España at www.ieo.es -->
    
<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.viewArtifacts.Navigation" />
			<map:transformer name="CommunityViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.CommunityViewer" />
			<map:transformer name="CollectionViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.CollectionViewer" />
			<map:transformer name="ItemViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemViewer" />
			<map:transformer name="ItemRequestForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestForm" />
			<map:transformer name="ItemRequestSent" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestSent" />
			<map:transformer name="FeedbackForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.FeedbackForm" />
			<map:transformer name="FeedbackSent" src="org.dspace.app.xmlui.aspect.artifactbrowser.FeedbackSent" />
			<map:transformer name="Contact" src="org.dspace.app.xmlui.aspect.artifactbrowser.Contact" />
			<map:transformer name="RestrictedItem" src="org.dspace.app.xmlui.aspect.artifactbrowser.RestrictedItem" />
			<map:transformer name="ItemRequestResponseDecisionForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseDecisionForm" />
			<map:transformer name="ItemRequestChangeStatusForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestChangeStatusForm" />
            <map:transformer name="ItemRequestContactAuthor" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestContactAuthor" />
            <map:transformer name="ItemRequestContactRequester" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestContactRequester" />
			<map:transformer name="ItemRequestResponseFalseForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseFalseForm" />
			<map:transformer name="ItemRequestResponseTrueForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseTrueForm" />
            <map:transformer name="ItemRequestResponseSent" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseSent" />
			<map:transformer name="ItemRequestStatusChanged" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestStatusChanged" />

            <map:transformer name="Statistics" src="org.dspace.app.xmlui.aspect.artifactbrowser.StatisticsViewer"/>
        </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:matcher name="ContainerHomePageSelector" src="org.dspace.app.xmlui.aspect.viewArtifacts.ContainerHomePageMatcher"/>
			<map:matcher name="ConfigurationMatcher" src="org.dspace.app.xmlui.aspect.general.ConfigurationMatcher" />
		</map:matchers>


		<map:actions>
			<map:action name="SendFeedbackAction" src="org.dspace.app.xmlui.aspect.artifactbrowser.SendFeedbackAction" />
			<map:action name="SendItemRequestAction" src="org.dspace.app.xmlui.aspect.artifactbrowser.SendItemRequestAction" />
			<map:action name="UsageLoggerAction" src="org.dspace.app.xmlui.cocoon.UsageLoggerAction" />
			<map:action name="NotModifiedAction" src="org.dspace.app.xmlui.aspect.general.NotModifiedAction" />
			<map:action name="ItemRequestResponseAction" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseAction" />
		</map:actions>


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


	</map:components>
	<map:pipelines>
		<map:pipeline>


                        <map:generate/>

                        <!--
                                        Add the basic navigation content to every page. This includes:

                                        1) Metadata about the current page (really just what the current
                                           context path is)
                                        2) Navigation links to browse the repository.
                                           - This includes links that are relative to the currently
                                             selected community or collection.
                                        3) Metadata about the search urls.
                                        -->
                        <map:transform type="Navigation"/>


                        <!--
                                        Display the DSpace homepage. This includes the news.xml file
                                        along with a list of top level communities in DSpace.
                                        -->
                        <map:match pattern="">
                            <map:transform type="Include" src="resource://aspects/ViewArtifacts/dspace-home.xml" />
                            <!--
                                DSpacePropertyFileReader will read the DSpace property file and
                                place the selected properties' value in this scope
                            -->
                                <map:act type="DSpacePropertyFileReader">
                                        <map:parameter name="dspace.dir" value="dspace.dir" />
                                        <map:transform type="Include" src="file://{dspace.dir}/config/news-xmlui.xml" />
                                </map:act>

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



			<!-- Display statistics -->
			<map:match pattern="statistics">
				<map:transform type="Statistics" />
				<map:serialize type="xml" />
			</map:match>


			<!-- restricted resource -->
			<map:match pattern="restricted-resource">
				<map:transform type="RestrictedItem" />
				<map:serialize type="xml" />
			</map:match>


			<!-- Handle specific features -->
			<map:match pattern="handle/*/**">

				<!-- Inform the user that the item they are viewing is a restricted resource -->
				<map:match pattern="handle/*/*/restricted-resource">
					<!-- If request copy is enabled it comes here -->
					<map:match type="ConfigurationMatcher" pattern="request.item.type">
						<map:act type="SendItemRequestAction">
							<map:transform type="ItemRequestForm">
								<map:parameter name="requesterName" value="{requesterName}" />
								<map:parameter name="requesterEmail" value="{requesterEmail}" />
								<map:parameter name="allFiles" value="{allFiles}" />
								<map:parameter name="message" value="{message}" />
								<map:parameter name="bitstreamId" value="{bitstreamId}" />
							</map:transform>
							<map:serialize type="xml" />
						</map:act>
						<map:transform type="ItemRequestSent" />
						<map:serialize type="xml" />
					</map:match>
					<!-- If request copy is disabled normal flow -->
					<map:transform type="RestrictedItem"/> 
					<map:serialize type="xml"/> 
				</map:match>

				<!-- Community, Collection, and Item Viewers -->
				<map:match pattern="handle/*/*">
					<map:match type="HandleAuthorizedMatcher" pattern="READ">
						<map:match type="HandleTypeMatcher" pattern="community">
							<map:act type="UsageLoggerAction">
								<map:parameter name="type" value="community" />
								<map:parameter name="eventType" value="view" />
							</map:act>
							<map:transform type="CommunityViewer" />
							<map:serialize type="xml" />
						</map:match>
						<map:match type="HandleTypeMatcher" pattern="collection">
							<map:act type="UsageLoggerAction">
								<map:parameter name="type" value="collection" />
								<map:parameter name="eventType" value="view" />
							</map:act>
							<map:transform type="CollectionViewer" />
							<map:serialize type="xml" />
						</map:match>
						<map:match type="HandleTypeMatcher" pattern="item">
							<map:act type="UsageLoggerAction">
								<map:parameter name="type" value="item" />
								<map:parameter name="eventType" value="view" />
							</map:act>
							<!-- Implement HTTP If-Modified-Since protocol (commonly used by search 
								- engine crawlers): return 304 NOT MODIFIED status if Item's - last-modified 
								date is before If-Modified-Since header. - - NOTE: Do NOT do this for interactive 
								users since it might encourage - browser to cache a view that is only shown 
								to authenticated users. - ONLY do this when user-agent is a spider (search-engine 
								crawler robot) - since they should only ever have "anonymous" access. - - 
								NOTE: Cocoon always automatically sets Last-Modified: header on its - transformed 
								pages with the current timestamp, which we cannot override. - It won't prevent 
								a spider's If-Modified-Since from working, though. -->
							<map:select type="browser">
								<map:when test="spider">
									<map:select type="IfModifiedSinceSelector">
										<map:when test="true">
											<map:act type="NotModifiedAction" />
											<map:serialize />
										</map:when>
										<map:otherwise>
											<map:transform type="ItemViewer" />
											<map:serialize type="xml" />
										</map:otherwise>
									</map:select>
								</map:when>
								<map:otherwise>
									<map:transform type="ItemViewer" />
									<map:serialize type="xml" />
								</map:otherwise>
							</map:select>
						</map:match>
					</map:match>

					<map:match type="HandleAuthorizedMatcher" pattern="!READ">
						<map:match type="HandleTypeMatcher" pattern="community">
							<map:transform type="RestrictedItem">
								<map:parameter name="header"
									value="xmlui.ArtifactBrowser.RestrictedItem.auth_header" />
								<map:parameter name="message"
									value="xmlui.ArtifactBrowser.RestrictedItem.auth_message" />
							</map:transform>
							<map:serialize type="xml" />
						</map:match>
						<map:match type="HandleTypeMatcher" pattern="collection">
							<map:transform type="RestrictedItem">
								<map:parameter name="header"
									value="xmlui.ArtifactBrowser.RestrictedItem.auth_header" />
								<map:parameter name="message"
									value="xmlui.ArtifactBrowser.RestrictedItem.auth_message" />
							</map:transform>
							<map:serialize type="xml" />
						</map:match>
						<map:match type="HandleTypeMatcher" pattern="item">
							<!-- <map:match type="ConfigurationMatcher" pattern="request.item.type,logged">
								<map:act type="SendItemRequestAction">
									<map:parameter name="type" value="item" />
									<map:parameter name="eventType" value="view" />
								</map:act>
							</map:match>-->
								<map:transform type="RestrictedItem">
									<map:parameter name="header"
										value="xmlui.ArtifactBrowser.RestrictedItem.auth_header" />
									<map:parameter name="message"
										value="xmlui.ArtifactBrowser.RestrictedItem.auth_message" />
								</map:transform>
								<map:serialize type="xml" />
							<!-- Implement HTTP If-Modified-Since protocol (commonly used by search 
								- engine crawlers): return 304 NOT MODIFIED status if Item's - last-modified 
								date is before If-Modified-Since header. - - NOTE: Do NOT do this for interactive 
								users since it might encourage - browser to cache a view that is only shown 
								to authenticated users. - ONLY do this when user-agent is a spider (search-engine 
								crawler robot) - since they should only ever have "anonymous" access. - - 
								NOTE: Cocoon always automatically sets Last-Modified: header on its - transformed 
								pages with the current timestamp, which we cannot override. - It won't prevent 
								a spider's If-Modified-Since from working, though. -->
							<map:select type="browser">
								<map:when test="spider">
									<map:select type="IfModifiedSinceSelector">
										<map:when test="true">
											<map:act type="NotModifiedAction" />
											<map:serialize />
										</map:when>
										<map:otherwise>
											<map:transform type="ItemViewer" />
											<map:serialize type="xml" />
										</map:otherwise>
									</map:select>
								</map:when>
								<map:otherwise>
									<map:transform type="ItemViewer" />
									<map:serialize type="xml" />
								</map:otherwise>
							</map:select>
						</map:match>
					</map:match>
				</map:match>


			</map:match> <!-- End match handle/*/** -->


			<!-- A simple feedback utility that presents the user with a form to fill 
				out, the results of which are emailed to the site administrator. -->
			<map:match pattern="feedback">
				<map:act type="SendFeedbackAction">
					<map:transform type="FeedbackForm">
						<map:parameter name="comments" value="{comments}" />
						<map:parameter name="email" value="{email}" />
						<map:parameter name="page" value="{page}" />
					</map:transform>

					<map:serialize type="xml" />
				</map:act>
				<map:transform type="FeedbackSent" />
				<map:serialize type="xml" />
			</map:match>
			
			<!-- A request item flow -->
			<map:match pattern="itemRequestResponse/*/">
				<map:act type="ItemRequestResponseAction">
					<map:parameter name="token" value="{1}" />
					<map:parameter name="decision" value="{decision}" />
					<map:parameter name="isSent" value="{isSent}" />
                    <map:parameter name="contactPerson" value="{contactPerson}"/>

					<map:select type="parameter">
					<map:parameter name="parameter-selector-test" value="{isSent}" />
						<map:when test="true">
							<map:transform type="ItemRequestChangeStatusForm">
								<map:parameter name="token" value="{1}" />
								<map:parameter name="name" value="{name}" />
								<map:parameter name="email" value="{email}" />
							</map:transform>
						</map:when>
                        <map:when test="notify">
                            <map:transform type="ItemRequestResponseSent"/>
                        </map:when>
						<map:otherwise>
							<map:select type="parameter">
							<map:parameter name="parameter-selector-test" value="{decision}" />
								<map:when test="false">
									<map:transform type="ItemRequestResponseFalseForm">
										<map:parameter name="decision" value="{decision}" />
									</map:transform>
								</map:when>
								<map:when test="true">
									<map:transform type="ItemRequestResponseTrueForm">
										<map:parameter name="decision" value="{decision}" />
									</map:transform>
								</map:when>
								<map:otherwise>
                                    <map:select type="parameter">
                                        <!-- Initial Message to either Requester, or Author -->
                                        <map:parameter name="parameter-selector-test" value="{contactPerson}" />
                                        <map:when test="requester">
                                            <map:transform type="ItemRequestContactRequester"></map:transform>
                                        </map:when>
                                        <map:when test="author">
                                            <map:transform type="ItemRequestContactAuthor"></map:transform>
                                        </map:when>
                                        <map:otherwise>
                                            <map:transform type="ItemRequestResponseDecisionForm">
                                                <map:parameter name="decision" value="{decision}" />
                                                <map:parameter name="title" value="{title}" />
                                            </map:transform>
                                        </map:otherwise>
                                    </map:select>
								</map:otherwise>
							</map:select>
						</map:otherwise>
					</map:select>
					<map:serialize type="xml" />
				</map:act>
				<map:transform type="ItemRequestStatusChanged" />
				<map:serialize type="xml" />
			</map:match>
			<!-- The most basic & generic contact us page. It is expected that most 
				themes will override this page and replace it with a more detailed version. -->
			<map:match pattern="contact">
				<map:transform type="Contact" />
				<map:serialize type="xml" />
			</map:match>


			<!-- Not a URL we care about, so just pass it on. -->
			<map:serialize type="xml" />

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