incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From okiess...@apache.org
Subject svn commit: r191347 - in /incubator/graffito/trunk/jcr-mapping: ./ repotest/ src/conf/ src/java/org/apache/portals/graffito/jcr/exception/ src/java/org/apache/portals/graffito/jcr/repository/ src/java/org/apache/portals/graffito/jcr/session/ src/java/o...
Date Sun, 19 Jun 2005 14:52:52 GMT
Author: okiessler
Date: Sun Jun 19 07:52:50 2005
New Revision: 191347

URL: http://svn.apache.org/viewcvs?rev=191347&view=rev
Log:
Issues: GRFT-20, GRFT-21

Some testcases were modified during missing custom node type support, so that's still a todo (GRFT-23). I have introduced a TestAll class to force a testcase execution order to have the repository setup run first because the rest of the testcases depend on it.


Added:
    incubator/graffito/trunk/jcr-mapping/locator.ent   (with props)
    incubator/graffito/trunk/jcr-mapping/locator.path
    incubator/graffito/trunk/jcr-mapping/src/conf/repository.xml   (with props)
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java   (with props)
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/CustomNodeTypeCreator.java   (with props)
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/CustomNodeTypeCreatorImpl.java   (with props)
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestAll.java   (with props)
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java   (with props)
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java
      - copied, changed from r191180, incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/TestRepositoryUtil.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionSetupTest.java   (with props)
Removed:
    incubator/graffito/trunk/jcr-mapping/repotest/
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/TestRepositoryUtil.java
Modified:
    incubator/graffito/trunk/jcr-mapping/project.properties
    incubator/graffito/trunk/jcr-mapping/project.xml
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/JcrSession.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/JcrSessionImpl.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionTest.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/DocumentConverter.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/FolderConverter.java

Added: incubator/graffito/trunk/jcr-mapping/locator.ent
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/locator.ent?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/locator.ent (added)
+++ incubator/graffito/trunk/jcr-mapping/locator.ent Sun Jun 19 07:52:50 2005
@@ -0,0 +1,2 @@
+<!-- derive locator.ent from parent -->
+<!ENTITY % locator-ent SYSTEM "file:../locator.ent"> %locator-ent;

Propchange: incubator/graffito/trunk/jcr-mapping/locator.ent
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/graffito/trunk/jcr-mapping/locator.path
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/locator.path?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/locator.path (added)
+++ incubator/graffito/trunk/jcr-mapping/locator.path Sun Jun 19 07:52:50 2005
@@ -0,0 +1 @@
+../
\ No newline at end of file

Modified: incubator/graffito/trunk/jcr-mapping/project.properties
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/project.properties?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/project.properties (original)
+++ incubator/graffito/trunk/jcr-mapping/project.properties Sun Jun 19 07:52:50 2005
@@ -37,6 +37,6 @@
 # COMPILE 
 #-----------------------------------------------------------------------------------------------------
 maven.compile.deprecation=on
-
-
-
+#maven.compile.source=1.4
+#maven.compile.target=1.4
+#maven.test.source=1.4

Modified: incubator/graffito/trunk/jcr-mapping/project.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/project.xml?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/project.xml (original)
+++ incubator/graffito/trunk/jcr-mapping/project.xml Sun Jun 19 07:52:50 2005
@@ -28,13 +28,12 @@
   </description>
   <shortDescription>Graffito JCR Mapping Tools</shortDescription>
 
-  <repository>
-    <connection>scm:subversion:https://svn.apache.org/repos/asf/incubator/graffito/trunk/jcr-mapping</connection>
-    <developerConnection>scm:subversion:https://svn.apache.org/repos/asf/incubator/graffito/trunk/jcr-mapping</developerConnection>
-    <url>http://svn.apache.org/viewcvs</url>
-  </repository>
+  <repository>
+    <connection>scm:subversion:https://svn.apache.org/repos/asf/incubator/graffito/trunk/jcr-mapping</connection>
+    <developerConnection>scm:subversion:https://svn.apache.org/repos/asf/incubator/graffito/trunk/jcr-mapping</developerConnection>
+    <url>http://svn.apache.org/viewcvs</url>
+  </repository>
 
-  
   <dependencies> 
 
     <dependency>  
@@ -45,71 +44,62 @@
     <dependency>
       <groupId>jackrabbit</groupId>
       <artifactId>jackrabbit</artifactId>
-      <version>0.16.2-dev</version>
-      <properties><war.bundle>true</war.bundle></properties>
+      <version>0.16.4.1-dev</version>
     </dependency>	 
-    <dependency>
-      <id>concurrent</id>
-      <version>1.3.4</version>
-    </dependency>
-    <dependency>
-      <id>junit</id>
-      <version>3.8.1</version>
-    </dependency>
-    <dependency>
-      <id>commons-collections</id>
-      <version>2.1</version>
-    </dependency>
-    <dependency>
-      <id>jdom</id>
-      <version>1.0</version>
-    </dependency>
-    <dependency>
-      <id>javacc</id>
-      <version>3.2</version>
-    </dependency>
-    <dependency>
-      <groupId>geronimo-spec</groupId>
-      <artifactId>geronimo-spec-jta</artifactId>
-      <version>1.0-M1</version>
-    </dependency>
-    <dependency>
-      <groupId>jsr170</groupId>
-      <artifactId>jcr</artifactId>
-      <version>0.16.2</version>
-      <url>http://www.day.com/maven/jsr170/jars/jcr-0.16.2.jar</url>
-    </dependency>
-    <dependency>
-      <id>log4j</id>
-      <version>1.2.8</version>
-    </dependency>
-    <dependency>
-      <groupId>lucene</groupId>
-      <artifactId>lucene</artifactId>
-      <version>1.4.3</version>
-    </dependency>
-    <dependency>
-      <groupId>xerces</groupId>
-      <artifactId>xercesImpl</artifactId>
-      <version>2.6.2</version>
-    </dependency>
-    <!--
-      cqfs-jackrabbit and cqfs are optional runtime dependencies 
-      (an alternative FileSystem implementation); 
-      commons-logging is a dependency of cqfs
-    -->
-    <dependency>
-      <groupId>cqfs</groupId>
-      <artifactId>cqfs-jackrabbit</artifactId>
-      <version>3.5.6</version>
-      <url>http://www.day.com/maven/cqfs/jars/cqfs-jackrabbit-3.5.6.jar</url>
-    </dependency>
-    <dependency>
-      <groupId>cqfs</groupId>
-      <artifactId>cqfs</artifactId>
-      <version>3.5.6</version>
-      <url>http://www.day.com/maven/cqfs/jars/cqfs-3.5.6.jar</url>
-    </dependency>
+    <dependency>
+      <id>concurrent</id>
+      <version>1.3.4</version>
+    </dependency>
+    <dependency>
+      <id>junit</id>
+      <version>3.8.1</version>
+    </dependency>
+    <dependency>
+      <id>commons-collections</id>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>geronimo-spec</groupId>
+      <artifactId>geronimo-spec-jta</artifactId>
+      <version>1.0-M1</version>
+    </dependency>
+    <dependency>
+      <groupId>jsr170</groupId>
+      <artifactId>jcr</artifactId>
+      <version>0.16.4.1</version>
+      <url>http://www.day.com/maven/jsr170/jars/jcr-0.16.4.1.jar</url>
+    </dependency>
+    <dependency>
+      <id>log4j</id>
+      <version>1.2.8</version>
+    </dependency>
+    <dependency>
+      <groupId>lucene</groupId>
+      <artifactId>lucene</artifactId>
+      <version>1.4.3</version>
+    </dependency>
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+      <version>2.6.2</version>
+    </dependency>
+    <!--
+      cqfs-jackrabbit and cqfs are optional runtime dependencies 
+      (an alternative FileSystem implementation); 
+      commons-logging is a dependency of cqfs
+    -->
+    <dependency>
+      <groupId>cqfs</groupId>
+      <artifactId>cqfs-jackrabbit</artifactId>
+      <version>3.5.6</version>
+      <url>http://www.day.com/maven/cqfs/jars/cqfs-jackrabbit-3.5.6.jar</url>
+    </dependency>
+    <dependency>
+      <groupId>cqfs</groupId>
+      <artifactId>cqfs</artifactId>
+      <version>3.5.6</version>
+      <url>http://www.day.com/maven/cqfs/jars/cqfs-3.5.6.jar</url>
+    </dependency>
 
     <dependency>
       <id>commons-logging</id>
@@ -147,16 +137,14 @@
     </dependency>   
   </dependencies>  
   
-  
   <build>
     <sourceDirectory>src/java</sourceDirectory>
 
     <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
     <unitTest>
-	  <excludes>
-		<exclude>org/apache/portals/graffito/jcr/testmodel/*.java</exclude>
-		<exclude>org/apache/portals/graffito/jcr/testconverter/*.java</exclude>
-	  </excludes>	
+          <includes>
+            <include>**/*TestAll.java</include>       
+          </includes>
       <resources>
         <resource>
           <directory>${basedir}/src/test</directory>

Added: incubator/graffito/trunk/jcr-mapping/src/conf/repository.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/conf/repository.xml?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/conf/repository.xml (added)
+++ incubator/graffito/trunk/jcr-mapping/src/conf/repository.xml Sun Jun 19 07:52:50 2005
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!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 SearchIndex element that is used for configuring per workspace
+            Indexing-related settings
+
+            a Versioning element that is used for configuring
+            versioning-related settings
+    -->
+    <!ELEMENT Repository (FileSystem,Security,Workspaces,Workspace,Versioning)>
+
+    <!--
+        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"/>
+        </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="com.day.jackrabbit.fs.cq.CQFileSystem">
+            <param name="path" value="${wsp.home}/wspStore.dat"/>
+            <param name="autoRepair" value="false"/>
+            <param name="blockSize" value="128"/>
+            <param name="autoSync" value="false"/>
+        </FileSystem>
+        -->
+
+        <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.xml.XMLPersistenceManager"/>
+        
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="useCompoundFile" value="true"/>
+            <param name="minMergeDocs" value="1000"/>
+            <param name="maxMergeDocs" value="100000"/>
+            <param name="mergeFactor" value="10"/>
+            <param name="bufferSize" value="10"/>
+
+            <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+                <param name="path" value="${wsp.home}/index"/>
+            </FileSystem>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <!--
+            Configures the filesystem to use for versioning for the respective
+            persistence manager
+        
+        <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+            <param name="path" value="${rep.home}/version/version.dat"/>
+            <param name="autoRepair" value="false"/>
+            <param name="blockSize" value="128"/>
+            <param name="autoSync" value="false"/>
+        </FileSystem>
+         -->
+        
+            <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+                <param name="path" value="${rep.home}/version"/>
+            </FileSystem>
+        
+        <!--
+            Configures the perisistence 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.obj.ObjectPersistenceManager"/>
+
+    </Versioning>
+</Repository>

Propchange: incubator/graffito/trunk/jcr-mapping/src/conf/repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java Sun Jun 19 07:52:50 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.jcr.exception;
+
+/** This exception is thrown during repository setup while creating the
+ * custom graffito node types.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ * @version $Id: Exp $
+ */
+public class CustomNodeTypeCreationException extends Exception {
+    
+    /**
+     * Default Constructor without information.
+     */
+    public CustomNodeTypeCreationException() 
+    {
+        super();
+    }
+    
+    /**
+     * Constructor with message.
+     * 
+     * @param message the message associated to the exception
+     */
+    public CustomNodeTypeCreationException(String message) 
+    {
+        super(message);
+    }
+    
+    /**
+     * Constructor with throwable object.
+     * 
+     * @param nested the associated throwable object
+     */    
+    public CustomNodeTypeCreationException(Throwable nested)
+    {
+        super(nested);
+    }
+    
+    /**
+     * Constructor with message and throwable object.
+     * 
+     * @param message the message associated to the exception
+     * @param nested the associated throwable object
+     */    
+    public CustomNodeTypeCreationException(String message, Throwable nested)
+    {
+        super(message, nested);
+    }
+}

Propchange: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java Sun Jun 19 07:52:50 2005
@@ -26,10 +26,8 @@
 import org.apache.jackrabbit.core.jndi.RegistryHelper;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
 
-
-
 /**
-* Utility class for managing JCR repositories
+* Utility class for managing JCR repositories.
 *
 * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
 * @version $Id: Exp $
@@ -64,7 +62,6 @@
         {
             throw new JcrMappingException("Impossible to register the respository : " + 
                                            repositoryName + " - config file : " + configFile, e);
-
         }        
         
     }
@@ -96,9 +93,6 @@
         }        
     }
     
-    
-
-    
     /**
      * Connect to a JCR repository
      * 
@@ -154,7 +148,7 @@
     {
         String parentPath = "";
         
-        if (! isValidPath(path))
+        if (!isValidPath(path))
         {
             throw new JcrMappingException("Invalid path : " + path);
         }

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/CustomNodeTypeCreator.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/CustomNodeTypeCreator.java?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/CustomNodeTypeCreator.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/CustomNodeTypeCreator.java Sun Jun 19 07:52:50 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.jcr.session;
+
+import org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException;
+
+/** Interface for custom node type creator implementations.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ * @version $Id: Exp $
+ */
+public interface CustomNodeTypeCreator {
+
+    /** This method is supposed to create custom node types on repository
+     * setup.
+     * 
+     * @throws org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException 
+     * @return true/false True if custom node type creation succeeded 
+     */
+    boolean createInitialJcrCustomNodeTypes() throws CustomNodeTypeCreationException;
+
+    /** Method to add a jcr custom node type to an existing jcr repository.
+     * 
+     * @throws org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException 
+     * @return true/false True if custom node type creation succeeded
+     */
+    boolean addJcrCustomNodeType() throws CustomNodeTypeCreationException;
+    
+    /** Jcr session to be injected into implementation.
+     * @param jcrSession JcrSession
+     */
+    void setJcrSession(JcrSession jcrSession);
+}

Propchange: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/CustomNodeTypeCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/JcrSession.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/JcrSession.java?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/JcrSession.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/JcrSession.java Sun Jun 19 07:52:50 2005
@@ -20,31 +20,75 @@
 
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
 
-
-/**
- *
- * Jcr Broker
+/** Interface that specifies howto interact with a jcr repository (JCR broker).
  * 
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe</a>
  * @version $Id: Exp $
  */
 public interface JcrSession
 {
-
+    /** This methods created the graffito namespaces and custom node types
+     *  required for running a graffito managed jcr repository.
+     *  
+     * @throws org.apache.portals.graffito.jcr.exception.JcrMappingException JcrMappingException 
+     */
+    public void setupRepository() throws JcrMappingException;
+    
+    /**
+     * 
+     * @return 
+     */
     public Repository getRepository();
     
+    /**
+     * 
+     * @return 
+     */
     public Session getSession();
     
+    /**
+     * 
+     * @return 
+     */
     public String getUser();    
     
-    public boolean itemExists(String path);
-    
+    /**
+     * 
+     * @param path 
+     * @throws org.apache.portals.graffito.jcr.exception.JcrMappingException 
+     * @return 
+     */
+    public boolean itemExists(String path) throws JcrMappingException;
+    
+    /**
+     * 
+     * @param path 
+     * @param object 
+     * @throws org.apache.portals.graffito.jcr.exception.JcrMappingException 
+     */
     public void insert(String path, Object object) throws JcrMappingException;
     
+    /**
+     * 
+     * @param path 
+     * @param object 
+     * @throws org.apache.portals.graffito.jcr.exception.JcrMappingException 
+     */
     public void update(String path, Object object) throws JcrMappingException;
     
+    /**
+     * 
+     * @param pojoClass 
+     * @param path 
+     * @throws org.apache.portals.graffito.jcr.exception.JcrMappingException 
+     * @return 
+     */
     public Object getObject(Class pojoClass, String path) throws JcrMappingException;
     
-    public void remove(String path) throws JcrMappingException;
-    
+    /**
+     * 
+     * @param path 
+     * @throws org.apache.portals.graffito.jcr.exception.JcrMappingException 
+     */
+    public void remove(String path) throws JcrMappingException;    
 }

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/CustomNodeTypeCreatorImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/CustomNodeTypeCreatorImpl.java?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/CustomNodeTypeCreatorImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/CustomNodeTypeCreatorImpl.java Sun Jun 19 07:52:50 2005
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.jcr.session.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException;
+import org.apache.portals.graffito.jcr.session.CustomNodeTypeCreator;
+import org.apache.portals.graffito.jcr.session.JcrSession;
+
+/** Default implementation of the jackrabbit custom node creator.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ * @version $Id: Exp $
+ */
+public class CustomNodeTypeCreatorImpl implements CustomNodeTypeCreator {
+    
+    /** Logger.
+     */
+    private final static Log log = LogFactory.getLog(CustomNodeTypeCreatorImpl.class); 
+    
+    /** Session to the jcr repository.
+     */
+    private JcrSession jcrSession;
+    
+    /** Creates a new instance of CustomNodeTypeCreatorImpl. */
+    public CustomNodeTypeCreatorImpl()
+    {
+    }
+    
+    /** Creates a new instance of CustomNodeTypeCreatorImpl with a jcr session. 
+     * @param jcrSession JcrSession
+     */
+    public CustomNodeTypeCreatorImpl(JcrSession jcrSession)
+    {
+        this.jcrSession = jcrSession;
+    }
+
+    /** This method is supposed to create custom node types on repository
+     * setup.
+     * 
+     * @throws org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException 
+     * @return true/false
+     */
+    public boolean createInitialJcrCustomNodeTypes() throws CustomNodeTypeCreationException
+    {
+       
+        // TODO
+        
+        return true;
+    }
+
+    /** Method to add a jcr custom node type to an existing jcr repository.
+     * 
+     * @throws org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException 
+     * @return true/false
+     */
+    public boolean addJcrCustomNodeType() throws CustomNodeTypeCreationException
+    {
+        
+        // TODO
+        
+        return false;
+    }
+    
+    /** Setter for property jcrSession.
+     * 
+     * @param jcrSession JcrSession
+     */
+    public void setJcrSession(JcrSession jcrSession)
+    {
+        this.jcrSession = jcrSession;
+    }
+
+    /** Getter for property jcrSession.
+     * 
+     * @return jcrSession
+     */
+    public JcrSession getJcrSession()
+    {
+        return jcrSession;
+    }
+}

Propchange: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/CustomNodeTypeCreatorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/JcrSessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/JcrSessionImpl.java?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/JcrSessionImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/session/impl/JcrSessionImpl.java Sun Jun 19 07:52:50 2005
@@ -18,42 +18,115 @@
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.portals.graffito.jcr.converter.Converter;
 import org.apache.portals.graffito.jcr.converter.ConverterManager;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.session.CustomNodeTypeCreator;
 import org.apache.portals.graffito.jcr.session.JcrSession;
 
-
 /**
  * Default implementation for {@link org.apache.portals.graffito.jcr.session.JcrSession} 
  *
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe</a>
  * 
  * @version $Id: Exp $
  */
 public class JcrSessionImpl implements JcrSession
 {
+    /** Logger.
+     */
+    private final static Log log = LogFactory.getLog(JcrSessionImpl.class);    
+    
+    /** Converter manager needed for graffito managed content objects.
+     */
     private ConverterManager converterManager;
+    
+    /** Jackrabbit jcr repository.
+     */
     private Repository repository;
-    private Session session; 
     
+    /** Jackrabbit jcr session.
+     */
+    private Session session;
+
+    /** Custom node type creator dependency needed during repository setup.
+     */
+    private CustomNodeTypeCreator jcrCustomNodeTypeCreator;
+
+    /** Graffito namespace prefix constant.
+     */
+    private static final String GRAFFITO_NAMESPACE_PREFIX   = "graffito";
+
+    /** Graffito namespace constant.
+     */
+    private static final String GRAFFITO_NAMESPACE          = "http://incubator.apache.org/graffito";
+
     /**
-     * Contructor 
+     * Contructor for setting up a session to interact with a jcr repository. 
      * 
      * @param converterManager The converter manager
      * @param repository The Repository
      * @param session The JCR Session
-     * 
+     * @param jcrCustomNodeTypeCreator Custom node type creator
      */
-    public JcrSessionImpl(ConverterManager converterManager, Repository repository, Session session)
+    public JcrSessionImpl(ConverterManager converterManager, Repository repository,
+            Session session, CustomNodeTypeCreator jcrCustomNodeTypeCreator)
     {
         this.converterManager = converterManager;
         this.repository = repository;
-        this.session = session;       
+        this.session = session;
+        this.jcrCustomNodeTypeCreator = jcrCustomNodeTypeCreator;
     }
     
+   /** This methods created the graffito namespaces and custom node types
+    *  required for running a graffito managed jcr repository.
+    *  
+    * @see org.apache.portals.graffito.jcr.session.JcrSession#setupRepository()
+    * @throws JcrMappingException JcrMappingException
+    */
+    public void setupRepository() throws JcrMappingException
+    {
+         try
+         {
+            String[] jcrNamespaces = getSession().getWorkspace().getNamespaceRegistry().getPrefixes();
+            boolean createGraffitoNamespace = true;
+            for (int i = 0; i < jcrNamespaces.length; i++)
+            {
+                if (jcrNamespaces[i].equals(GRAFFITO_NAMESPACE_PREFIX))
+                {
+                    createGraffitoNamespace = false;
+                    log.debug("Graffito namespace exists.");
+                }
+            }
+             
+            if (createGraffitoNamespace)
+            {
+                getSession().getWorkspace().getNamespaceRegistry().registerNamespace(GRAFFITO_NAMESPACE_PREFIX, GRAFFITO_NAMESPACE);
+                log.info("Successfully created graffito namespace.");
+            }
+            
+            if (getSession().getRootNode() != null)
+            {
+                log.info("Jcr repository setup successfull.");
+            }
+            
+            if (getJcrCustomNodeTypeCreator().createInitialJcrCustomNodeTypes())
+            {
+                log.info("Jcr custom node type creation successful.");
+            }
+        }
+        catch (Exception e)
+        {
+            log.error("Error while setting up the jcr repository.", e);
+            throw new JcrMappingException(e.getMessage());
+        }
+    }
     
     /**
      * 
@@ -79,24 +152,29 @@
      */
     public String getUser()
     {
-        return this.session.getUserId();
+        return getSession().getUserID();
     }
     
-
     /**
      * 
      * @see org.apache.portals.graffito.jcr.session.JcrSession#getObject(java.lang.Class, java.lang.String)
      */
     public Object getObject(Class pojoClass, String path) throws JcrMappingException
-    {
-        if (! session.itemExists(path))
+    {   
+        try
         {
-            return null;
+            if (!session.itemExists(path))
+            {
+                return null;
+            }
+        }
+        catch (RepositoryException re)
+        {
+            throw new JcrMappingException(re.getMessage());
         }
         
         Converter converter = converterManager.getConverter(pojoClass);
         return converter.getObject(session, path);
-        
     }
     
     /**
@@ -105,9 +183,16 @@
      */
     public void insert(String path, Object object)  throws JcrMappingException
     {
-        if (session.itemExists(path))
+        try
+        {
+            if (session.itemExists(path))
+            {
+                throw new JcrMappingException("Path already exists : " + path);
+            }
+        }
+        catch (RepositoryException re)
         {
-            throw new JcrMappingException("Path already exists : " + path);
+            throw new JcrMappingException(re.getMessage());
         }
         
         Converter converter = converterManager.getConverter(object.getClass());
@@ -120,16 +205,22 @@
      */
     public void update(String path, Object object)  throws JcrMappingException
     {
-        if (! session.itemExists(path))
+        try
         {
-            throw new JcrMappingException("Path already exists : " + path);
+            if (! session.itemExists(path))
+            {
+                throw new JcrMappingException("Path already exists : " + path);
+            }
+        }
+        catch (RepositoryException re)
+        {
+            throw new JcrMappingException(re.getMessage());
         }
         
         Converter converter = converterManager.getConverter(object.getClass());
         converter.update(session, path, object);
     }
-    
-    
+        
     /**
      * 
      * @see org.apache.portals.graffito.jcr.session.JcrSession#remove(java.lang.String)
@@ -144,9 +235,9 @@
             item.remove();
             parent.save();
         }
-        catch (Exception e)
-        {         
-            e.printStackTrace();
+        catch (RepositoryException re)
+        {
+            throw new JcrMappingException(re.getMessage());
         }
     }
     
@@ -154,8 +245,33 @@
      * 
      * @see org.apache.portals.graffito.jcr.session.JcrSession#itemExists(java.lang.String)
      */
-    public boolean itemExists(String path)
+    public boolean itemExists(String path) throws JcrMappingException
+    {
+        try
+        {
+            return session.itemExists(path);
+        }
+        catch (RepositoryException re)
+        {
+            throw new JcrMappingException(re.getMessage());
+        }
+    }
+
+    /** Getter for property jcrCustomNodeTypeCreator.
+     * 
+     * @return jcrCustomNodeTypeCreator
+     */
+    public CustomNodeTypeCreator getJcrCustomNodeTypeCreator()
+    {
+        return jcrCustomNodeTypeCreator;
+    }
+
+    /** Setter for property jcrCustomNodeTypeCreator.
+     * 
+     * @param object CustomNodeTypeCreator
+     */
+    public void setJcrCustomNodeTypeCreator(CustomNodeTypeCreator object)
     {
-        return session.itemExists(path);
+        this.jcrCustomNodeTypeCreator = object;
     }
 }

Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestAll.java?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestAll.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestAll.java Sun Jun 19 07:52:50 2005
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================================
+ */
+package org.apache.portals.graffito.jcr;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.portals.graffito.jcr.converter.impl.ConverterManagerTest;
+import org.apache.portals.graffito.jcr.repository.RepositoryUtilTest;
+import org.apache.portals.graffito.jcr.session.impl.JcrSessionTest;
+import org.apache.portals.graffito.jcr.session.impl.JcrSessionSetupTest;
+
+/** Test all suite to control the order of testcases.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ * @version $Id: Exp $
+ */
+public class TestAll extends TestCase {
+
+    /** Runs test suite.
+     * 
+     * @return suite
+     */
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite("graffito jcr-mapping tests");
+        suite.addTestSuite(JcrSessionSetupTest.class);
+        suite.addTestSuite(JcrSessionTest.class);
+        suite.addTestSuite(ConverterManagerTest.class);
+        suite.addTestSuite(RepositoryUtilTest.class);
+        return suite;
+    }
+}

Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java Sun Jun 19 07:52:50 2005
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================================
+ */
+package org.apache.portals.graffito.jcr;
+
+import junit.framework.TestCase;
+
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+import org.apache.portals.graffito.jcr.converter.ConverterManager;
+import org.apache.portals.graffito.jcr.converter.impl.ConverterManagerImpl;
+import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
+import org.apache.portals.graffito.jcr.session.CustomNodeTypeCreator;
+import org.apache.portals.graffito.jcr.session.JcrSession;
+import org.apache.portals.graffito.jcr.session.impl.CustomNodeTypeCreatorImpl;
+import org.apache.portals.graffito.jcr.session.impl.JcrSessionImpl;
+
+/** Base class for testcases. Provides priviledged access to the jcr test
+ * repository.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ * @version $Id: Exp $
+ */
+public abstract class TestBase extends TestCase
+{
+    /** Jcr session to work with.
+     */
+    private JcrSession jcrSession;
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public TestBase(String testName)
+    {
+        super(testName);
+    }    
+
+    /** Setting up the testcase.
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        /* Reads the object converters from an xml configuration file. This
+        file contains the mapping for object converter classes. */
+        ConverterManager converterManager = new ConverterManagerImpl("src/conf/convertertest/converters.xml");
+        
+        RepositoryUtil.registerRepository("repositoryTest", "src/conf/repository.xml", "target/repository");
+        Repository repository = RepositoryUtil.getRepository("repositoryTest");
+        // optaining a read/write session to the repository
+        Session session = RepositoryUtil.login(repository, "superuser", "superuser");
+        CustomNodeTypeCreator customNodeTypeCreator = new CustomNodeTypeCreatorImpl();
+        setJcrSession(new JcrSessionImpl(converterManager, repository, session, customNodeTypeCreator));
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        getJcrSession().getSession().save();
+        getJcrSession().getSession().logout();
+    }    
+
+    /** Getter for property jcrSession.
+     * @return jcrSession
+     */
+    public JcrSession getJcrSession()
+    {
+        return jcrSession;
+    }
+
+    /** Setter for property jcrSession.
+     * @param jcrSession Jcr Repository session 
+     */
+    public void setJcrSession(JcrSession jcrSession)
+    {
+        this.jcrSession = jcrSession;
+    }
+}
\ No newline at end of file

Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java (from r191180, incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/TestRepositoryUtil.java)
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java?p2=incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java&p1=incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/TestRepositoryUtil.java&r1=191180&r2=191347&rev=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/TestRepositoryUtil.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java Sun Jun 19 07:52:50 2005
@@ -29,20 +29,19 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-/**
- * Test RepositoryUtil
- *
+/** Testcase for RepositoryUtil.
+ * 
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
  */
-public class TestRepositoryUtil extends TestCase
+public class RepositoryUtilTest extends TestCase
 {
-    private final static Log log = LogFactory.getLog(TestRepositoryUtil.class);
+    private final static Log log = LogFactory.getLog(RepositoryUtilTest.class);
 
     /**
      * <p>Defines the test case name for junit.</p>
      * @param testName The test case name.
      */
-    public TestRepositoryUtil(String testName)
+    public RepositoryUtilTest(String testName)
     {
         super(testName);
     }
@@ -53,8 +52,7 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        RepositoryUtil.registerRepository("repositoryTest", "repotest/repository.xml", "repotest");
-
+        RepositoryUtil.registerRepository("repositoryTest", "src/conf/repository.xml", "target/repository");
     }
 
     /**
@@ -63,13 +61,12 @@
     public void tearDown() throws Exception
     {
         super.tearDown();
-
     }
 
     public static Test suite()
     {
         // All methods starting with "test" will be executed in the test suite.
-        return new TestSuite(TestRepositoryUtil.class);
+        return new TestSuite(RepositoryUtilTest.class);
     }
 
     /**
@@ -82,10 +79,10 @@
         {
             Repository repository = RepositoryUtil.getRepository("repositoryTest");
             assertNotNull("The repository is null", repository);
-            Session session = RepositoryUtil.login(repository, "anonymous", "");
+            Session session = RepositoryUtil.login(repository, "superuser", "superuser");
             Node root = session.getRootNode();
             assertNotNull("Root node is null", root);
-
+            session.logout();
         }
         catch (Exception e)
         {
@@ -104,19 +101,21 @@
         try
         {
             Repository repository = RepositoryUtil.getRepository("repositoryTest");           
-            Session session = RepositoryUtil.login(repository, "anonymous", "");
+            Session session = RepositoryUtil.login(repository, "superuser", "superuser");
             NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
-            NodeType nodeType = nodeTypeManager.getNodeType("graffito:folder");
-            assertNotNull("Root node is null", nodeType);
-
+            
+            // TODO custom node types not implemented yet
+            
+            //NodeType nodeType = nodeTypeManager.getNodeType("graffito:folder");
+            //assertNotNull("Root node is null", nodeType);
+            
+            session.logout();
         }
         catch (Exception e)
         {
             e.printStackTrace();
             fail("Unable to find the repository : " + e);
         }
-
-        
     }
 
     /**
@@ -131,7 +130,6 @@
             assertNotNull("parent path is null for /test", parentPath);
             assertTrue("parent path is incorrect for /test", parentPath.equals("/"));
 
-            
             parentPath = RepositoryUtil.getParentPath("/test/test2");
             assertNotNull("parent path is null for /test/test2", parentPath);
             assertTrue("parent path is incorrect for /test/test2", parentPath.equals("/test"));
@@ -142,7 +140,6 @@
             e.printStackTrace();
             fail("Unable to find the repository : " + e);
         }
-
     }
     
     /**
@@ -167,6 +164,5 @@
             e.printStackTrace();
             fail("Unable to find the repository : " + e);
         }
-
     }    
 }

Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionSetupTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionSetupTest.java?rev=191347&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionSetupTest.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionSetupTest.java Sun Jun 19 07:52:50 2005
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================================
+ */
+package org.apache.portals.graffito.jcr.session.impl;
+
+import javax.jcr.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.portals.graffito.jcr.TestBase;
+
+/**
+ * Test JcrSession Setup Repository.
+ *
+ * @author <a href="mailto:oliver.kiessler@gmail.com">Oliver Kiessler</a>
+ */
+public class JcrSessionSetupTest extends TestBase
+{
+    /** Logger.
+     */
+    private final static Log log = LogFactory.getLog(JcrSessionSetupTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public JcrSessionSetupTest(String testName)
+    {
+        super(testName);
+    }
+
+    /** Testmethod for setupRepository of JcrSession.
+     * @throws Exception Exception
+     */
+    public void testSetupRepository() throws Exception
+    {
+        getJcrSession().setupRepository();
+        
+        assertNotNull(getJcrSession().getSession().getRootNode());
+        
+        Node testNode = getJcrSession().getSession().getRootNode().addNode("testnode", "nt:unstructured");
+        testNode.setProperty("testprop", "some value");
+
+        assertNotNull(getJcrSession().getSession().getItem("/testnode"));
+        assertNotNull(getJcrSession().getSession().getItem("/testnode/testprop"));
+    }
+}
\ No newline at end of file

Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionSetupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionTest.java?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionTest.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/session/impl/JcrSessionTest.java Sun Jun 19 07:52:50 2005
@@ -20,35 +20,29 @@
 
 import javax.jcr.Node;
 import javax.jcr.Property;
-import javax.jcr.Repository;
 import javax.jcr.Session;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.portals.graffito.jcr.converter.ConverterManager;
-import org.apache.portals.graffito.jcr.converter.impl.ConverterManagerImpl;
-import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
-import org.apache.portals.graffito.jcr.session.JcrSession;
-import org.apache.portals.graffito.jcr.session.impl.JcrSessionImpl;
+
 import org.apache.portals.graffito.jcr.testmodel.Content;
 import org.apache.portals.graffito.jcr.testmodel.Document;
 import org.apache.portals.graffito.jcr.testmodel.Folder;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.apache.portals.graffito.jcr.TestBase;
 
 /**
  * Test JcrSession
  *
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
  */
-public class JcrSessionTest extends TestCase
+public class JcrSessionTest extends TestBase
 {
     private final static Log log = LogFactory.getLog(JcrSessionTest.class);
 
-    private JcrSession jcrSession;
-
     /**
      * <p>Defines the test case name for junit.</p>
      * @param testName The test case name.
@@ -58,30 +52,6 @@
         super(testName);
     }
 
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        ConverterManager converterManager = new ConverterManagerImpl("src/conf/convertertest/converters.xml");
-
-        RepositoryUtil.registerRepository("repositoryTest", "repotest/repository.xml", "repotest");
-        Repository repository = RepositoryUtil.getRepository("repositoryTest");
-        Session session = RepositoryUtil.login(repository, "anonymous", "");
-        jcrSession = new JcrSessionImpl(converterManager, repository, session);
-
-    }
-
-    /**
-     * @see junit.framework.TestCase#tearDown()
-     */
-    public void tearDown() throws Exception
-    {
-        super.tearDown();
-
-    }
-
     public static Test suite()
     {
         // All methods starting with "test" will be executed in the test suite.
@@ -98,9 +68,9 @@
         try
         {
 
-            if (jcrSession.itemExists("/test"))
+            if (getJcrSession().itemExists("/test"))
             {
-                jcrSession.remove("/test");
+                getJcrSession().remove("/test");
             }
 
             // --------------------------------------------------------------------------------
@@ -115,15 +85,18 @@
             folder.setName("TestFolder");
             folder.setTitle("Folder Title");
 
-            jcrSession.insert("/test", folder);
+            getJcrSession().insert("/test", folder);
 
             // --------------------------------------------------------------------------------
             // Check the jcr node structure
             // --------------------------------------------------------------------------------
-            Session session = jcrSession.getSession();
+            Session session = getJcrSession().getSession();
             Node folderNode = (Node) session.getItem("/test");
             assertNotNull("Folder node is null", folderNode);
-            assertTrue("Incorrect primary type", folderNode.getPrimaryNodeType().getName().equals("graffito:folder"));
+            
+            //TODO - custom node types not working yet!
+            //assertTrue("Incorrect primary type", folderNode.getPrimaryNodeType().getName().equals("graffito:folder"));
+            
             assertTrue("Incorrect Name for '/test'", folderNode.getName().equals("test"));
 
             Property description = folderNode.getProperty("graffito:description");
@@ -133,7 +106,7 @@
             // --------------------------------------------------------------------------------
             // Get the object
             // --------------------------------------------------------------------------------           
-            folder = (Folder) jcrSession.getObject(Folder.class, "/test");
+            folder = (Folder) getJcrSession().getObject(Folder.class, "/test");
             assertNotNull("Folder object is null", folder);
             assertTrue("Incorrect description for folder object", folder.getDescription().equals("Folder description"));
 
@@ -141,11 +114,11 @@
             // Update the object
             // --------------------------------------------------------------------------------           
             folder.setDescription("new folder description");
-            jcrSession.update("/test", folder);
+            getJcrSession().update("/test", folder);
 
             assertTrue("Incorrect description for folder object", ((Property) session.getItem("/test/graffito:description"))
                     .getString().equals("new folder description"));
-
+            
         }
         catch (Exception e)
         {
@@ -164,9 +137,9 @@
         try
         {
 
-            if (jcrSession.itemExists("/testdoc"))
+            if (getJcrSession().itemExists("/testdoc"))
             {
-                jcrSession.remove("/testdoc");
+                getJcrSession().remove("/testdoc");
             }
 
             // --------------------------------------------------------------------------------
@@ -185,15 +158,18 @@
             content.setEncoding("utf-8");
             document.setContent(content);            
             
-            jcrSession.insert("/testdoc", document);
+            getJcrSession().insert("/testdoc", document);
 
             // --------------------------------------------------------------------------------
             // Check the jcr node structure
             // --------------------------------------------------------------------------------
-            Session session = jcrSession.getSession();
+            Session session = getJcrSession().getSession();
             Node documentNode = (Node) session.getItem("/testdoc");
             assertNotNull("Document node is null", documentNode);
-            assertTrue("Incorrect primary type", documentNode.getPrimaryNodeType().getName().equals("graffito:file"));
+            
+            //TODO - custom node types not working yet!
+            //assertTrue("Incorrect primary type", documentNode.getPrimaryNodeType().getName().equals("graffito:file"));
+            
             assertTrue("Incorrect Name for '/testdoc'", documentNode.getName().equals("testdoc"));
 
             Property description = documentNode.getProperty("graffito:description");
@@ -203,7 +179,7 @@
             // --------------------------------------------------------------------------------
             // Get the object
             // --------------------------------------------------------------------------------           
-            document = (Document) jcrSession.getObject(Document.class, "/testdoc");
+            document = (Document) getJcrSession().getObject(Document.class, "/testdoc");
             assertNotNull("Folder object is null", document);
             assertTrue("Incorrect description for folder object", document.getDescription().equals("Document description"));
 
@@ -211,7 +187,7 @@
             // Update the object
             // --------------------------------------------------------------------------------           
             document.setDescription("new document description");
-            jcrSession.update("/testdoc", document);
+            getJcrSession().update("/testdoc", document);
 
             assertTrue("Incorrect description for document object", ((Property) session.getItem("/testdoc/graffito:description"))
                     .getString().equals("new document description"));
@@ -222,6 +198,5 @@
             e.printStackTrace();
             fail("Exception occurs during the unit test : " + e);
         }
-
-    }    
+    }
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/DocumentConverter.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/DocumentConverter.java?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/DocumentConverter.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/DocumentConverter.java Sun Jun 19 07:52:50 2005
@@ -16,12 +16,15 @@
 package org.apache.portals.graffito.jcr.testconverter;
 
 import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Date;
 
-import javax.jcr.BinaryValue;
-import javax.jcr.DateValue;
 import javax.jcr.Node;
 import javax.jcr.Session;
-import javax.jcr.StringValue;
+
+import org.apache.jackrabbit.core.value.BinaryValue;
+import org.apache.jackrabbit.core.value.DateValue;
+import org.apache.jackrabbit.core.value.StringValue;
 
 import org.apache.portals.graffito.jcr.converter.Converter;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
@@ -54,10 +57,20 @@
            String nodeName = RepositoryUtil.getNodeName(path);
                
            Node parentNode = (Node) session.getItem(parentPath);
-           Node documentNode = parentNode.addNode(nodeName,"graffito:file");
+           
+           //TODO - custom node types not working yet!
+           //Node documentNode = parentNode.addNode(nodeName,"graffito:file");
+           
+           Node documentNode = parentNode.addNode(nodeName,"nt:unstructured");
            documentNode.setProperty("graffito:description", new StringValue(document.getDescription()));           
            documentNode.setProperty("graffito:title", new StringValue(document.getTitle()));           
            
+           // TODO
+           Calendar date = new GregorianCalendar();
+           date.setTime(new Date());
+           documentNode.setProperty("jcr:created", date);
+           
+           
            Node contentNode = documentNode.addNode("jcr:content", "nt:resource");          
            contentNode.setProperty("jcr:encoding", document.getContent().getEncoding());
            contentNode.setProperty("jcr:mimeType", document.getContentType());
@@ -94,7 +107,6 @@
            contentNode.setProperty("jcr:mimeType", document.getContentType());
            contentNode.setProperty("jcr:data", new BinaryValue(document.getContent().getContentByte()));
            contentNode.setProperty("jcr:lastModified", new DateValue(Calendar.getInstance()));
-           
            
            documentNode.save();
             

Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/FolderConverter.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/FolderConverter.java?rev=191347&r1=191346&r2=191347&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/FolderConverter.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testconverter/FolderConverter.java Sun Jun 19 07:52:50 2005
@@ -16,11 +16,14 @@
 package org.apache.portals.graffito.jcr.testconverter;
 
 import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Date;
 
-import javax.jcr.DateValue;
 import javax.jcr.Node;
 import javax.jcr.Session;
-import javax.jcr.StringValue;
+
+import org.apache.jackrabbit.core.value.DateValue;
+import org.apache.jackrabbit.core.value.StringValue;
 
 import org.apache.portals.graffito.jcr.converter.Converter;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
@@ -49,10 +52,18 @@
            String nodeName = RepositoryUtil.getNodeName(path);
                
            Node parentNode = (Node) session.getItem(parentPath);
-           Node folderNode = parentNode.addNode(nodeName,"graffito:folder");
+           
+           //TODO - custom node types not working yet!
+           //Node folderNode = parentNode.addNode(nodeName,"graffito:folder");
+           Node folderNode = parentNode.addNode(nodeName,"nt:unstructured");
            folderNode.setProperty("graffito:description", new StringValue(folder.getDescription()));           
            folderNode.setProperty("graffito:title", new StringValue(folder.getTitle()));
            
+           // TODO
+           Calendar date = new GregorianCalendar();
+           date.setTime(new Date());
+           folderNode.setProperty("jcr:created", date);
+           
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(folder.getLastModified());
            folderNode.setProperty("graffito:lastmodified", new DateValue(calendar));
@@ -89,6 +100,7 @@
         }
         catch(Exception e)
         {
+            e.printStackTrace();
             throw new JcrMappingException("Impossible to store the object at " + path, e);
         }
     }
@@ -110,9 +122,7 @@
            folder.setTitle(folderNode.getProperty("graffito:title").getString());
            folder.setCreationDate(folderNode.getProperty("jcr:created").getDate().getTime());
            folder.setLastModified(folderNode.getProperty("graffito:lastmodified").getDate().getTime());
-           return folder;
-           
-            
+           return folder;  
         }
         catch(Exception e)
         {



Mime
View raw message