/**
Copyright (C) 2000-2010  Ministere de la culture et de la communication (France), AJLSM
See LICENCE file
**/

+-------------------------------------------------------+
|     How to : Install SDX2 over an existing Cocoon     |
|      [ using sdx-cocoon target in the ant build ]     |
+-------------------------------------------------------+


Table of contents

    I -     Get and prepare the files
    II -    Install the files
    IIi -   Modify the Cocoon configuration


I - Get and prepare the files
-----------------------------

You need to download the source distribution of SDX 2.3 or more recent. This
distribution is available from the main Web site for SDX:
http://adnx.org/sdx/


Once you have this distribution, unpack it, open a command line window and
execute either of these commands:

build sdx-cocoon-zip

or

build sdx-cocoon-tgz

The first one will prepare a ZIP archive of relevant files, and the second one
will prepare a tar/gz archive.

II - Install the files
----------------------

The previous action will give you an archive of relevant files. This archive
will be in the build directory of your distribution.

You need to unpack this archive in the directory where Cocoon is installed.

Afterwards, delete the old lucene jar file (should be lucene-1.3-final.jar with
cocoon 2.1.5), located in the /WEB-INF/lib/ directory.

The correct lucene jar are the cocoon-block and the patched one provided with
SDX.


III - Modify the Cocoon configuration
-------------------------------------

There are 3 configuration files to edit, they are located in the /WEB-INF/
directory of your Cocoon installation directory:
    - cocoon.xconf
    - logkit.xconf
    - web.xml

We have provided example configuration files from the SDX distributions. They
are named cocoon.xconf.sdx, logkit.xconf.sdx and web.xml.sdx. You may either
apply the following modifications to your Cocoon configuration files or start
from the ones provided with SDX and modify them.

Changes to cocoon.xconf:

1- Add these two elements just after the root tag:

<sdx-framework role="fr.gouv.culture.sdx.framework.Framework"
class="fr.gouv.culture.sdx.framework.FrameworkImpl" logger="sdx.framework"/>

<oai role="fr.gouv.culture.oai.OAIComponent"
class="fr.gouv.culture.oai.OAIComponentImpl" logger="oai"/>


2- Find this block (entity resolution):

<entity-resolver logger="core.resolver">
	<parameter name="catalog" value="WEB-INF/entities/catalog"/>
	<parameter name="verbosity" value="1"/>
</entity-resolver>

And replace it with:

<sdx-entity-resolver role="org.apache.excalibur.xml.EntityResolver"
class="fr.gouv.culture.sdx.resolver.entity.SDXResolver"
logger="sdx.framework.SDXResolver">
	<parameter name="verbosity" value="1"/>
</sdx-entity-resolver>


3- Find the following line:

<xslt-processor logger="core.xslt-processor">

And replace it with :

<xslt-processor logger="core.xslt-processor" pool-grow="2" pool-min="8"
pool-max="32">


4- Bellow this line:

<target-language name="java">

Add the following element:

<builtin-logicsheet>
	<parameter name="prefix" value="sdx"/>
	<parameter name="uri" value="http://www.culture.gouv.fr/ns/sdx/sdx"/>
	<parameter name="href" value="resource://fr/gouv/culture/sdx/logicsheet/sdx.xsl"/>
</builtin-logicsheet>


Changes to logkit.xconf:


1- In the <targets> section, add the following blocks:

<cocoon id="sdx">
	<filename>${context-root}/WEB-INF/logs/sdx.log</filename>
	<format type="cocoon">%7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}</format>
	<append>false</append>
</cocoon>
 
<priority-filter id="sdxError" log-level="ERROR">
	<cocoon>
		<filename>${context-root}/WEB-INF/logs/sdxError.log</filename>
		<format type="cocoon">%7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}</format>
		<append>false</append>
	</cocoon>
</priority-filter>
 
<cocoon id="oai">
	<filename>${context-root}/WEB-INF/logs/oai.log</filename>
	<format type="cocoon">%7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}</format>
	<append>false</append>
</cocoon>
 
<priority-filter id="oaiError" log-level="ERROR">
	<cocoon>
		<filename>${context-root}/WEB-INF/logs/oaiError.log</filename>
		<format type="cocoon">%7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}</format>
		<append>false</append>
	</cocoon>
</priority-filter>


2- In the <categories> section, add the following blocks :

<category name="sdx" log-level="ERROR">
	<category name="sdx.framework" log-level="ERROR"/>
	<category name="sdx.rdbms" log-level="ERROR"/>
	<log-target id-ref="sdx"/>
	<log-target id-ref="sdxError"/>
</category>

<category name="oai" log-level="ERROR">
	<category name="oai" log-level="ERROR"/>
	<log-target id-ref="oai"/>
	<log-target id-ref="oaiError"/>
</category>


Changes to web.xml:

1- Find this block :

<init-param>
	<param-name>enable-uploads</param-name>
	<param-value>false</param-value>
</init-param>

And set the value to "true":

<init-param>
	<param-name>enable-uploads</param-name>
	<param-value>true</param-value>
</init-param>


2- Search for this block :

<!--
	Specify maximum allowed size of the upload. Defaults to 10 Mb.

<init-param>
	<param-name>upload-max-size</param-name>
	<param-value>10000000</param-value>
</init-param>
-->

And uncomment it to set a useful value:

<!--
	Specify maximum allowed size of the upload. Defaults to 10 Mb.
-->
<init-param>
	<param-name>upload-max-size</param-name>
	<param-value>25000000</param-value>
</init-param>


3- Find the following two blocks about the encoding :

<!--
	Set encoding used by the container. If not set the ISO-8859-1 encoding
	will be assumed.
-->
<!--
<init-param>
	<param-name>container-encoding</param-name>
	<param-value>utf-8</param-value>
</init-param>
-->

<!--
	Set form encoding. This will be the character set used to decode request
	parameters. If not set the ISO-8859-1 encoding will be assumed.
-->
<!--
<init-param>
	<param-name>form-encoding</param-name>
	<param-value>utf-8</param-value>
</init-param>
-->

And uncomment them:

<!--
	Set encoding used by the container. If not set the ISO-8859-1 encoding
	will be assumed.
-->
<init-param>
	<param-name>container-encoding</param-name>
	<param-value>utf-8</param-value>
</init-param>

<!--
	Set form encoding. This will be the character set used to decode request
	parameters. If not set the ISO-8859-1 encoding will be assumed.
-->
<init-param>
	<param-name>form-encoding</param-name>
	<param-value>utf-8</param-value>
</init-param>

