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

<!--
 * ====================================================================
 * Copyright (c) 2005-2011 sventon project. All rights reserved.
 *
 * This software is licensed as described in the file LICENSE, which
 * you should have received as part of this distribution. The terms
 * are also available at http://www.sventon.org.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
  -->

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<!-- Uncomment to set a fixed locale regardless of browser accept headers.
  <bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
    <property name="defaultLocale" value="en"/>
  </bean>
-->

  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/WEB-INF/jsp/"/>
    <property name="suffix" value=".jsp"/>
  </bean>

  <bean id="urlMapping" class="carbonfive.spring.web.pathparameter.ParameterizedUrlHandlerMapping">
    <property name="alwaysUseFullPath" value="true"/>
    <property name="mappings">
      <props>
        <!--
        <prop key="/repos/">listRepositoriesController</prop>
        <prop key="/repos/list">listRepositoriesController</prop>
        -->
        <prop key="/repos/listconfigs">listConfigurationsController</prop>
        <prop key="/repos/deleteconfig">deleteConfigurationController</prop>
        <prop key="/repos/submitconfig">submitConfigurationsController</prop>
        <prop key="/repos/configlogin">configurationLoginController</prop>

        <prop key="/repos/(*:name)/info">revisionInfoController</prop>
        <prop key="/repos/(*:name)/list/(**/*:path)*">repoBrowserController</prop>
        <prop key="/repos/(*:name)/show/(**/*:path)*">showFileController</prop>
        <prop key="/repos/(*:name)/blame/(**/*:path)*">blameController</prop>
        <prop key="/repos/(*:name)/log/(**/*:path)*">showLogsController</prop>
        <prop key="/repos/(*:name)/get/(**/*:path)*">getFileController</prop>
        <prop key="/repos/(*:name)/export/(**/*:path)*">exportController</prop>
        <prop key="/repos/(*:name)/diff/(**/*:path)*">diffController</prop>
        <prop key="/repos/(*:name)/goto/(**/*:path)*">goToController</prop>

        <prop key="/repos/(*:name)/showlocks/(**/*:path)*">showLocksController</prop>
        <prop key="/repos/(*:name)/showthumbnails/(**/*:path)*">showThumbnailsController</prop>
        <prop key="/repos/(*:name)/searchentries/(**/*:path)*">searchEntriesController</prop>
        <prop key="/repos/(*:name)/searchlogs/(**/*:path)*">searchLogsController</prop>
        <prop key="/repos/(*:name)/flatten/(**/*:path)*">flattenController</prop>

        <!-- url mappings for xml producers -->
        <prop key="/xml/(*:name)/rss/(**/*:path)*">rssController</prop>

        <!-- url mappings for ajax controllers -->
        <prop key="/ajax/static">getStaticContentController</prop>
        <prop key="/ajax/(*:name)/getmessage">logMessageController</prop>
        <prop key="/ajax/(*:name)/latestrevisions">latestRevisionsController</prop>
        <prop key="/ajax/(*:name)/listfiles/(**/*:path)*">listFilesController</prop>
        <prop key="/ajax/(*:name)/entrytray/(**/*:path)*">entryTrayController</prop>
        <prop key="/ajax/(*:name)/filehistory/(**/*:path)*">fileHistoryController</prop>
        <prop key="/ajax/(*:name)/exportprogress">exportProgressController</prop>
      </props>
    </property>
  </bean>

  <bean id="abstractBaseController" class="org.sventon.web.ctrl.AbstractBaseController" abstract="true">
    <property name="commandClass" value="org.sventon.web.command.BaseCommand"/>
    <property name="cacheSeconds" value="0"/>
    <property name="validator" ref="baseCommandValidator"/>
    <property name="nameEditor" ref="nameEditor"/>
    <property name="revisionEditor" ref="revisionEditor"/>
    <property name="pathRevisionEditor" ref="pathRevisionEditor"/>
    <property name="application" ref="application"/>
    <property name="repositoryService" ref="repositoryService"/>
    <property name="connectionFactory" ref="connectionFactory"/>
  </bean>

  <bean id="abstractTemplateController" class="org.sventon.web.ctrl.template.AbstractTemplateController" parent="abstractBaseController" abstract="true">
    <property name="cacheGateway" ref="cacheGatewayBean"/>
    <property name="maxRevisionsCount" ref="maxRevisionsCount"/>
    <property name="availableCharsets" ref="availableCharsets"/>
  </bean>

  <bean id="rssController" class="org.sventon.web.ctrl.RSSController" parent="abstractBaseController">
    <property name="commandClass" value="org.sventon.web.command.RevisionRangeCommand"/>
    <property name="mimeType" value="application/xml; charset=UTF-8"/>
    <property name="rssFeedGenerator" ref="rssFeedGenerator"/>
    <property name="httpAuthenticationHandler" ref="httpAuthenticationHandler"/>
  </bean>

  <bean id="listFilesController" class="org.sventon.web.ctrl.template.ListFilesController" parent="abstractTemplateController">
    <property name="viewName" value="ajax/listFiles"/>
  </bean>

  <bean id="latestRevisionsController" class="org.sventon.web.ctrl.template.GetLatestRevisionsController" parent="abstractTemplateController">
    <property name="viewName" value="ajax/latestRevisions"/>
  </bean>

  <bean id="logMessageController" class="org.sventon.web.ctrl.template.GetLogMessageController" parent="abstractTemplateController">
    <property name="viewName" value="ajax/logMessage"/>
  </bean>

  <bean id="entryTrayController" class="org.sventon.web.ctrl.template.DirEntryTrayController" parent="abstractTemplateController">
    <property name="commandClass" value="org.sventon.web.command.MultipleEntriesCommand"/>
    <property name="viewName" value="ajax/entryTray"/>
  </bean>

  <bean id="fileHistoryController" class="org.sventon.web.ctrl.template.GetFileHistoryController" parent="abstractTemplateController">
    <property name="viewName" value="ajax/fileHistory"/>
  </bean>

  <bean id="exportProgressController" class="org.sventon.web.ctrl.template.ExportProgressController" parent="abstractTemplateController">
    <constructor-arg ref="exportExecutor"/>
    <property name="viewName" value="ajax/exportProgress"/>
  </bean>

  <bean id="getStaticContentController" class="org.sventon.web.ctrl.GetStaticContentController">
    <property name="path" value="/WEB-INF/static"/>
  </bean>

  <bean id="repoBrowserController" class="org.sventon.web.ctrl.template.RepoBrowserController" parent="abstractTemplateController">
    <property name="commandClass" value="org.sventon.web.command.MultipleEntriesCommand"/>
    <property name="viewName" value="repoBrowser"/>
  </bean>

  <bean id="revisionInfoController" class="org.sventon.web.ctrl.template.ShowRevisionInfoController" parent="abstractTemplateController">
    <property name="viewName" value="showRevisionInfo"/>
  </bean>

  <bean id="showLocksController" class="org.sventon.web.ctrl.template.ShowLocksController" parent="abstractTemplateController">
    <property name="viewName" value="showLocks"/>
  </bean>

  <bean id="searchLogsController" class="org.sventon.web.ctrl.template.SearchLogsController" parent="abstractTemplateController">
    <property name="viewName" value="searchLogsResult"/>
  </bean>

  <bean id="flattenController" class="org.sventon.web.ctrl.template.FlattenController" parent="abstractTemplateController">
    <property name="commandClass" value="org.sventon.web.command.MultipleEntriesCommand"/>
    <property name="viewName" value="flattenDirResult"/>
  </bean>

  <bean id="searchEntriesController" class="org.sventon.web.ctrl.template.SearchEntriesController" parent="abstractTemplateController">
    <property name="commandClass" value="org.sventon.web.command.MultipleEntriesCommand"/>
    <property name="viewName" value="searchEntriesResult"/>
  </bean>

  <bean id="showLogsController" class="org.sventon.web.ctrl.template.ShowLogController" parent="abstractTemplateController">
    <property name="commandClass" value="org.sventon.web.command.LogCommand"/>
    <property name="pageSize" ref="logsPerPageCount"/>
    <property name="viewName" value="showLog"/>
  </bean>

  <bean id="goToController" class="org.sventon.web.ctrl.template.GoToController" parent="abstractTemplateController"/>

  <bean id="diffController" class="org.sventon.web.ctrl.template.DiffController" parent="abstractTemplateController">
    <property name="commandClass" value="org.sventon.web.command.DiffCommand"/>
    <property name="preferredDiffStyle" ref="defaultDiffView" />
  </bean>

  <bean id="showFileController" class="org.sventon.web.ctrl.template.ShowFileController" parent="abstractTemplateController">
    <constructor-arg ref="mimeFileTypeMap"/>
    <property name="textFileExtensionPattern" value=""/>
    <property name="binaryFileExtensionPattern" value="(bin|exe|pdf)"/>
    <property name="archiveFileExtensionPattern" value="(jar|zip|war|ear)"/>
    <property name="colorer" ref="colorer"/>
  </bean>

  <bean id="getFileController" class="org.sventon.web.ctrl.template.GetFileController" parent="abstractTemplateController">
    <property name="mimeFileTypeMap" ref="mimeFileTypeMap"/>
    <property name="imageScaler" ref="imageScaler"/>
    <property name="objectCacheManager" ref="objectCacheManager"/>
    <property name="imageFormatName" value="png"/>
    <property name="maxThumbnailSize" ref="maxThumbnailSize"/>
  </bean>

  <bean id="showThumbnailsController" class="org.sventon.web.ctrl.template.ShowThumbnailsController" parent="abstractTemplateController">
    <constructor-arg ref="mimeFileTypeMap"/>
    <property name="commandClass" value="org.sventon.web.command.MultipleEntriesCommand"/>
    <property name="viewName" value="showThumbnails"/>
  </bean>

  <bean id="exportController" class="org.sventon.web.ctrl.template.ExportController" parent="abstractTemplateController">
    <constructor-arg ref="exportExecutor"/>
    <property name="commandClass" value="org.sventon.web.command.MultipleEntriesCommand"/>
    <property name="viewName" value="repoBrowser"/>
  </bean>

  <bean id="blameController" class="org.sventon.web.ctrl.template.BlameController" parent="abstractTemplateController">
    <constructor-arg ref="colorer"/>
    <property name="viewName" value="blame"/>
  </bean>

  <bean id="submitConfigurationsController" class="org.sventon.web.ctrl.SubmitConfigurationsController">
    <property name="application" ref="application"/>
    <property name="scheduler" ref="scheduler"/>
  </bean>

  <bean id="deleteConfigurationController" class="org.sventon.web.ctrl.DeleteConfigurationController">
    <property name="application" ref="application"/>
  </bean>

  <bean id="listConfigurationsController" class="org.sventon.web.ctrl.ListConfigurationsController">
    <property name="application" ref="application"/>
  </bean>

  <bean id="configurationLoginController" class="org.sventon.web.ctrl.ConfigurationLoginController">
    <constructor-arg ref="application"/>
    <property name="commandClass" value="org.sventon.web.command.ConfigLoginCommand"/>
    <property name="formView" value="config/login"/>
    <property name="successView" value="redirect:listconfigs"/>
  </bean>

</beans>

