incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From okiess...@apache.org
Subject svn commit: r349266 - in /incubator/graffito/trunk/jcr-nodemanagement: ./ src/config/jackrabbit/ src/config/jeceira/ src/java/org/apache/portals/graffito/jcr/nodemanagement/ src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/ src/java/org/apa...
Date Sun, 27 Nov 2005 17:59:46 GMT
Author: okiessler
Date: Sun Nov 27 09:59:29 2005
New Revision: 349266

URL: http://svn.apache.org/viewcvs?rev=349266&view=rev
Log:
Issue: GRFT-79

Added:
    incubator/graffito/trunk/jcr-nodemanagement/src/config/jackrabbit/repository_derby.xml
    incubator/graffito/trunk/jcr-nodemanagement/src/config/jeceira/jeceira.xml
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/RepositorySession.java
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JackrabbitRepositorySession.java
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JeceiraRepositorySession.java
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositoryConfiguration.java
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositorySessionFactory.java
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NamespaceHelper.java
Modified:
    incubator/graffito/trunk/jcr-nodemanagement/project.xml
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/NodeTypeManager.java
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
    incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java
    incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/TestBase.java
    incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java

Modified: incubator/graffito/trunk/jcr-nodemanagement/project.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/project.xml?rev=349266&r1=349265&r2=349266&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/project.xml (original)
+++ incubator/graffito/trunk/jcr-nodemanagement/project.xml Sun Nov 27 09:59:29 2005
@@ -43,8 +43,8 @@
 	<dependency>
       <groupId>jackrabbit</groupId>
       <artifactId>jackrabbit</artifactId>
-      <version>1.0-20051109-SNAPSHOT</version>
-    </dependency>
+      <version>1.0-20051125-SNAPSHOT</version>
+    </dependency>   
     <dependency>
       <id>concurrent</id>
       <version>1.3.4</version>
@@ -94,6 +94,49 @@
       <artifactId>commons-digester</artifactId>
       <version>1.7</version>
     </dependency>
+    <dependency>
+        <groupId>org.apache.derby</groupId>
+        <artifactId>derby</artifactId>
+        <version>10.1.1.0</version>
+	</dependency>    
+    
+    <dependency>
+      <groupId>jeceira</groupId>
+      <typeId>jar</typeId>
+      <artifactId>jeceira</artifactId>
+      <version>0.1.4</version>
+    </dependency> 
+    <dependency>
+      <groupId>commons</groupId>
+      <typeId>jar</typeId>
+      <artifactId>commons</artifactId>
+      <version>0.2</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <typeId>jar</typeId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>doka</groupId>
+      <typeId>jar</typeId>
+      <artifactId>doka</artifactId>
+      <version>0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <typeId>jar</typeId>
+      <artifactId>hsqldb</artifactId>
+      <version>1.7.2.2</version>
+    </dependency>
+    <dependency>
+      <groupId>jug-asl</groupId>
+      <typeId>jar</typeId>
+      <artifactId>jug-asl</artifactId>
+      <version>2.0rc4</version>
+    </dependency>           
+            
   </dependencies>  
   
   <build>
@@ -111,6 +154,13 @@
 						<exclude>**/*.java</exclude>
 					</excludes>
 				</resource>
+                <resource>
+                  <directory>${basedir}/src/config/jeceira</directory>
+                  <includes>
+                    <include>*.xml</include>
+                  </includes>
+                  <filtering>false</filtering>
+                </resource>                                
 			</resources>
 		</unitTest>
     

Added: incubator/graffito/trunk/jcr-nodemanagement/src/config/jackrabbit/repository_derby.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/config/jackrabbit/repository_derby.xml?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/config/jackrabbit/repository_derby.xml (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/config/jackrabbit/repository_derby.xml Sun Nov 27 09:59:29 2005
@@ -0,0 +1,212 @@
+<?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 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="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>
+</Repository>

Added: incubator/graffito/trunk/jcr-nodemanagement/src/config/jeceira/jeceira.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/config/jeceira/jeceira.xml?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/config/jeceira/jeceira.xml (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/config/jeceira/jeceira.xml Sun Nov 27 09:59:29 2005
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jeceira>
+    <repositories>
+        <repository name="test" persistenceFactory="com.jeceira.persistence.hsqldb.HsqldbFactory">
+            <properties>
+                <property name="url" value="jdbc:hsqldb:file:./target/jeceira/testrepo" />
+                <property name="username" value="sa" />
+                <property name="password" value='' />
+            </properties>
+            <workspaces>
+                <workspace name="testworkspace" />
+            </workspaces>
+        </repository>
+    </repositories>
+</jeceira>

Modified: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/NodeTypeManager.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/NodeTypeManager.java?rev=349266&r1=349265&r2=349266&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/NodeTypeManager.java (original)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/NodeTypeManager.java Sun Nov 27 09:59:29 2005
@@ -169,11 +169,11 @@
      * @param namespace Name of nodetypes to return
      * @return list of matching JCR node types
      */
-    List getPrimaryNodeTypeNames(String namespace);
+    List getPrimaryNodeTypeNames(Session session, String namespace);
     
     /** Returns a list of all JCR node types.
      *
      * @return list of all JCR node types
      */
-    List getAllPrimaryNodeTypeNames();
+    List getAllPrimaryNodeTypeNames(Session session);
 }

Added: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/RepositorySession.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/RepositorySession.java?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/RepositorySession.java (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/RepositorySession.java Sun Nov 27 09:59:29 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2005 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.nodemanagement;
+
+import javax.jcr.Session;
+
+import org.apache.portals.graffito.jcr.nodemanagement.impl.RepositoryConfiguration;
+
+/** Represents to JCR repository connection parameter.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ */
+public interface RepositorySession
+{
+    
+    /** Connects to a JCR repository and returns a session to it.
+     * 
+     * @param username Username to connect to repository
+     * @param password Password
+     * @param configuration Repository configuration
+     * @return session
+     */
+    Session getSession(String username, String password,
+            RepositoryConfiguration configuration);
+}

Added: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JackrabbitRepositorySession.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JackrabbitRepositorySession.java?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JackrabbitRepositorySession.java (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JackrabbitRepositorySession.java Sun Nov 27 09:59:29 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2005 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.nodemanagement.impl;
+
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
+import org.apache.portals.graffito.jcr.nodemanagement.RepositorySession;
+
+/** This class is the Jackrabbit JCR Repository session implementation.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ */
+public class JackrabbitRepositorySession implements RepositorySession
+{
+    
+    /** Creates a new instance of JackrabbitRepositorySession. */
+    public JackrabbitRepositorySession()
+    {
+    }
+    
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.RepositorySession#getSession
+     */
+    public Session getSession(String username, String password,
+            RepositoryConfiguration configuration)
+    {
+
+        RepositoryUtil.registerRepository(configuration.getRepositoryName(),
+                configuration.getConfigurationFile(),
+                configuration.getRepositoryPath());
+        
+        Repository repository =
+                RepositoryUtil.getRepository(configuration.getRepositoryName());
+        
+        return RepositoryUtil.login(repository, username, password);
+    }
+}

Added: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JeceiraRepositorySession.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JeceiraRepositorySession.java?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JeceiraRepositorySession.java (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/JeceiraRepositorySession.java Sun Nov 27 09:59:29 2005
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2005 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.nodemanagement.impl;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import com.jeceira.repository.RepositoryFactory;
+
+import org.apache.portals.graffito.jcr.nodemanagement.RepositorySession;
+
+/** This class is the Jeceira JCR Repository session implementation.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ */
+public class JeceiraRepositorySession implements RepositorySession
+{
+    
+    /** Creates a new instance of JeceiraRepositorySession. */
+    public JeceiraRepositorySession()
+    {
+    }
+
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.RepositorySession#getSession
+     */    
+    public Session getSession(String username, String password,
+            RepositoryConfiguration configuration)
+    {
+        Session session = null;
+        
+        try {
+            RepositoryFactory repositoryFactory = RepositoryFactory.getInstance();
+            Repository repository = repositoryFactory.getRepository(configuration.getRepositoryName());
+            
+            session = repository.login();
+        }
+        catch (RepositoryException re)
+        {
+            re.printStackTrace();
+        }
+        
+        return session;
+    } 
+}

Added: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositoryConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositoryConfiguration.java?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositoryConfiguration.java (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositoryConfiguration.java Sun Nov 27 09:59:29 2005
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2000-2005 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.nodemanagement.impl;
+
+/**
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ */
+public class RepositoryConfiguration
+{
+    
+    /**
+     */
+    private String configurationFile;
+    
+    /**
+     */
+    private String repositoryPath;
+    
+    /**
+     */
+    private String repositoryName;
+    
+    /**
+     */
+    private String workspaceName;
+    
+    /**
+     */
+    private boolean useJNDI;
+    
+    /**
+     */
+    private String jndiName;
+    
+    /** Creates a new instance of RepositoryConfiguration. */
+    public RepositoryConfiguration()
+    {
+    }
+
+    public String getConfigurationFile()
+    {
+        return configurationFile;
+    }
+
+    public void setConfigurationFile(String configurationFile)
+    {
+        this.configurationFile = configurationFile;
+    }
+
+    public String getRepositoryPath() 
+    {
+        return repositoryPath;
+    }
+
+    public void setRepositoryPath(String repositoryPath)
+    {
+        this.repositoryPath = repositoryPath;
+    }
+
+    public boolean isUseJNDI()
+    {
+        return useJNDI;
+    }
+
+    public void setUseJNDI(boolean useJNDI)
+    {
+        this.useJNDI = useJNDI;
+    }
+
+    public String getJndiName()
+    {
+        return jndiName;
+    }
+
+    public void setJndiName(String jndiName)
+    {
+        this.jndiName = jndiName;
+    }
+
+    public String getRepositoryName()
+    {
+        return repositoryName;
+    }
+
+    public void setRepositoryName(String repositoryName)
+    {
+        this.repositoryName = repositoryName;
+    }
+
+    public String getWorkspaceName()
+    {
+        return workspaceName;
+    }
+
+    public void setWorkspaceName(String workspaceName)
+    {
+        this.workspaceName = workspaceName;
+    }
+}

Added: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositorySessionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositorySessionFactory.java?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositorySessionFactory.java (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/RepositorySessionFactory.java Sun Nov 27 09:59:29 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-2005 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.nodemanagement.impl;
+
+import javax.jcr.Session;
+
+/** Factory class to create a JCR repository session for different
+ * JCR implementations.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ */
+public class RepositorySessionFactory {
+    
+    public static final String JACKRABBIT = "jackrabbit";
+    public static final String JECEIRA = "jeceira";
+
+    private static Session session;
+    
+    /**  
+     * Private constructor.
+     */
+    private RepositorySessionFactory()
+    {
+    }
+    
+    /** Returns a session to a JCR repository.
+     * 
+     * @param jcrRepository 
+     * @param username Username to logon
+     * @param password Password
+     * @return session JCR repository session
+     */
+    public static Session getSession(String jcrRepository,
+            String username, String password,
+            RepositoryConfiguration configuration)
+    {
+        
+        if (session == null)
+        {
+            if (jcrRepository != null)
+            {
+                if (jcrRepository.equals(JACKRABBIT))
+                {
+                    session = new JackrabbitRepositorySession().getSession(username, password, configuration);
+                }
+                else if (jcrRepository.equals(JECEIRA)) 
+                {
+                    session = new JeceiraRepositorySession().getSession(username, password, configuration); 
+                }
+            }
+        }
+
+        return session;
+    }
+}

Added: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NamespaceHelper.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NamespaceHelper.java?rev=349266&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NamespaceHelper.java (added)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NamespaceHelper.java Sun Nov 27 09:59:29 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2000-2005 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.nodemanagement.impl.jackrabbit;
+
+import javax.jcr.NamespaceRegistry;
+
+import org.apache.jackrabbit.core.nodetype.ItemDef;
+import org.apache.jackrabbit.name.QName;
+
+/** Jackrabbit namespace helper class.
+ *
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ */
+public class NamespaceHelper
+{
+    
+    /** JCR namespace registry.
+     */
+    private NamespaceRegistry registry;
+    
+    /** Creates a new instance of NamespaceHelper. */
+    public NamespaceHelper()
+    {
+    }
+
+    /** Returns a QName object from a given JCR item name.
+     * 
+     * @param nodeName JCR item name
+     * @return qName
+     */
+    public QName getQName(String itemName)
+    {
+        QName qName = null;
+        
+        if (itemName != null && itemName.length() > 0)
+        {
+            if (itemName.equals("*"))
+            {
+                qName = ItemDef.ANY_NAME;
+            }
+            else
+            {
+                String[] parts = itemName.split(":");
+                qName = new QName(getNamespaceUri(parts[0]),
+                        parts[1]); 
+            }
+        }
+        
+        return qName;
+    }
+
+    /** Returns the namespace URI from a given namespace prefix.
+     * 
+     * @param namespacePrefix 
+     * @return uri
+     */
+    public String getNamespaceUri(String namespacePrefix)
+    {    
+        String uri = null;
+        try
+        {
+            uri = getRegistry().getURI(namespacePrefix);
+        }
+        catch (Exception ne)
+        {
+            ne.printStackTrace();
+        }
+
+        return uri;
+    }
+    
+    /** Getter for property registry.
+     * 
+     * @return registry
+     */
+    public NamespaceRegistry getRegistry()
+    {
+        return registry;
+    }
+
+    /** Setter for property registry.
+     * 
+     * @param object registry
+     */
+    public void setRegistry(NamespaceRegistry object)
+    {
+        this.registry = object;
+    }
+}

Modified: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java?rev=349266&r1=349265&r2=349266&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java (original)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImpl.java Sun Nov 27 09:59:29 2005
@@ -17,19 +17,28 @@
 
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import javax.jcr.PropertyType;
 
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
+import javax.jcr.version.OnParentVersionAction;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.nodetype.PropDef;
+import org.apache.jackrabbit.core.nodetype.PropDefImpl;
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
+import org.apache.jackrabbit.name.QName;
 
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
+import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.MappingDescriptor;
 
 import org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager;
@@ -49,6 +58,10 @@
      */
     private static Log log = LogFactory.getLog(NodeTypeManagerImpl.class);
     
+    /**
+     */
+    private NamespaceHelper namespaceHelper = new NamespaceHelper();
+    
     /** Creates a new instance of NodeTypeManagerImpl. */
     public NodeTypeManagerImpl()
     {
@@ -65,7 +78,8 @@
             try
             {
                 session.getWorkspace().getNamespaceRegistry().registerNamespace(namespace, namespaceUri);
-                log.info("Namespace created: " + namespace);
+                log.info("Namespace created: " +
+                        "{" + namespaceUri + "}" + namespace);
             }
             catch (Exception e)
             {
@@ -74,33 +88,153 @@
         }
     }
     
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#createNodeTypes
+     */    
     public void createNodeTypes(Session session, MappingDescriptor mappingDescriptor)
     throws NodeTypeCreationException
     {
     }
     
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#createNodeTypes
+     */     
     public void createNodeTypes(Session session, ClassDescriptor[] classDescriptors)
     throws NodeTypeCreationException
     {
     }
     
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#createNodeTypesFromMappingFiles
+     */       
     public void createNodeTypesFromMappingFiles(Session session,
             InputStream[] mappingXmlFiles)
             throws NodeTypeCreationException
     {
     }
     
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#createSingleNodeType
+     */ 
     public void createSingleNodeType(Session session, ClassDescriptor classDescriptor)
     throws NodeTypeCreationException
     {
+        try
+        {
+            getNamespaceHelper().setRegistry(session.getWorkspace().getNamespaceRegistry());
+            ArrayList list = new ArrayList();
+            NodeTypeDef nodeTypeDef = getNodeTypeDef(classDescriptor.getJcrNodeType(),
+                        classDescriptor.getJcrSuperTypes());
+            
+            if (classDescriptor.getFieldDescriptors() != null)
+            {
+                Iterator fieldIterator = classDescriptor.getFieldDescriptors().iterator();
+                PropDef[] properties = new PropDef[classDescriptor.getFieldDescriptors().size()];
+                int i = 0;
+                while (fieldIterator.hasNext())
+                {
+                    FieldDescriptor field = (FieldDescriptor) fieldIterator.next();
+                    properties[i] = getPropertyDefinition(field,
+                            nodeTypeDef.getName());
+                    i++;
+                }
+                
+                nodeTypeDef.setPropertyDefs(properties);
+            }
+
+            list.add(nodeTypeDef);
+            createNodeTypesFromList(session, list);
+            log.info("Registered JCR node type '" + classDescriptor.getJcrNodeType() +
+                    "' for class '" + classDescriptor.getClassName() + "'");
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            log.error("Could not create node types from class descriptor.", e);
+            throw new NodeTypeCreationException(e);
+        }        
+    }
+    
+    /** Creates a NodeTypeDef object.
+     * 
+     * @param jcrNodeType Name of JCR node type
+     * @param jcrSuperTypes JCR node super types
+     * @return type
+     */
+    public NodeTypeDef getNodeTypeDef(String jcrNodeType, String jcrSuperTypes)
+    {
+        NodeTypeDef type = new NodeTypeDef();
+        type.setMixin(false);
+        type.setName(getNamespaceHelper().getQName(jcrNodeType));
+        type.setSupertypes(getJcrSuperTypes(jcrSuperTypes));
+        type.setPrimaryItemName(getNamespaceHelper().getQName(jcrNodeType));
+        return type;
+    }
+    
+    /** Creates a PropDefImpl object.
+     * 
+     * @param field Field descriptor
+     * @param declaringNodeType Node Type QName where the property belongs to
+     * @return property
+     */
+    public PropDefImpl getPropertyDefinition(FieldDescriptor field,
+            QName declaringNodeType)
+    {
+        PropDefImpl property = new PropDefImpl();
+        property.setName(getNamespaceHelper().getQName(field.getJcrName()));
+        property.setRequiredType(PropertyType.valueFromName(field.getJcrType()));
+        property.setDeclaringNodeType(declaringNodeType);
+        property.setAutoCreated(field.isJcrAutoCreated());
+        property.setMandatory(field.isJcrMandatory());
+        property.setMultiple(field.isJcrMultiple());
+        
+        if (field.getJcrOnParentVersion() != null &&
+                field.getJcrOnParentVersion().length() > 0)
+        {
+            property.setOnParentVersion(OnParentVersionAction.valueFromName(field.getJcrOnParentVersion()));
+        }
+        
+        property.setProtected(field.isJcrProtected());
+        return property;
+    }
+
+    /** Creates a QName array from a comma separated list of JCR super types in
+     * a given String.
+     * 
+     * @param superTypes JCR super types 
+     * @return qNameSuperTypes
+     */
+    public QName[] getJcrSuperTypes(String superTypes)
+    {
+        QName[] qNameSuperTypes = null;
+        if (superTypes != null && superTypes.length() > 0)
+        {
+            String[] superTypesArray = superTypes.split(",");
+            log.debug("JCR super types found: " + superTypesArray.length);
+            qNameSuperTypes = new QName[superTypesArray.length];
+            for (int i = 0; i < superTypesArray.length; i++)
+            {
+                String superTypeName = superTypesArray[i].trim();
+                qNameSuperTypes[i] = getNamespaceHelper().getQName(superTypeName);
+                log.debug("Setting JCR super type: " + superTypeName);
+            }
+        }
+
+        return qNameSuperTypes;
     }
     
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#createSingleNodeTypeFromMappingFile
+     */     
     public void createSingleNodeTypeFromMappingFile(Session session,
             InputStream mappingXmlFile, String jcrNodeType)
             throws NodeTypeCreationException
     {
     }
     
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#createNodeTypeFromClass
+     */     
     public void createNodeTypeFromClass(Session session, Class clazz,
             String jcrNodeType, boolean reflectSuperClasses)
             throws NodeTypeCreationException
@@ -109,7 +243,7 @@
     
     /**
      * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#createNodeTypesFromConfiguration
-     */
+     */  
     public void createNodeTypesFromConfiguration(Session session,
             InputStream jcrRepositoryConfigurationFile)
             throws OperationNotSupportedException, NodeTypeCreationException
@@ -124,12 +258,7 @@
                 list.add(types[i]);
             }
             
-            Workspace wsp = session.getWorkspace();
-            javax.jcr.nodetype.NodeTypeManager ntMgr = wsp.getNodeTypeManager();
-            NodeTypeRegistry ntReg =
-                    ((org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl) ntMgr).getNodeTypeRegistry();
-            
-            ntReg.registerNodeTypes(list);
+            createNodeTypesFromList(session, list);
             log.info("Registered " + list.size() + " nodetypes from xml configuration file.");
         }
         catch (Exception e)
@@ -139,23 +268,71 @@
         }
     }
     
+    /**
+     * 
+     * @param session 
+     * @param nodeTypes 
+     * @throws org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException 
+     * @throws javax.jcr.RepositoryException 
+     */
+    public void createNodeTypesFromList(Session session, List nodeTypes)
+    throws InvalidNodeTypeDefException, RepositoryException
+    {
+        Workspace wsp = session.getWorkspace();
+        javax.jcr.nodetype.NodeTypeManager ntMgr = wsp.getNodeTypeManager();
+        NodeTypeRegistry ntReg =
+                ((org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl) ntMgr).getNodeTypeRegistry();
+        
+        ntReg.registerNodeTypes(nodeTypes);
+    }
+    
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#removeNodeTypes
+     */     
     public void removeNodeTypes(Session session, InputStream[] mappingXmlFiles)
     throws NodeTypeRemovalException
     {
     }
     
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#removeSingleNodeType
+     */     
     public void removeSingleNodeType(Session session, String jcrNodeType)
     throws NodeTypeRemovalException
     {
     }
     
-    public List getPrimaryNodeTypeNames(String namespace)
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#getPrimaryNodeTypeNames
+     */    
+    public List getPrimaryNodeTypeNames(Session session, String namespace)
     {
         return null;
     }
     
-    public List getAllPrimaryNodeTypeNames()
+    /**
+     * @see org.apache.portals.graffito.jcr.nodemanagement.NodeTypeManager#getAllPrimaryNodeTypeNames
+     */    
+    public List getAllPrimaryNodeTypeNames(Session session)
     {
         return null;
+    }
+
+    /** Getter for property namespaceHelper.
+     * 
+     * @return namespaceHelper
+     */
+    public NamespaceHelper getNamespaceHelper()
+    {
+        return namespaceHelper;
+    }
+
+    /** Setter for property namespaceHelper.
+     * 
+     * @param object namespaceHelper
+     */
+    public void setNamespaceHelper(NamespaceHelper object)
+    {
+        this.namespaceHelper = object;
     }
 }

Modified: incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java?rev=349266&r1=349265&r2=349266&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java (original)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/java/org/apache/portals/graffito/jcr/nodemanagement/impl/jeceira/NodeTypeManagerImpl.java Sun Nov 27 09:59:29 2005
@@ -107,12 +107,12 @@
     {
     }
     
-    public List getPrimaryNodeTypeNames(String namespace)
+    public List getPrimaryNodeTypeNames(Session session, String namespace)
     {
         return null;
     }
     
-    public List getAllPrimaryNodeTypeNames()
+    public List getAllPrimaryNodeTypeNames(Session session)
     {
         return null;
     }    

Modified: incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/TestBase.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/TestBase.java?rev=349266&r1=349265&r2=349266&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/TestBase.java (original)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/TestBase.java Sun Nov 27 09:59:29 2005
@@ -1,18 +1,17 @@
-/* ========================================================================
- * Copyright 2004 The Apache Software Foundation
- *
+/*
+ * Copyright 2000-2005 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
- *
+ * 
+ *      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.nodemanagement;
 
@@ -21,6 +20,8 @@
 import javax.jcr.nodetype.PropertyDefinition;
 
 import junit.framework.TestCase;
+import org.apache.portals.graffito.jcr.nodemanagement.impl.RepositoryConfiguration;
+import org.apache.portals.graffito.jcr.nodemanagement.impl.RepositorySessionFactory;
 
 import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
 
@@ -30,9 +31,7 @@
  */
 public class TestBase  extends TestCase
 {
-    private Session session;
-    
-    private static Repository repository;
+    protected static Session session;
     
     /**
      * Setting up the testcase.
@@ -41,23 +40,26 @@
      */
     protected void setUp() throws Exception
     {
-        if (repository == null) 
+        if (session == null)
         {
-            RepositoryUtil.registerRepository("repositoryTest",
-                    "./src/config/jackrabbit/repository.xml",
-                    "./target/repository");
-            repository = RepositoryUtil.getRepository("repositoryTest");
-        }
-
-        session = RepositoryUtil.login(repository, "superuser", "superuser");        
+            RepositoryConfiguration configuration = new RepositoryConfiguration();
+            configuration.setConfigurationFile("./src/config/jackrabbit/repository.xml");
+            configuration.setRepositoryName("repositoryTest");
+            configuration.setRepositoryPath("./target/repository");
+            session = RepositorySessionFactory.getSession(RepositorySessionFactory.JACKRABBIT, "superuser", "superuser", configuration);
+            
+            /*RepositoryConfiguration configuration = new RepositoryConfiguration();
+            configuration.setConfigurationFile("./src/config/jeceria/jeceira.xml");
+            configuration.setRepositoryName("test");
+            session = RepositorySessionFactory.getSession(RepositorySessionFactory.JECEIRA, null, null, configuration);*/
+        }       
     }
-    
+
     /**
      * @see junit.framework.TestCase#tearDown()
      */
     public void tearDown() throws Exception
     {
-        getSession().logout();
     }
     
     /** Returns true if a property was found in an array of property defintions.
@@ -83,23 +85,5 @@
         }
         
         return found;
-    }    
-
-    /** Getter for property session;
-     *
-     * @return session
-     */
-    public Session getSession()
-    {
-        return session;
-    }
-    
-    /** Setter for property session.
-     *
-     * @param object Session
-     */
-    public void setSession(Session object)
-    {
-        this.session = object;
     }
 }

Modified: incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java?rev=349266&r1=349265&r2=349266&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java (original)
+++ incubator/graffito/trunk/jcr-nodemanagement/src/test/org/apache/portals/graffito/jcr/nodemanagement/impl/jackrabbit/NodeTypeManagerImplTest.java Sun Nov 27 09:59:29 2005
@@ -18,8 +18,11 @@
 import java.io.FileInputStream;
 
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
 
 import junit.framework.*;
+import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
+import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
 
 import org.apache.portals.graffito.jcr.nodemanagement.TestBase;
 import org.apache.portals.graffito.jcr.nodemanagement.exception.NamespaceCreationException;
@@ -30,6 +33,11 @@
  */
 public class NodeTypeManagerImplTest extends TestBase {
     
+    /** Class to test.
+     */
+    private NodeTypeManagerImpl jackrabbitNodeTypeManagerImpl
+                = new NodeTypeManagerImpl();
+    
     /** Returns testsuite.
      * @return suite
      */
@@ -44,19 +52,17 @@
      */
     public void testCreateNamespace() throws Exception
     {
-        NodeTypeManagerImpl jackrabbitNodeTypeManagerImpl
-                = new NodeTypeManagerImpl();
-        jackrabbitNodeTypeManagerImpl.createNamespace(getSession(),
+        getJackrabbitNodeTypeManagerImpl().createNamespace(session,
                 "test", "http://www.test.com/test-uri");
         
-        assertEquals(getSession().getWorkspace().getNamespaceRegistry().getPrefix("http://www.test.com/test-uri"), "test");
-        assertEquals(getSession().getWorkspace().getNamespaceRegistry().getURI("test"), "http://www.test.com/test-uri");
+        assertEquals(session.getWorkspace().getNamespaceRegistry().getPrefix("http://www.test.com/test-uri"), "test");
+        assertEquals(session.getWorkspace().getNamespaceRegistry().getURI("test"), "http://www.test.com/test-uri");
         
         boolean failed = false;
         
         try
         {
-            jackrabbitNodeTypeManagerImpl.createNamespace(getSession(),
+            getJackrabbitNodeTypeManagerImpl().createNamespace(session,
                     "test", "http://www.test.com/test-uri");
         } catch (NamespaceCreationException nce) {
             // expected
@@ -72,12 +78,10 @@
      */
     public void testCreateNodeTypesFromConfiguration() throws Exception
     {
-        NodeTypeManagerImpl jackrabbitNodeTypeManagerImpl
-                = new NodeTypeManagerImpl();
-        jackrabbitNodeTypeManagerImpl.createNodeTypesFromConfiguration(getSession(),
+        getJackrabbitNodeTypeManagerImpl().createNodeTypesFromConfiguration(session,
                 new FileInputStream("./src/config/jackrabbit/nodetypes_test1.xml"));
         
-        NodeType test1 = getSession().getWorkspace().getNodeTypeManager().getNodeType("graffito:test1");
+        NodeType test1 = session.getWorkspace().getNodeTypeManager().getNodeType("graffito:test1");
         assertNotNull(test1);
         assertFalse(test1.isMixin());
         assertFalse(test1.hasOrderableChildNodes());
@@ -85,5 +89,88 @@
         assertEquals(test1.getSupertypes().length, 1);
         assertEquals(test1.getSupertypes()[0].getName(), "nt:base");
         assertTrue(containsPropertyDefintion(test1.getPropertyDefinitions(), "graffito:testProperty"));
+    }
+    
+    /**
+     * Test of createSingleNodeType method, of class org.apache.portals.graffito.jcr.nodemanagement.impl.jackrabbit.NodeTypeManagerImpl.
+     * @throws java.lang.Exception 
+     */
+    public void testCreateSingleNodeType() throws Exception
+    {
+        ClassDescriptor classDescriptor = new ClassDescriptor();
+        classDescriptor.setClassName("test.TestClass");
+        classDescriptor.setJcrNodeType("graffito:test2");
+        classDescriptor.setJcrSuperTypes("nt:base");
+        
+        FieldDescriptor field1 = new FieldDescriptor();
+        field1.setFieldName("a");
+        field1.setJcrName("graffito:a");
+        field1.setJcrType("String");
+        classDescriptor.addFieldDescriptor(field1);
+
+        FieldDescriptor field2 = new FieldDescriptor();
+        field2.setFieldName("b");
+        field2.setJcrName("graffito:b");
+        field2.setJcrType("Long");
+        classDescriptor.addFieldDescriptor(field2);        
+
+        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
+        
+        NodeType test2 = session.getWorkspace().getNodeTypeManager().getNodeType("graffito:test2");
+        assertNotNull(test2);
+        assertFalse(test2.isMixin());
+        assertEquals(test2.getName(), "graffito:test2");
+        assertEquals(test2.getSupertypes().length, 1);
+        assertEquals(test2.getSupertypes()[0].getName(), "nt:base");
+
+        // 2 defined in graffito:test2 and 2 inherited from nt:base
+        assertEquals(test2.getPropertyDefinitions().length, 4);
+        
+        assertTrue(containsProperty("graffito:a", test2.getPropertyDefinitions()));
+        assertTrue(containsProperty("graffito:b", test2.getPropertyDefinitions()));
+        assertTrue(containsProperty("jcr:primaryType", test2.getPropertyDefinitions()));
+        assertTrue(containsProperty("jcr:mixinTypes", test2.getPropertyDefinitions()));
+    }
+
+    /** Returns true if a given property is found in an arry of property
+     * definitions.
+     * 
+     * @param propertyName Name of property to find
+     * @param propDefs Properties of a node type
+     * @return true/false 
+     */
+    protected boolean containsProperty(String propertyName,
+            PropertyDefinition[] propDefs)
+    {
+        boolean found = false;
+        
+        for (int i = 0; i < propDefs.length; i++)
+        {
+           if (propDefs[i].getName().equals(propertyName))
+           {
+               found = true;
+               break;
+           }
+        }
+
+        return found;
+    }
+    
+    /** Getter for property jackrabbitNodeTypeManagerImpl.
+     * 
+     * @return jackrabbitNodeTypeManagerImpl
+     */
+    public NodeTypeManagerImpl getJackrabbitNodeTypeManagerImpl()
+    {
+        return jackrabbitNodeTypeManagerImpl;
+    }
+
+    /** Setter for property jackrabbitNodeTypeManagerImpl.
+     * 
+     * @param object jackrabbitNodeTypeManagerImpl
+     */
+    public void setJackrabbitNodeTypeManagerImpl(NodeTypeManagerImpl object)
+    {
+        this.jackrabbitNodeTypeManagerImpl = object;
     }
 }



Mime
View raw message