Author: sergiykarpenko
Date: 2010-09-20 02:30:42 -0400 (Mon, 20 Sep 2010)
New Revision: 3134
Added:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml
Modified:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml
Log:
EXOJCR-939: documentation added
Added:
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml
(rev 0)
+++
jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml 2010-09-20
06:30:42 UTC (rev 3134)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter>
+ <?dbhtml filename="ch-db-cleaner-service.html"?>
+
+ <title>DBCleanerService</title>
+
+ <section>
+ <title>API</title>
+
+ <para>There is two methods of DBCleanerService:</para>
+
+ <table>
+ <title>API</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>public static void removeWorkspaceData(WorkspaceEntry
+ wsConfig) </entry>
+
+ <entry>If workspace is multiDB - drops JCR_SITEM,JCR_SVALUE,
+ JCR_SREF tables, otherwise, it removes all rows of this
+ workspace.</entry>
+ </row>
+
+ <row>
+ <entry>public static void removeRepositoryData(RepositoryEntry
+ repoConfig)</entry>
+
+ <entry>Removes data of all worksapces of this
repository.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section>
+ <title>How it works</title>
+
+ <para>removeWorkspaceData takes workspaces configs from RepositoryEntry
+ and clean each workspace using removeRepositoryData.</para>
+
+ <para>Lets see removeWorkspaceData in detail:<itemizedlist>
+ <listitem>
+ <para>at first, it ejects workspace name (aka container name), data
+ source of databse, and and deside is workspase multiDB or
+ singleDB;</para>
+ </listitem>
+
+ <listitem>
+ <para>than it deside which script must be used to remove (databse
+ dialect and isMultiDb used);</para>
+ </listitem>
+
+ <listitem>
+ <para>than this script is parsed to list of queries, and executed in
+ order of occurance;</para>
+ </listitem>
+ </itemizedlist></para>
+ </section>
+
+ <section>
+ <title>Scripts in detail</title>
+
+ <para>Single and Multi DB scripts examples</para>
+
+ <para>In case of: dbDialect = "MySQL" and isMultiDB="true",
will use
+ "conf/storage/cleanup/jcr-mjdbc.mysql.sql"</para>
+
+ <programlisting>DROP TABLE JCR_MREF;
+DROP TABLE JCR_MVALUE;
+DROP TABLE JCR_MITEM;</programlisting>
+
+ <para>In case of: dbDialect = "PgSQL" and
isMultiDB="false", will use
+ "conf/storage/cleanup/jcr-sjdbc.pgsql.sql"</para>
+
+ <programlisting>delete from JCR_SVALUE where exists(select * from JCR_SITEM
where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SREF where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SITEM where CONTAINER_NAME=?;</programlisting>
+
+ <note>
+ <para>"?" will be replased with container name on
execution.</para>
+ </note>
+
+ <para>But what is the strage coment is in
+ "conf/storage/cleanup/jcr-sjdbc.sql" ?</para>
+
+ <programlisting>delete from JCR_SVALUE where exists(select * from JCR_SITEM
where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SREF where exists(select * from JCR_SITEM where
JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?;
+/*$CLEAN_JCR_SITEM_DEFAULT*/;</programlisting>
+
+ <para><emphasis
role="bold">/*$CLEAN_JCR_SITEM_DEFAULT*/</emphasis> - some
+ database may throw constraint violaion exception according to
+ JCR_FK_SITEM_PARENT FOREIGN KEY in case of ordinary "" delete from
+ JCR_SITEM where CONTAINER_NAME=? query. So there is special method, that
+ will be executed on /*$CLEAN_JCR_SITEM_DEFAULT*/. It a bit slowly, but
+ safe.</para>
+
+ <note>
+ <para>"conf/storage/cleanup/jcr-sjdbc.sql" or
+ "conf/storage/cleanup/jcr-mjdbc.sql" are used if dialect is not
+ recognized.</para>
+ </note>
+ </section>
+
+ <section>
+ <title>Few words in addition</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>DBCleanerService is static, so all you need is config to
+ execute;</para>
+ </listitem>
+
+ <listitem>
+ <para>code that executes DBCleanerService must have
+ JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION;</para>
+ </listitem>
+
+ <listitem>
+ <para>you can update scripts for your needs.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+</chapter>
Modified: jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml
===================================================================
--- jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml 2010-09-20 06:09:06
UTC (rev 3133)
+++ jcr/trunk/docs/reference/en/src/main/docbook/en-US/modules/jcr.xml 2010-09-20 06:30:42
UTC (rev 3134)
@@ -62,4 +62,9 @@
<xi:include href="jcr/data-container-howto.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="jcr/db-cleaner-service.xml"
+
xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+
+
</part>