[jboss-svn-commits] JBL Code SVN: r7701 - in labs/jbossrules/trunk/drools-repository: . src/main/java/org/drools src/main/java/org/drools/resource src/main/java/org/drools/resource/exception src/main/java/org/drools/resource/util src/main/resources src/test/java/org/drools src/test/java/org/drools/resource src/test/resources src/test/resources/files src/test/resources/files/drls src/test/resources/files/dsls src/test/resources/files/functions src/test/resources/files/rules src/test/resources/files/spreadsheets src/test/resources/svn_repo src/test/resources/svn_repo/conf src/test/resources/svn_repo/db src/test/resources/svn_repo/db/revprops src/test/resources/svn_repo/db/revs src/test/resources/svn_repo/hooks src/test/resources/svn_repo/locks
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Nov 18 06:23:17 EST 2006
Author: mark.proctor at jboss.com
Date: 2006-11-18 06:23:01 -0500 (Sat, 18 Nov 2006)
New Revision: 7701
Added:
labs/jbossrules/trunk/drools-repository/repository.xml
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/BaseResourceHandler.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/RepositoryBean.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceHandler.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceType.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/SvnResourceHandler.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceAccessDeniedException.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceTypeNotSupportedException.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceUrlNotFoundException.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/util/
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/util/SvnUtil.java
labs/jbossrules/trunk/drools-repository/src/main/resources/example-testng.xml
labs/jbossrules/trunk/drools-repository/src/main/resources/log4j.xml
labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/resource/
labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/resource/SvnResourceHandlerTest.java
labs/jbossrules/trunk/drools-repository/src/test/resources/files/
labs/jbossrules/trunk/drools-repository/src/test/resources/files/drls/
labs/jbossrules/trunk/drools-repository/src/test/resources/files/drls/test.drl
labs/jbossrules/trunk/drools-repository/src/test/resources/files/dsls/
labs/jbossrules/trunk/drools-repository/src/test/resources/files/dsls/test.dsl
labs/jbossrules/trunk/drools-repository/src/test/resources/files/functions/
labs/jbossrules/trunk/drools-repository/src/test/resources/files/functions/test.function
labs/jbossrules/trunk/drools-repository/src/test/resources/files/rules/
labs/jbossrules/trunk/drools-repository/src/test/resources/files/rules/test.rule
labs/jbossrules/trunk/drools-repository/src/test/resources/files/spreadsheets/
labs/jbossrules/trunk/drools-repository/src/test/resources/files/spreadsheets/test.xls
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/README.txt
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/authz
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/passwd
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/svnserve.conf
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/dav/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/current
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/format
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/fs-type
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/0
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/1
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/0
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/1
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/transactions/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/uuid
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/write-lock
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/format
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-commit.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-lock.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-revprop-change.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-unlock.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-commit.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-lock.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-revprop-change.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-unlock.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/start-commit.tmpl
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db-logs.lock
labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db.lock
Modified:
labs/jbossrules/trunk/drools-repository/.classpath
labs/jbossrules/trunk/drools-repository/pom.xml
Log:
JBRULES-563 ResourceHandler API for t he repository
Modified: labs/jbossrules/trunk/drools-repository/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-repository/.classpath 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/.classpath 2006-11-18 11:23:01 UTC (rev 7701)
@@ -5,16 +5,17 @@
<classpathentry kind="src" path="src/test/resources" output="target/test-classes"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/tmatesoft/javasvn/1.1-beta5/javasvn-1.1-beta5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xmlParserAPIs/2.0.2/xmlParserAPIs-2.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
<classpathentry kind="var" path="M2_REPO/lucene/lucene/1.4.3/lucene-1.4.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.0/slf4j-log4j12-1.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-core/1.0.1/jackrabbit-core-1.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-core/1.0.1/jackrabbit-core-1.0.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/geronimo-spec/geronimo-spec-jta/1.0-M1/geronimo-spec-jta-1.0-M1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/xerces/xmlParserAPIs/2.0.2/xmlParserAPIs-2.0.2.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.0/slf4j-log4j12-1.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/jsr170/jcr/1.0/jcr-1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/derby/derby/10.1.1.0/derby-10.1.1.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/geronimo-spec/geronimo-spec-jta/1.0-M1/geronimo-spec-jta-1.0-M1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/jcr/jcr/1.0/jcr-1.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar"/>
</classpath>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-repository/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-repository/pom.xml 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/pom.xml 2006-11-18 11:23:01 UTC (rev 7701)
@@ -28,7 +28,13 @@
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>1.0.1</version>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.tmatesoft</groupId>
+ <artifactId>javasvn</artifactId>
+ <version>1.1-beta5</version>
+ </dependency>
</dependencies>
<build>
Added: labs/jbossrules/trunk/drools-repository/repository.xml
===================================================================
--- labs/jbossrules/trunk/drools-repository/repository.xml 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/repository.xml 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,224 @@
+<?xml version="1.0"?>
+<!DOCTYPE Repository [
+ <!--
+ the Repository element configures a repository instance;
+ individual workspaces of the repository are configured through
+ separate configuration files called workspace.xml which are
+ located in a subfolder of the workspaces root directory
+ (see Workspaces element).
+
+ it consists of
+
+ a FileSystem element (the virtual file system
+ used by the repository to persist global state such as
+ registered namespaces, custom node types, etc..
+
+ a Security element that specifies the name of the app-entry
+ in the JAAS config and the access manager
+
+ a Workspaces element that specifies to the location of
+ workspaces root directory and the name of default workspace
+
+ a Workspace element that is used as a workspace configuration
+ template; it is used to create the initial workspace if there's
+ no workspace yet and for creating additional workspaces through
+ the api
+
+ a Versioning element that is used for configuring
+ versioning-related settings
+
+ a SearchIndex element that is used for configuring Indexing-related
+ settings on the /jcr:system tree.
+ -->
+ <!ELEMENT Repository (FileSystem,Security,Workspaces,Workspace,Versioning,SearchIndex?)>
+
+ <!--
+ a virtual file system
+ -->
+ <!ELEMENT FileSystem (param*)>
+ <!ATTLIST FileSystem
+ class CDATA #REQUIRED>
+
+ <!--
+ the Security element specifies the name (appName attribute)
+ of the JAAS configuration app-entry for this repository.
+
+ it also specifies the access manager to be used (AccessManager element).
+ -->
+ <!ELEMENT Security (AccessManager, LoginModule?)>
+ <!ATTLIST Security
+ appName CDATA #REQUIRED>
+
+ <!--
+ the AccessManager element configures the access manager to be used by
+ this repository instance; the class attribute specifies the FQN of the
+ class implementing the AccessManager interface
+ -->
+ <!ELEMENT AccessManager (param*)>
+ <!ATTLIST AccessManager
+ class CDATA #REQUIRED>
+
+ <!--
+ generic parameter (name/value pair)
+ -->
+ <!ELEMENT param EMPTY>
+ <!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED>
+
+ <!--
+ the LoginModule element optionally specifies a JAAS login module to
+ authenticate users. This feature allows the use of Jackrabbit in a
+ non-JAAS environment.
+ -->
+ <!ELEMENT LoginModule (param*)>
+ <!ATTLIST LoginModule
+ class CDATA #REQUIRED>
+
+ <!--
+ the Workspaces element specifies the workspaces root directory
+ (rootPath attribute) and the name of the default workspace
+ (defaultWorkspace attribute).
+
+ individual workspaces are configured through individual workspace.xml
+ files located in a subfolder each of the workspaces root directory.
+ -->
+ <!ELEMENT Workspaces EMPTY>
+ <!ATTLIST Workspaces
+ rootPath CDATA #REQUIRED
+ defaultWorkspace CDATA #REQUIRED>
+
+ <!--
+ the Workspace element serves as a workspace configuration template;
+ it is used to create the initial workspace if there's no workspace yet
+ and for creating additional workspaces through the api
+ -->
+ <!ELEMENT Workspace (FileSystem,PersistenceManager,SearchIndex?)>
+ <!ATTLIST Workspace
+ name CDATA #REQUIRED>
+
+ <!--
+ the PersistenceManager element configures the persistence manager
+ to be used for the workspace; the class attribute specifies the
+ FQN of the class implementing the PersistenceManager interface
+ -->
+ <!ELEMENT PersistenceManager (param*)>
+ <!ATTLIST PersistenceManager
+ class CDATA #REQUIRED>
+
+ <!--
+ the SearchIndex element specifies the locaction of the search index
+ (used by the QueryHandler); the class attribute specifies the
+ FQN of the class implementing the QueryHandler interface.
+ -->
+ <!ELEMENT SearchIndex (param*,FileSystem?)>
+ <!ATTLIST SearchIndex
+ class CDATA #REQUIRED>
+
+ <!--
+ the Versioning element configures the persistence manager
+ to be used for persisting version state
+ -->
+ <!ELEMENT Versioning (FileSystem, PersistenceManager)>
+ <!ATTLIST Versioning
+ rootPath CDATA #REQUIRED
+ >
+]>
+<!-- Example Repository Configuration File -->
+<Repository>
+ <!--
+ virtual file system where the repository stores global state
+ (e.g. registered namespaces, custom node types, etc.)
+ -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/repository"/>
+ </FileSystem>
+
+ <!--
+ security configuration
+ -->
+ <Security appName="Jackrabbit">
+ <!--
+ access manager:
+ class: FQN of class implementing the AccessManager interface
+ -->
+ <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+ <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+ </AccessManager>
+
+ <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+ <!-- anonymous user name ('anonymous' is the default value) -->
+ <param name="anonymousId" value="anonymous"/>
+ <!--
+ default user name to be used instead of the anonymous user
+ when no login credentials are provided (unset by default)
+ -->
+ <!-- <param name="defaultUserId" value="superuser"/> -->
+ </LoginModule>
+ </Security>
+
+ <!--
+ location of workspaces root directory and name of default workspace
+ -->
+ <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+ <!--
+ workspace configuration template:
+ used to create the initial workspace if there's no workspace yet
+ -->
+ <Workspace name="${wsp.name}">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing the FileSystem interface
+ -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}"/>
+ </FileSystem>
+ <!--
+ persistence manager of the workspace:
+ class: FQN of class implementing the PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
+ <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+ <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+ </PersistenceManager>
+ <!--
+ Search index and the file system it uses.
+ class: FQN of class implementing the QueryHandler interface
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${wsp.home}/index"/>
+ </SearchIndex>
+ </Workspace>
+
+ <!--
+ Configures the versioning
+ -->
+ <Versioning rootPath="${rep.home}/version">
+ <!--
+ Configures the filesystem to use for versioning for the respective
+ persistence manager
+ -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/version" />
+ </FileSystem>
+
+ <!--
+ Configures the persistence manager to be used for persisting version state.
+ Please note that the current versioning implementation is based on
+ a 'normal' persistence manager, but this could change in future
+ implementations.
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.db.DerbyPersistenceManager">
+ <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
+ <param name="schemaObjectPrefix" value="version_"/>
+ </PersistenceManager>
+ </Versioning>
+
+ <!--
+ Search index for content that is shared repository wide
+ (/jcr:system tree, contains mainly versions)
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${rep.home}/repository/index"/>
+ </SearchIndex>
+</Repository>
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/BaseResourceHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/BaseResourceHandler.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/BaseResourceHandler.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,14 @@
+package org.drools.resource;
+
+/**
+ * This class is the base resource handler that includes attributes/methods that
+ * all sub-classes will need.
+ *
+ * @author James Williams (james.williams at redhat.com)
+ *
+ */
+public abstract class BaseResourceHandler {
+
+ //All implementations will be URL based
+ protected String repositoryUrl = "";
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/RepositoryBean.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/RepositoryBean.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/RepositoryBean.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,59 @@
+package org.drools.resource;
+
+/**
+ * The repository elements that can be referenced via URL will typically
+ * have several attributes including a unique URL, resource type, name, version
+ * and of course content. This meta-data object just describes what the URL
+ * resource is. Single Rules, DRLs, functions, DSLs and spreadsheets all need
+ * to be supported.
+ *
+ * @author James Williams (james.williams at redhat.com)
+ *
+ */
+public class RepositoryBean {
+
+ private String version = "-1";
+ private String name;
+ private ResourceType resourceType;
+ private String resourceContent;
+
+ public String getResourceContent() {
+ return resourceContent;
+ }
+
+ public void setResourceContent(String resourceContent) {
+ this.resourceContent = resourceContent;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public long getVersionInLong() {
+ return Long.valueOf( this.version ).longValue();
+ }
+
+ public void setVersion(long version) {
+ this.version = String.valueOf( version );
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceHandler.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceHandler.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,74 @@
+package org.drools.resource;
+
+import java.io.ByteArrayOutputStream;
+
+import org.drools.resource.exception.ResourceAccessDeniedException;
+import org.drools.resource.exception.ResourceTypeNotSupportedException;
+import org.drools.resource.exception.ResourceUrlNotFoundException;
+
+/**
+ * Resource handler for interace that all implementations must provide.
+ * Subversion is the first implementation of this interface. The interface
+ * may need to be changed/extended to accomodate advanced line items, like
+ * resource locking/deployment.
+ *
+ * @author James Williams (james.williams at redhat.com)
+ *
+ */
+public interface ResourceHandler {
+
+ /**
+ * Get the URL contents.
+ *
+ * This method should also be smart enough to pull the specific version
+ * if specified in the RepositoryBean version attribute.
+ *
+ * @param aRepositoryBean
+ * @return
+ */
+ public ByteArrayOutputStream getResourceStream(RepositoryBean aRepositoryBean) throws ResourceUrlNotFoundException,
+ ResourceTypeNotSupportedException,
+ ResourceAccessDeniedException;
+
+ /**
+ * Get the latest version of the resource from the repository if no version
+ * is specified.
+ *
+ * This method should also be smart enough to pull the specific version
+ * if specified in the RepositoryBean version attribute.
+ *
+ * @param aRepositoryBean
+ * @return
+ * @throws ResourceTypeNotSupportedException
+ */
+ public String getResourceURL(RepositoryBean aRepositoryBean) throws ResourceTypeNotSupportedException;
+
+ /**
+ * Authenticate the user based on his/her credentials, typically a
+ * username/password combo.
+ *
+ * @param url
+ * @return
+ */
+ public boolean authenticate(String url);
+
+ /**
+ * Set the credentials for the resource handler calls. Typically called
+ * before the user attempts to get any resources.
+ *
+ * @param username
+ * @param password
+ */
+ public void setCredentials(String username,
+ String password);
+
+ public void setRepositoryUrl(String url);
+
+ //resource types that need to be supported
+// public static final int DRL_FILE = 1;
+// public static final int RULE = 2;
+// public static final int FUNCTION = 3;
+// public static final int DSL_FILE = 4;
+// public static final int XLS_FILE = 5;
+
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceType.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceType.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/ResourceType.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,37 @@
+package org.drools.resource;
+
+public class ResourceType {
+ public static final ResourceType DRL_FILE = new ResourceType( 1 );
+ public static final ResourceType RULE = new ResourceType( 2 );
+ public static final ResourceType FUNCTION = new ResourceType( 3 );
+ public static final ResourceType DSL_FILE = new ResourceType( 4 );
+ public static final ResourceType XLS_FILE = new ResourceType( 5 );
+
+
+ private int type;
+
+ private ResourceType(int type) {
+ this.type = type;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+ private Object readResolve() throws java.io.ObjectStreamException {
+ switch ( this.type ) {
+ case 1:
+ return DRL_FILE;
+ case 2:
+ return RULE;
+ case 3:
+ return FUNCTION;
+ case 4:
+ return DSL_FILE;
+ case 5:
+ return XLS_FILE;
+ default:
+ }
+ throw new RuntimeException( "unable to determine ResourceType for value [" + this.type + "]" );
+ }
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/SvnResourceHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/SvnResourceHandler.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/SvnResourceHandler.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,152 @@
+package org.drools.resource;
+
+import java.io.ByteArrayOutputStream;
+
+import org.drools.resource.exception.ResourceAccessDeniedException;
+import org.drools.resource.exception.ResourceTypeNotSupportedException;
+import org.drools.resource.exception.ResourceUrlNotFoundException;
+import org.drools.resource.util.SvnUtil;
+import org.tmatesoft.svn.core.SVNException;
+
+/**
+ * Resource Handler implementation for subversion. Assumes that there is an HTTP
+ * accessible subversion repository with the following structure:
+ *
+ * Base URL - Example: http://localhost/svn/resource-handler Subfolders off the
+ * base URL:
+ * /drls
+ * /dsls
+ * /functions
+ * /rules
+ * /spreadsheets
+ *
+ * Security can be enabled and if it's enabled, you will need to have
+ * appropriate credentials to access any URL resource.
+ *
+ * @author James Williams (james.williams at redhat.com)
+ *
+ */
+public class SvnResourceHandler extends BaseResourceHandler
+ implements
+ ResourceHandler {
+
+ private String username = "";
+ private String password = "";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.drools.resource.ResourceHandler#authenticate(java.lang.String)
+ */
+ public boolean authenticate(String url) {
+ return SvnUtil.authenticate( username,
+ password,
+ url );
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.drools.resource.ResourceHandler#setCredentials(java.lang.String,
+ * java.lang.String)
+ */
+ public void setCredentials(String username,
+ String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.drools.resource.ResourceHandler#getResourceStream(org.drools.resource.RepositoryBean)
+ */
+ public ByteArrayOutputStream getResourceStream(RepositoryBean aRepositoryBean) throws ResourceUrlNotFoundException,
+ ResourceTypeNotSupportedException,
+ ResourceAccessDeniedException {
+
+ String url = new String();
+ ByteArrayOutputStream baos;
+ try {
+ url = getResourceURL( aRepositoryBean );
+ if ( !authenticate( url ) ) {
+ throw new ResourceAccessDeniedException( url,
+ this.username,
+ this.password );
+ }
+
+ else {
+ baos = SvnUtil.getFileContentsFromSvn( url,
+ this.username,
+ this.password,
+ aRepositoryBean.getVersionInLong() );
+ }
+ }
+
+ catch ( SVNException e ) {
+ e.printStackTrace();
+ throw new ResourceUrlNotFoundException( url );
+ } catch ( ResourceTypeNotSupportedException exc ) {
+ throw exc;
+ }
+ return baos;
+ }
+
+ /*
+ *
+ * @see org.drools.resource.ResourceHandler#getResourceURL(org.drools.resource.RepositoryBean)
+ */
+ public String getResourceURL(RepositoryBean aRepositoryBean) throws ResourceTypeNotSupportedException {
+
+ StringBuffer urlBuf = new StringBuffer( repositoryUrl );
+ if ( aRepositoryBean.getResourceType() == ResourceType.DRL_FILE ) {
+ urlBuf.append( "/drls/" );
+ urlBuf.append( aRepositoryBean.getName() );
+ urlBuf.append( ".drl" );
+ } else if ( aRepositoryBean.getResourceType() == ResourceType.FUNCTION ) {
+ urlBuf.append( "/functions/" );
+ urlBuf.append( aRepositoryBean.getName() );
+ urlBuf.append( ".function" );
+ } else if ( aRepositoryBean.getResourceType() == ResourceType.RULE ) {
+ urlBuf.append( "/rules/" );
+ urlBuf.append( aRepositoryBean.getName() );
+ urlBuf.append( ".rule" );
+ } else if ( aRepositoryBean.getResourceType() == ResourceType.DSL_FILE ) {
+ urlBuf.append( "/dsls/" );
+ urlBuf.append( aRepositoryBean.getName() );
+ urlBuf.append( ".dsl" );
+ } else if ( aRepositoryBean.getResourceType() == ResourceType.XLS_FILE ) {
+ urlBuf.append( "/spreadsheets/" );
+ urlBuf.append( aRepositoryBean.getName() );
+ urlBuf.append( ".xls" );
+ } else {
+ throw new ResourceTypeNotSupportedException( urlBuf.toString() );
+ }
+
+ return urlBuf.toString();
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public void setRepositoryUrl(String url) {
+ this.repositoryUrl = url;
+ }
+
+ public String getRepositoryUrl() {
+ return this.repositoryUrl;
+ }
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceAccessDeniedException.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceAccessDeniedException.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceAccessDeniedException.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.drools.resource.exception;
+
+/**
+ * @author jwilliams
+ *
+ */
+public class ResourceAccessDeniedException extends Exception {
+
+ private String url;
+ private String username;
+ private String password;
+
+ public ResourceAccessDeniedException(String url,
+ String username,
+ String password) {
+ this.url = url;
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getMessage() {
+ return "You do not have the right access priveleges for this resource: " + url + "\nwith username=" + username + " and password=" + password;
+ }
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceTypeNotSupportedException.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceTypeNotSupportedException.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceTypeNotSupportedException.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.drools.resource.exception;
+
+/**
+ * @author jwilliams
+ *
+ */
+public class ResourceTypeNotSupportedException extends Exception {
+
+ private String url;
+
+ public ResourceTypeNotSupportedException(String url) {
+ this.url = url;
+ }
+
+ public String getMessage() {
+ return "The requested URL resource type is not supported: " + url;
+ }
+
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceUrlNotFoundException.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceUrlNotFoundException.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/exception/ResourceUrlNotFoundException.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.drools.resource.exception;
+
+/**
+ * @author jwilliams
+ *
+ */
+public class ResourceUrlNotFoundException extends Exception {
+
+ private String url;
+
+ public ResourceUrlNotFoundException(String url) {
+ this.url = url;
+ }
+
+ public String getMessage() {
+ return "The requested URL resource type cannot be found: " + url;
+ }
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/util/SvnUtil.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/util/SvnUtil.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/resource/util/SvnUtil.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.drools.resource.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.drools.resource.RepositoryBean;
+import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNNodeKind;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
+import org.tmatesoft.svn.core.io.SVNRepository;
+import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+/**
+ * Subversion utility class that uses JavaSVN to get rules and rule lists from
+ * Subversion via http. It is assumed that you have a working SVN Repository
+ * that is URL enabled. This class does support credentials, so the repository
+ * doesn't have to be setup with anonymous access, although that's the easiest
+ * to get working.
+ *
+ * @author James Williams
+ *
+ */
+public class SvnUtil {
+ private static Logger logger = Logger.getLogger( SvnUtil.class );
+
+ /**
+ * Get a DRL file's contents from Subversion.
+ *
+ * @param svnUrl -
+ * URL
+ * @param svnUsername -
+ * username
+ * @param svnPassword -
+ * password
+ * @param ruleVersion -
+ * tag or trunk SVN folder, which represents the subdirectory
+ * that contains the DRL.
+ * @param drlName -
+ * DRL file name
+ * @return
+ * @throws SVNException
+ */
+ public static ByteArrayOutputStream getFileContentsFromSvn(String url,
+ String svnUsername,
+ String svnPassword,
+ long version) throws SVNException {
+ String username = svnUsername;
+ String password = svnPassword;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ setupLibrary();
+
+ try {
+ SVNRepository repository = null;
+
+ /*
+ * Creates an instance of SVNRepository to work with the repository.
+ * All user's requests to the repository are relative to the
+ * repository location used to create this SVNRepository. SVNURL is
+ * a wrapper for URL strings that refer to repository locations.
+ */
+ repository = SVNRepositoryFactoryImpl.create( SVNURL.parseURIEncoded( url ) );
+
+ /*
+ * User's authentication information is provided via an
+ * ISVNAuthenticationManager instance. SVNWCUtil creates a default
+ * usre's authentication manager given user's name and password.
+ */
+ ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( username,
+ password );
+
+ /*
+ * Sets the manager of the user's authentication information that
+ * will be used to authenticate the user to the server (if needed)
+ * during operations handled by the SVNRepository.
+ */
+ repository.setAuthenticationManager( authManager );
+
+ /*
+ * This Map will be used to get the file properties. Each Map key is
+ * a property name and the value associated with the key is the
+ * property value.
+ */
+ Map fileProperties = new HashMap();
+
+ /*
+ * Checks up if the specified path really corresponds to a file. If
+ * doesn't the program exits. SVNNodeKind is that one who says what
+ * is located at a path in a revision. -1 means the latest revision.
+ */
+ SVNNodeKind nodeKind = repository.checkPath( "",
+ -1 );
+
+ if ( nodeKind == SVNNodeKind.NONE ) {
+ logger.error( "There is no entry at '" + url + "'." );
+
+ } else if ( nodeKind == SVNNodeKind.DIR ) {
+ logger.error( "The entry at '" + url + "' is a directory while a file was expected." );
+
+ }
+
+ /*
+ * Gets the contents and properties of the file located at filePath
+ * in the repository at the latest revision (which is meant by a
+ * negative revision number).
+ */
+ repository.getFile( "",
+ version,
+ fileProperties,
+ baos );
+
+ } catch ( SVNException e ) {
+ e.printStackTrace();
+ logger.error( "The SVN file cannot be found. " + url );
+ throw e;
+ }
+
+ return baos;
+ }
+
+ /**
+ * Get a list of rule repository resources from subversion.
+ *
+ * @param criteriaBean
+ * @return
+ * @throws SVNException
+ */
+ public static List getRepositoryBeanList(RepositoryBean criteriaBean,
+ String username,
+ String password,
+ String repositoryUrl) throws RuntimeException {
+ String url = repositoryUrl;
+ List resourceList = new ArrayList();
+
+ logger.debug( "URL is: " + url );
+ /*
+ * initializes the library (it must be done before ever using the
+ * library itself)
+ */
+ setupLibrary();
+ try {
+ SVNRepository repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded( url ) );
+ // we need to narrow down collection list to resources in a folder
+ // before
+ // this call
+ Collection entries = repository.getDir( url,
+ -1,
+ null,
+ (Collection) null );
+
+ Collections.sort( resourceList );
+ Iterator i = entries.iterator();
+ while ( i.hasNext() ) {
+ String svnDetail = ((SVNDirEntry) i.next()).toString();
+ // here is where we need to insert criteria logic
+ }
+ } catch ( SVNException e ) {
+ logger.error( "Repository does not exist or is unavailable" );
+ throw new RuntimeException( e );
+ }
+
+ return resourceList;
+ }
+
+ /**
+ * Write the DRL file out to a String.
+ *
+ * @param baos
+ * @return
+ */
+ public static String writeFile(ByteArrayOutputStream baos) {
+ String fileText = null;
+ try {
+ fileText = baos.toString( "text/html" );
+ } catch ( IOException ioe ) {
+ logger.error( ioe );
+ }
+
+ return fileText;
+ }
+
+ public static ByteArrayOutputStream getByteArrayOutputFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream( file );
+
+ // Get the size of the file
+ long length = file.length();
+
+ // You cannot create an array using a long type.
+ // It needs to be an int type.
+ // Before converting to an int type, check
+ // to ensure that file is not larger than Integer.MAX_VALUE.
+ if ( length > Integer.MAX_VALUE ) {
+ // File is too large
+ }
+
+ // Create the byte array to hold the data
+ byte[] bytes = new byte[(int) length];
+
+ // Read in the bytes
+ int offset = 0;
+ int numRead = 0;
+ while ( offset < bytes.length && (numRead = is.read( bytes,
+ offset,
+ bytes.length - offset )) >= 0 ) {
+ offset += numRead;
+ }
+
+ // Ensure all the bytes have been read in
+ if ( offset < bytes.length ) {
+ throw new IOException( "Could not completely read file " + file.getName() );
+ }
+
+ // Close the input stream and return bytes
+ is.close();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write( bytes );
+ return baos;
+ }
+
+ /*
+ * Initializes the library to work with a repository either via svn:// (and
+ * svn+ssh://) or via http:// (and https://)
+ */
+ public static void setupLibrary() {
+ // for DAV (over http and https)
+ DAVRepositoryFactory.setup();
+
+ // for SVN (over svn and svn+ssh)
+ SVNRepositoryFactoryImpl.setup();
+
+ // For File
+ FSRepositoryFactory.setup();
+ }
+
+ /**
+ * authenticate a subversion user for access to a particular URL.
+ *
+ * @param criteriaBean
+ * @return
+ * @throws SVNException
+ */
+ public static boolean authenticate(String username,
+ String password,
+ String repositoryUrl) throws RuntimeException {
+
+ try {
+ logger.debug( "Subversion authentication for : username=" + username + ", password=" + password + ", repositoryURL=" + repositoryUrl );
+
+ setupLibrary();
+ SVNRepository repository = null;
+
+ /*
+ * Creates an instance of SVNRepository to work with the repository.
+ * All user's requests to the repository are relative to the
+ * repository location used to create this SVNRepository. SVNURL is
+ * a wrapper for URL strings that refer to repository locations.
+ */
+ repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded( repositoryUrl ) );
+
+ /*
+ * User's authentication information is provided via an
+ * ISVNAuthenticationManager instance. SVNWCUtil creates a default
+ * usre's authentication manager given user's name and password.
+ */
+ ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( username,
+ password );
+
+ /*
+ * Sets the manager of the user's authentication information that
+ * will be used to authenticate the user to the server (if needed)
+ * during operations handled by the SVNRepository.
+ */
+ repository.setAuthenticationManager( authManager );
+ repository.testConnection();
+ } catch ( SVNException e ) {
+ logger.error( e.getErrorMessage() );
+ return false;
+ }
+
+ return true;
+ }
+
+}
Added: labs/jbossrules/trunk/drools-repository/src/main/resources/example-testng.xml
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/resources/example-testng.xml 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/resources/example-testng.xml 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,9 @@
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+
+<suite name="Resource Handler Test Suite" verbose="2" parallel="false">
+ <test name="Resource Handler Tests">
+ <classes>
+ <class name="org.drools.resource.test.SvnResourceHandlerTest"/>
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-repository/src/main/resources/log4j.xml
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/resources/log4j.xml 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/main/resources/log4j.xml 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.8 2006/04/26 17:29:10 gavin Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <priority value="DEBUG"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Added: labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/resource/SvnResourceHandlerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/resource/SvnResourceHandlerTest.java 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/resource/SvnResourceHandlerTest.java 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,264 @@
+package org.drools.resource;
+
+import java.io.File;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.drools.resource.RepositoryBean;
+import org.drools.resource.ResourceHandler;
+import org.drools.resource.SvnResourceHandler;
+import org.drools.resource.util.SvnUtil;
+
+/**
+ * @author James Williams (james.williams at redhat.com)
+ *
+ */
+public class SvnResourceHandlerTest extends TestCase {
+
+ private static Logger logger = Logger.getLogger( SvnResourceHandlerTest.class );
+
+ private static String svnUrl = "file:///D:/dev/trunk2/rule-resource-handler/target/test-classes/svn_repo";
+ private static String testFilePath = "D:/dev/trunk2/rule-resource-handler/target/test-classes/files";
+
+ public void setUp() {
+ // First we need to find the absolute path
+ File file = new File ( getClass().getClassLoader().getSystemClassLoader().getResource( "svn_repo" ).getFile() );
+
+ // Now set the two path roots
+ svnUrl = "file:///" + file.getAbsolutePath().replaceAll( "\\\\", "/" );
+ testFilePath = file.getParentFile().getAbsolutePath().replaceAll( "\\\\", "/" ) + "/files";
+ }
+
+ public void testAuthentication() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+ boolean authRtnPass = rHandler.authenticate( "file:///D:/dev/trunk2/rule-resource-handler/target/test-classes/svn_repo" );
+ boolean authRtnFail = rHandler.authenticate( "file:///D:/dev/trunk2/rule-resource-handler/target/test-classes/svn_repo2" );
+
+ assertEquals( true,
+ authRtnPass );
+ assertEquals( false,
+ authRtnFail );
+
+ logger.debug( "testAuthentication executed" );
+ }
+
+ public void testGetDrlFile() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.DRL_FILE );
+ try {
+ File f = new File( testFilePath + "/drls/test.drl" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetDrlFileByVersion() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.DRL_FILE );
+
+ //this value is unique to your subversion implementation
+ bean.setVersion( "1" );
+
+ try {
+ File f = new File( testFilePath + "/drls/test.drl" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetDslFile() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.DSL_FILE );
+
+ try {
+ File f = new File( testFilePath + "/dsls/test.dsl" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetDslFileByVersion() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.DSL_FILE );
+
+ //this value is unique to your subversion implementation
+ bean.setVersion( "1" );
+
+ try {
+ File f = new File( testFilePath + "/dsls/test.dsl" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetRuleFunctionByVersion() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.FUNCTION );
+
+ //this value is unique to your subversion implementation
+ bean.setVersion( "1" );
+
+ try {
+ File f = new File( testFilePath + "/functions/test.function" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetRuleFunction() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.FUNCTION );
+
+ try {
+ File f = new File( testFilePath + "/functions/test.function" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetRule() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.RULE );
+
+ try {
+ File f = new File( testFilePath + "/rules/test.rule" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetRuleByVersion() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.RULE );
+
+ //this value is unique to your subversion implementation
+ bean.setVersion( "1" );
+
+ try {
+ File f = new File( testFilePath + "/rules/test.rule" );
+ System.out.println( rHandler.getResourceStream( bean ) );
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetSpreadsheet() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.XLS_FILE );
+
+ try {
+ File f = new File( testFilePath + "/spreadsheets/test.xls" );
+ // System.out.println(rHandler.getResourceStream(bean));
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+ public void testGetSpreadsheetByVersion() {
+ ResourceHandler rHandler = new SvnResourceHandler();
+ rHandler.setRepositoryUrl( svnUrl );
+ rHandler.setCredentials( "mrtrout",
+ "drools" );
+
+ RepositoryBean bean = new RepositoryBean();
+ bean.setName( "test" );
+ bean.setResourceType( ResourceType.XLS_FILE );
+
+ //this value is unique to your subversion implementation
+ bean.setVersion( "1" );
+
+ try {
+ File f = new File( testFilePath + "/spreadsheets/test.xls" );
+ // System.out.println(rHandler.getResourceStream(bean));
+ assertEquals( SvnUtil.getByteArrayOutputFromFile( f ).toString(),
+ rHandler.getResourceStream( bean ).toString() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ }
+ }
+
+}
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/files/drls/test.drl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/files/drls/test.drl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/files/drls/test.drl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,17 @@
+#created on: Oct 30, 2006
+package test
+
+rule "Your First Rule"
+ when
+ #conditions
+ then
+ #actions
+end
+
+rule "Your Second Rule"
+ #include attributes such as "salience" here...
+ when
+ #conditions
+ then
+ #actions
+end
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/files/dsls/test.dsl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/files/dsls/test.dsl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/files/dsls/test.dsl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,9 @@
+#This is a starter DSL to show off some of the features. Make sure you change it to be what you need !.
+[when]There is an Instance with field of "{value}"=i: Instance(field=="{value}")
+[when]Instance is at least {number} and field is "{value}"=i: Instance(number > {number}, location=="{value}")
+[then]Log : "{message}"=System.out.println("{message}");
+[then]Set field of instance to "{value}"=i.setField("{value}");
+[then]Create instance : "{value}"=assert(new Instance("{value}"));
+[when]There is no current Instance with field : "{value}"=not Instance(field == "{value}")
+[then]Report error : "{error}"=System.err.println("{error}");
+[then]Retract the fact : '{variable}'=retract({variable}); //this would retract bound variable {variable}
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/files/functions/test.function
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/files/functions/test.function 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/files/functions/test.function 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1 @@
+This is a rules function
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/files/rules/test.rule
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/files/rules/test.rule 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/files/rules/test.rule 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1 @@
+This is a test rule
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/files/spreadsheets/test.xls
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-repository/src/test/resources/files/spreadsheets/test.xls
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/README.txt
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/README.txt 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/README.txt 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,5 @@
+This is a Subversion repository; use the 'svnadmin' tool to examine
+it. Do not add, delete, or modify files here unless you know how
+to avoid corrupting the repository.
+
+Visit http://subversion.tigris.org/ for more information.
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/authz
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/authz 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/authz 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,21 @@
+### This file is an example authorization file for svnserve.
+### Its format is identical to that of mod_authz_svn authorization
+### files.
+### As shown below each section defines authorizations for the path and
+### (optional) repository specified by the section name.
+### The authorizations follow. An authorization line can refer to a
+### single user, to a group of users defined in a special [groups]
+### section, or to anyone using the '*' wildcard. Each definition can
+### grant read ('r') access, read-write ('rw') access, or no access
+### ('').
+
+[groups]
+# harry_and_sally = harry,sally
+
+# [/foo/bar]
+# harry = rw
+# * =
+
+# [repository:/baz/fuz]
+# @harry_and_sally = rw
+# * = r
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/passwd
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/passwd 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/passwd 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,7 @@
+### This file is an example password file for svnserve.
+### Its format is similar to that of svnserve.conf. As shown in the
+### example below it contains one section labelled [users].
+### The name and password for each user follow, one account per line.
+
+[users]
+mrtrout = drools
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/svnserve.conf
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/svnserve.conf 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/conf/svnserve.conf 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,30 @@
+### This file controls the configuration of the svnserve daemon, if you
+### use it to allow access to this repository. (If you only allow
+### access through http: and/or file: URLs, then this file is
+### irrelevant.)
+
+### Visit http://subversion.tigris.org/ for more information.
+
+[general]
+### These options control access to the repository for unauthenticated
+### and authenticated users. Valid values are "write", "read",
+### and "none". The sample settings below are the defaults.
+# anon-access = read
+# auth-access = write
+### The password-db option controls the location of the password
+### database file. Unless you specify a path starting with a /,
+### the file's location is relative to the conf directory.
+### Uncomment the line below to use the default password file.
+password-db = passwd
+### The authz-db option controls the location of the authorization
+### rules for path-based access control. Unless you specify a path
+### starting with a /, the file's location is relative to the conf
+### directory. If you don't specify an authz-db, no path-based access
+### control is done.
+### Uncomment the line below to use the default authorization file.
+# authz-db = authz
+### This option specifies the authentication realm of the repository.
+### If two repositories have the same authentication realm, they should
+### have the same password database, and vice versa. The default realm
+### is repository's uuid.
+# realm = My First Repository
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/current
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/current 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/current 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1 @@
+1 b 1
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/format
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/format 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/format 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1 @@
+2
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/fs-type
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/fs-type 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/fs-type 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1 @@
+fsfs
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/0
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/0 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/0 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,5 @@
+K 8
+svn:date
+V 27
+2006-11-13T22:06:51.921875Z
+END
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/1
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/1 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revprops/1 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,13 @@
+K 10
+svn:author
+V 7
+mrtrout
+K 8
+svn:date
+V 27
+2006-11-13T22:09:53.734375Z
+K 7
+svn:log
+V 0
+
+END
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/0
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/0 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/0 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,11 @@
+PLAIN
+END
+ENDREP
+id: 0.0.r0/17
+type: dir
+count: 0
+text: 0 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e
+cpath: /
+
+
+17 107
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/1
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/revs/1
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/uuid
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/uuid 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/uuid 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1 @@
+061e0160-7260-2a4b-ba4c-d68616b12a72
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/db/write-lock
===================================================================
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/format
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/format 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/format 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1 @@
+5
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-commit.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-commit.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-commit.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# POST-COMMIT HOOK
+#
+# The post-commit hook is invoked after a commit. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-commit' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the number of the revision just committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the commit has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-committed tree.
+#
+# On a Unix system, the normal procedure is to have 'post-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-commit.bat' or 'post-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+
+commit-email.pl "$REPOS" "$REV" commit-watchers at example.org
+log-commit.py --repository "$REPOS" --revision "$REV"
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-lock.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-lock.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-lock.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# POST-LOCK HOOK
+#
+# The post-lock hook is run after a path is locked. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-lock' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the user who created the lock)
+#
+# The paths that were just locked are passed to the hook via STDIN (as
+# of Subversion 1.2, only one path is passed per invocation, but the
+# plan is to pass all locked paths at once, so the hook program
+# should be written accordingly).
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the lock has already been created and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-created lock.
+#
+# On a Unix system, the normal procedure is to have 'post-lock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-lock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-lock.bat' or 'post-lock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+USER="$2"
+
+# Send email to interested parties, let them know a lock was created:
+mailer.py lock "$REPOS" "$USER" /path/to/mailer.conf
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-revprop-change.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-revprop-change.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-revprop-change.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# POST-REVPROP-CHANGE HOOK
+#
+# The post-revprop-change hook is invoked after a revision property
+# has been added, modified or deleted. Subversion runs this hook by
+# invoking a program (script, executable, binary, etc.) named
+# 'post-revprop-change' (for which this file is a template), with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the revision that was tweaked)
+# [3] USER (the username of the person tweaking the property)
+# [4] PROPNAME (the property that was changed)
+# [5] ACTION (the property was 'A'dded, 'M'odified, or 'D'eleted)
+#
+# [STDIN] PROPVAL ** the old property value is passed via STDIN.
+#
+# Because the propchange has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# new property value.
+#
+# On a Unix system, the normal procedure is to have 'post-revprop-change'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-revprop-change' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-revprop-change.bat' or 'post-revprop-change.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+ACTION="$5"
+
+propchange-email.pl "$REPOS" "$REV" "$USER" "$PROPNAME" watchers at example.org
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-unlock.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-unlock.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/post-unlock.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# POST-UNLOCK HOOK
+#
+# The post-unlock hook runs after a path is unlocked. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-unlock' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the user who destroyed the lock)
+#
+# The paths that were just unlocked are passed to the hook via STDIN
+# (as of Subversion 1.2, only one path is passed per invocation, but
+# the plan is to pass all unlocked paths at once, so the hook program
+# should be written accordingly).
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the lock has already been destroyed and cannot be undone,
+# the exit code of the hook program is ignored.
+#
+# On a Unix system, the normal procedure is to have 'post-unlock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-unlock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-unlock.bat' or 'post-unlock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+USER="$2"
+
+# Send email to interested parties, let them know a lock was removed:
+mailer.py unlock "$REPOS" "$USER" /path/to/mailer.conf
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-commit.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-commit.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-commit.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# PRE-COMMIT HOOK
+#
+# The pre-commit hook is invoked before a Subversion txn is
+# committed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-commit' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] TXN-NAME (the name of the txn about to be committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the txn is committed; but
+# if it exits with failure (non-zero), the txn is aborted, no commit
+# takes place, and STDERR is returned to the client. The hook
+# program can use the 'svnlook' utility to help it examine the txn.
+#
+# On a Unix system, the normal procedure is to have 'pre-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
+# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
+#
+# This is why we recommend using the read-only 'svnlook' utility.
+# In the future, Subversion may enforce the rule that pre-commit
+# hooks should not modify the versioned data in txns, or else come
+# up with a mechanism to make it safe to do so (by informing the
+# committing client of the changes). However, right now neither
+# mechanism is implemented, so hook writers just have to be careful.
+#
+# Note that 'pre-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-commit.bat' or 'pre-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+TXN="$2"
+
+# Make sure that the log message contains some text.
+SVNLOOK=/usr/local/bin/svnlook
+$SVNLOOK log -t "$TXN" "$REPOS" | \
+ grep "[a-zA-Z0-9]" > /dev/null || exit 1
+
+# Check that the author of this commit has the rights to perform
+# the commit on the files and directories being modified.
+commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
+
+# All checks passed, so allow the commit.
+exit 0
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-lock.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-lock.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-lock.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# PRE-LOCK HOOK
+#
+# The pre-lock hook is invoked before an exclusive lock is
+# created. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-lock' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] PATH (the path in the repository about to be locked)
+# [3] USER (the user creating the lock)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the lock is created; but
+# if it exits with failure (non-zero), the lock action is aborted
+# and STDERR is returned to the client.
+
+# On a Unix system, the normal procedure is to have 'pre-lock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-lock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-lock.bat' or 'pre-lock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+PATH="$2"
+USER="$3"
+
+# If a lock exists and is owned by a different person, don't allow it
+# to be stolen (e.g., with 'svn lock --force ...').
+
+# (Maybe this script could send email to the lock owner?)
+SVNLOOK=/usr/local/bin/svnlook
+GREP=/bin/grep
+SED=/bin/sed
+
+LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
+ $GREP '^Owner: ' | $SED 's/Owner: //'`
+
+# If we get no result from svnlook, there's no lock, allow the lock to
+# happen:
+if [ "$LOCK_OWNER" = "" ]; then
+ exit 0
+fi
+
+# If the person locking matches the lock's owner, allow the lock to
+# happen:
+if [ "$LOCK_OWNER" = "$USER" ]; then
+ exit 0
+fi
+
+# Otherwise, we've got an owner mismatch, so return failure:
+echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2
+exit 1
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-revprop-change.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-revprop-change.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-revprop-change.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# PRE-REVPROP-CHANGE HOOK
+#
+# The pre-revprop-change hook is invoked before a revision property
+# is added, modified or deleted. Subversion runs this hook by invoking
+# a program (script, executable, binary, etc.) named 'pre-revprop-change'
+# (for which this file is a template), with the following ordered
+# arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REVISION (the revision being tweaked)
+# [3] USER (the username of the person tweaking the property)
+# [4] PROPNAME (the property being set on the revision)
+# [5] ACTION (the property is being 'A'dded, 'M'odified, or 'D'eleted)
+#
+# [STDIN] PROPVAL ** the new property value is passed via STDIN.
+#
+# If the hook program exits with success, the propchange happens; but
+# if it exits with failure (non-zero), the propchange doesn't happen.
+# The hook program can use the 'svnlook' utility to examine the
+# existing value of the revision property.
+#
+# WARNING: unlike other hooks, this hook MUST exist for revision
+# properties to be changed. If the hook does not exist, Subversion
+# will behave as if the hook were present, but failed. The reason
+# for this is that revision properties are UNVERSIONED, meaning that
+# a successful propchange is destructive; the old value is gone
+# forever. We recommend the hook back up the old value somewhere.
+#
+# On a Unix system, the normal procedure is to have 'pre-revprop-change'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-revprop-change' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-revprop-change.bat' or 'pre-revprop-change.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+ACTION="$5"
+
+if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
+
+echo "Changing revision properties other than svn:log is prohibited" >&2
+exit 1
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-unlock.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-unlock.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/pre-unlock.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# PRE-UNLOCK HOOK
+#
+# The pre-unlock hook is invoked before an exclusive lock is
+# destroyed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-unlock' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] PATH (the path in the repository about to be unlocked)
+# [3] USER (the user destroying the lock)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the lock is destroyed; but
+# if it exits with failure (non-zero), the unlock action is aborted
+# and STDERR is returned to the client.
+
+# On a Unix system, the normal procedure is to have 'pre-unlock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-unlock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-unlock.bat' or 'pre-unlock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+PATH="$2"
+USER="$3"
+
+# If a lock is owned by a different person, don't allow it be broken.
+# (Maybe this script could send email to the lock owner?)
+
+SVNLOOK=/usr/local/bin/svnlook
+GREP=/bin/grep
+SED=/bin/sed
+
+LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
+ $GREP '^Owner: ' | $SED 's/Owner: //'`
+
+# If we get no result from svnlook, there's no lock, return success:
+if [ "$LOCK_OWNER" = "" ]; then
+ exit 0
+fi
+# If the person unlocking matches the lock's owner, return success:
+if [ "$LOCK_OWNER" = "$USER" ]; then
+ exit 0
+fi
+
+# Otherwise, we've got an owner mismatch, so return failure:
+echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2
+exit 1
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/start-commit.tmpl
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/start-commit.tmpl 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/hooks/start-commit.tmpl 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# START-COMMIT HOOK
+#
+# The start-commit hook is invoked before a Subversion txn is created
+# in the process of doing a commit. Subversion runs this hook
+# by invoking a program (script, executable, binary, etc.) named
+# 'start-commit' (for which this file is a template)
+# with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the authenticated user attempting to commit)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the commit continues; but
+# if it exits with failure (non-zero), the commit is stopped before
+# a Subversion txn is created, and STDERR is returned to the client.
+#
+# On a Unix system, the normal procedure is to have 'start-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'start-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'start-commit.bat' or 'start-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+USER="$2"
+
+commit-allower.pl --repository "$REPOS" --user "$USER" || exit 1
+special-auth-check.py --user "$USER" --auth-level 3 || exit 1
+
+# All checks passed, so allow the commit.
+exit 0
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db-logs.lock
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db-logs.lock 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db-logs.lock 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,3 @@
+This file is not used by Subversion 1.3.x or later.
+However, its existence is required for compatibility with
+Subversion 1.2.x or earlier.
Added: labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db.lock
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db.lock 2006-11-17 22:06:00 UTC (rev 7700)
+++ labs/jbossrules/trunk/drools-repository/src/test/resources/svn_repo/locks/db.lock 2006-11-18 11:23:01 UTC (rev 7701)
@@ -0,0 +1,3 @@
+This file is not used by Subversion 1.3.x or later.
+However, its existence is required for compatibility with
+Subversion 1.2.x or earlier.
More information about the jboss-svn-commits
mailing list