<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- SVN $Id: sitemap.xmap 595741 2007-11-16 17:07:09Z cziegeler $ -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

  <!-- ========================= Components ================================ -->

  <map:components>
    <map:generators default="file">
      <map:generator name="portal" src="org.apache.cocoon.portal.generation.PortalGenerator"/>
    </map:generators>
    <map:transformers default="xslt">
      <map:transformer name="portal-coplet" 
                       src="org.apache.cocoon.portal.transformation.CopletTransformer" 
                       logger="sitemap.transformer.portal" />
      <map:transformer name="htmlroot" src="org.apache.cocoon.portal.transformation.HTMLRootTransformer"
        logger="sitemap.transformer.htmlroot" />
      <map:transformer name="rss" src="org.apache.cocoon.portal.transformation.RSSTransformer"
        logger="sitemap.transformer.rss" />
      <map:transformer name="portal-proxy" src="org.apache.cocoon.portal.transformation.ProxyTransformer"
        logger="sitemap.transformer.portal.proxy">
        <parameter name="envelope-tag" value="div"/>
      </map:transformer>
      <map:transformer name="portal-new-eventlink" src="org.apache.cocoon.portal.transformation.NewEventLinkTransformer"
        logger="sitemap.transformer.portal.eventlink" />
      <map:transformer name="portal-html-eventlink" src="org.apache.cocoon.portal.transformation.HTMLEventLinkTransformer"
        logger="sitemap.transformer.portal.eventlink.html"/>
      <map:transformer name="portal-html-linktoeventlink" src="org.apache.cocoon.portal.transformation.LinkTransformer"
        logger="sitemap.transformer.portal.eventlink" />
    </map:transformers>
    <map:readers default="resource">
      <map:reader name="portal-proxy" src="org.apache.cocoon.portal.reading.ProxyReader"
        logger="sitemap.reader.portal.proxy" />
    </map:readers>
    <map:serializers default="html">
      <map:serializer name="html-include"
        logger="sitemap.serializer.html"
        mime-type="text/html"
        pool-max="${html-include-serializer.pool-max}"
        src="org.apache.cocoon.portal.serialization.IncludingHTMLSerializer">
        <doctype-public>-//W3C//DTD HTML 4.01 Transitional//EN</doctype-public>
        <doctype-system>http://www.w3.org/TR/html4/loose.dtd</doctype-system>
      </map:serializer>
    </map:serializers>
    <map:matchers default="wildcard"/>
    <map:selectors default="browser"/>
    <map:actions>
      <map:action name="portal-set-object-model"
                  src="org.apache.cocoon.acting.SetterAction"/>
      <map:action name="portal-set-data"
                  src="org.apache.cocoon.portal.acting.CopletSetDataAction"/>
      <map:action name="portal-save-profile"
                  src="org.apache.cocoon.portal.acting.SaveAction"/>
      <map:action src="org.apache.cocoon.portal.acting.BookmarkAction" name="portal-bookmark">
        <parameter name="src" value="resources/bookmarks.xml"/>
      </map:action>
      <map:action name="portal-prepare"
                  src="org.apache.cocoon.portal.acting.PreparePortalAction"/>
      <map:action name="portal-urlhelper"
                  src="org.apache.cocoon.portal.acting.URLAction"/>

      <map:action name="cauth-is-logged-in"
                  src="org.apache.cocoon.auth.acting.LoggedInAction"/>
      <map:action name="cauth-login"
                  src="org.apache.cocoon.auth.acting.LoginAction"/>
      <map:action name="cauth-logout"
                  src="org.apache.cocoon.auth.acting.LogoutAction"/>
    </map:actions>
  </map:components>

  <map:resources>
    <map:resource name="show-portal">
      <map:act type="cauth-is-logged-in">
        <map:parameter name="application" value="portal"/>

        <map:generate type="portal" label="content"/>
        <map:transform src="{portal-skin:skin.basepath}/styles/portal-page.xsl">
          <map:parameter name="user" value="{ID}"/>
          <map:parameter name="title" value="{global:mainTitle}"/>
          <map:parameter name="base" value="{portalpath:relative}"/>
        </map:transform>
        <map:transform type="cinclude"/>
        <map:transform type="portal-coplet"/>
        <map:transform type="portal-new-eventlink"/>
        <map:transform type="encodeURL"/>
        <!--
        <map:transform type="htmlroot" />
        -->
        <!-- If you don't need JSR-168 support, you can use the html serializer instead -->
        <map:serialize type="html-include"/>
      </map:act>
    </map:resource>
  </map:resources>

  <!-- =========================== Views =================================== -->

  <map:views>
    <map:view name="content" from-label="content">
      <map:serialize type="xml"/>
    </map:view>
  </map:views>


  <!-- =========================== Pipelines ================================= -->

  <map:pipelines>
    <map:component-configurations>
      <!-- select skin to use -->
      <map:global-variables>
		<skin>common</skin>
    	<mainTitle>Cocoon Portal</mainTitle>
	    <toolsTitle>Cocoon Portal Tools</toolsTitle>
      </map:global-variables>

    </map:component-configurations>

  <map:pipeline>
    <!-- This action sets the portal name for the current request and
         initializes the portal service. So this should be the first
         task for every request!
    -->
    <map:act type="portal-prepare">
      <map:parameter name="portal-name" value="portal"/>
    </map:act>
  </map:pipeline>
  
    <!-- The internal pipelines for loading and saving -->
    <map:pipeline internal-only="true">
      <map:match pattern="sunrise-authuser">
        <map:generate src="resources/sunrise-user.xml"/>
        <map:transform src="styles/authenticate.xsl">
          <map:parameter name="use-request-parameters" value="true"/>
        </map:transform>
        <map:serialize type="xml"/>
      </map:match>

      <map:match pattern="load-global-profile">
        <map:generate src="profiles/{request-param:profile}/{request-param:portal}.xml"/>
        <map:serialize type="xml"/>
      </map:match>

      <map:match pattern="load-role-profile">
        <map:generate src="profiles/{request-param:profile}/{request-param:portal}-role-{request-param:role}.xml"/>
        <map:serialize type="xml"/>
      </map:match>

      <map:match pattern="load-user-profile">
        <map:generate src="profiles/{request-param:profile}/{request-param:portal}-user-{request-param:user}.xml"/>
        <map:serialize type="xml"/>
      </map:match>

      <map:match pattern="save-user-profile">
        <map:generate src="resources/save-user-profile.xml"/>
				<map:transform src="styles/save-user-profile.xsl">
					<map:parameter name="profiles" value="context://samples/blocks/portal/profiles/"/>
				</map:transform>
        <map:transform type="session"/>
        <map:transform type="write-source"/>
        <map:serialize type="xml"/>
      </map:match>
    </map:pipeline>

    <!-- Now the accessible pipelines -->
    <map:pipeline>

      <!-- images -->
      <map:match pattern="proxy-**">
        <map:read type="portal-proxy"/>
      </map:match>
      <map:match pattern="images/*.gif">
        <map:read mime-type="image/gif" src="{portal-skin:skin.basepath}/images/{1}.gif"/>
      </map:match>
      <map:match pattern="images/*.jpg">
        <map:read mime-type="image/jpg" src="{portal-skin:skin.basepath}/images/{1}.jpg"/>
      </map:match>

      <!-- Cascading Stylesheets -->
      <map:match pattern="css/*.css">
        <map:read mime-type="text/css" src="{portal-skin:skin.basepath}/css/{1}.css"/>
      </map:match>

      <map:match pattern="">
        <map:redirect-to uri="portal"/>
      </map:match>

      <map:match pattern="coplets/**">
        <map:mount check-reload="yes" src="coplets/" uri-prefix="coplets"/>
      </map:match>

      <map:match pattern="portlets/**">
        <map:mount check-reload="yes" src="portlets/" uri-prefix="portlets"/>
      </map:match>

      <!-- Do an auto login as anonymous -->
      <map:act type="cauth-is-logged-in">
        <map:parameter name="application" value="portal"/>
        <map:parameter name="negate-result" value="true"/>

        <map:act type="cauth-login">
          <map:parameter name="application" value="portal"/>

          <map:parameter name="name" value="anonymous"/>
          <map:parameter name="password" value="anonymous"/>
        </map:act>
      </map:act>

      <!-- Test pipeline for portal engine -->
      <map:match pattern="portal">
        <map:call resource="show-portal"/>
      </map:match>

      <!-- Test pipeline for bookmark -->
      <map:match pattern="bookmark">
        <map:act type="cauth-is-logged-in">
          <map:parameter name="application" value="portal"/>

          <map:act type="portal-bookmark">
            <map:redirect-to uri="portal?{uri}"/>
          </map:act>
        </map:act>
      </map:match>

      <map:match pattern="portalxml">
        <map:act type="cauth-is-logged-in">
          <map:parameter name="application" value="portal"/>

            <map:generate type="portal" label="content"/>
          <map:serialize type="xml"/>
        </map:act>
      </map:match>

      <!-- Authenticate a user -->
      <map:match pattern="auth">
        <!-- Check if we are logged in:
        - if we are anonymous, then logout
        - if we are any other use, redirect to loggedin
        -->
          <map:act type="cauth-is-logged-in">
            <map:parameter name="application" value="portal"/>

            <map:select type="parameter" >
              <map:parameter name="parameter-selector-test" value="{ID}"/>
              <map:when test="anonymous">
                <map:act type="cauth-logout">
                  <map:parameter name="application" value="portal"/>
                </map:act>
              </map:when>
              <map:otherwise>
                <map:redirect-to uri="loggedin"/>
              </map:otherwise>
            </map:select>
          </map:act>

        <!-- Start the authentication process -->
        <map:act type="cauth-login">
          <map:parameter name="application" value="portal"/>
          <map:parameter name="name" value="{request-param:name}"/>
          <map:parameter name="password" value="{request-param:password}"/>

          <!-- Authentication succeeded -->
          <map:redirect-to uri="{request-param:resource}"/>

        </map:act>
        <!-- Authentication failed -->
        <map:generate src="resources/login-error.xml"/>
        <map:transform src="{portal-skin:skin.basepath}/styles/portal-page.xsl">
          <map:parameter name="user" value="anonymous"/>
        </map:transform>
        <map:transform type="encodeURL"/>
        <map:serialize/>
      </map:match>

      <map:match pattern="loggedin">
        <map:act type="cauth-is-logged-in">
          <map:parameter name="application" value="portal"/>

          <map:generate src="resources/logged-in.xml"/>
          <map:transform src="{portal-skin:skin.basepath}/styles/portal-page.xsl"/>
          <map:transform type="encodeURL"/>
          <map:serialize/>
        </map:act>
        <map:redirect-to uri="login"/>
      </map:match>

      <map:match pattern="logout">
        <map:act type="cauth-is-logged-in">
          <map:parameter name="application" value="portal"/>
<!--
            <map:act type="portal-save-profile"/>
-->
          <map:act type="cauth-logout">
		        <map:parameter name="application" value="portal"/>
          </map:act>
        </map:act>
        <!-- TODO logout page -->
        <map:redirect-to uri="portal"/>
      </map:match>

      <!-- Test pipeline for portal engine -->
      <map:match pattern="*">
        <map:call resource="show-portal"/>
      </map:match>
      
        <!-- ==== P O R T A L   T O O L S ==== -->
	
	<!-- mount sitemap of the portal tools -->
	<map:match pattern="tools/**"> 
		<map:act type="cauth-is-logged-in">
			<map:parameter name="application" value="portal"/> 
			
			<map:mount uri-prefix="tools" check-reload="no" src="tools/sitemap.xmap"/>
		</map:act>
	</map:match>
	
    <!-- portal tools image reader -->
	<map:match pattern="toolImages/*/*.jpg">
		<map:read mime-type="image/jpg" src="tools/skins/{1}/images/{2}.jpg"/>
	</map:match>
	<map:match pattern="userImages/*.jpg">
		<map:read mime-type="image/jpg" src="tools/plugins/userManagement/userImages/{1}.jpg"/>
	</map:match>


      <!-- process page labels -->
      <map:match pattern="*">
        <map:call resource="show-portal"/>
      </map:match>

      <!-- Everything else redirect to the portal -->
      <map:match pattern="**">
        <map:redirect-to uri="portal"/>
      </map:match>
    </map:pipeline>

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

<!-- end of file -->
