incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r290788 - in /incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence: PersistenceManager.java impl/PersistenceManagerImpl.java
Date Wed, 21 Sep 2005 18:51:00 GMT
Author: clombart
Date: Wed Sep 21 11:50:55 2005
New Revision: 290788

URL: http://svn.apache.org/viewcvs?rev=290788&view=rev
Log:
Change the repository manager API

Modified:
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java?rev=290788&r1=290787&r2=290788&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
Wed Sep 21 11:50:55 2005
@@ -15,9 +15,6 @@
  */
 package org.apache.portals.graffito.jcr.persistence;
 
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
 
 /**
@@ -30,31 +27,7 @@
  */
 public interface PersistenceManager
 {
-    /** 
-     * This method creates the graffito namespaces and custom node types
-     *  required for running a graffito managed jcr repository.
-     * 
-     * @throws JcrMappingException JcrMappingException
-     */
-    public void setupRepository() throws JcrMappingException;
-    /**
-     * 
-     * @return The JCR repository object
-     */
-    public Repository getRepository();
-
-    /**
-     * 
-     * @return The associated JCR session 
-     */
-    public Session getSession();
-
-    /**
-     * 
-     * @return The user name
-     */
-    public String getUser();
-
+    
     /**
      * Check if an item exists
      * @param path the JCR item path
@@ -94,18 +67,11 @@
      * @throws org.apache.portals.graffito.jcr.exception.JcrMappingException 
      */
     public void remove(String path) throws JcrMappingException;
-        
-    /** 
-     * Getter for property jcrCustomNodeTypeCreator.
-     * 
-     * @return jcrCustomNodeTypeCreator
-     */
-    public CustomNodeTypeCreator getJcrCustomNodeTypeCreator();
-
-    /** 
-     * Setter for property jcrCustomNodeTypeCreator.
-     * 
-     * @param object CustomNodeTypeCreator
+    
+    
+    /**
+     * Close the JCR session    
      */
-    public void setJcrCustomNodeTypeCreator(CustomNodeTypeCreator object);
+    public void logout() throws JcrMappingException;
+        
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java?rev=290788&r1=290787&r2=290788&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
Wed Sep 21 11:50:55 2005
@@ -44,19 +44,15 @@
     private final static Log log = LogFactory.getLog(PersistenceManagerImpl.class);    
     
    
-    /** Jackrabbit jcr repository.
+    /** 
+     * Jackrabbit jcr repository.
      */
     private Repository repository;
     
     /** Jackrabbit jcr session.
      */
     private Session session;
-       
-
-    /** Custom node type creator dependency needed during repository setup.
-     */
-    private CustomNodeTypeCreator jcrCustomNodeTypeCreator;
-    
+           
     /**
      * The Mapper component
      */
@@ -72,13 +68,7 @@
      */
     private ObjectConverter objectConverter;
     
-    /** 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 for setting up a session to interact with a jcr repository. 
@@ -86,10 +76,10 @@
      * @param mapper the Mapper component
      * @param repository The JCR repository reference
      * @param session The JCR Session
-     * @param jcrCustomNodeTypeCreator Custom node type creator
+     * 
      * @throws JcrMappingException when it is impossible to create the PersistenceManager
      */
-    public PersistenceManagerImpl(Mapper mapper, Repository repository, Session session,
CustomNodeTypeCreator jcrCustomNodeTypeCreator) throws JcrMappingException
+    public PersistenceManagerImpl(Mapper mapper, Repository repository, Session session)
throws JcrMappingException
     {
        try
        {
@@ -97,9 +87,7 @@
         this.repository = repository;
         this.session = session;
         this.atomicTypeConverterFactory = AtomicTypeConverterFactory.getInstance(session.getValueFactory());
-        this.objectConverter = new ObjectConverter(mapper, atomicTypeConverterFactory);
-        this.jcrCustomNodeTypeCreator = jcrCustomNodeTypeCreator;
-        
+        this.objectConverter = new ObjectConverter(mapper, atomicTypeConverterFactory); 
              
        }
        catch(Exception e)
        {
@@ -107,75 +95,7 @@
        }
     }
     
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#setupRepository()
-     */
-    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());
-        }
-    }
-    
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getRepository()
-     */
-    public Repository getRepository()
-    {       
-        return this.repository;
-    }
-    
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getSession()
-     */
-    public Session getSession()
-    {
-        return this.session; 
-    }
-    
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getUser()
-     */
-    public String getUser()
-    {
-        return getSession().getUserID();
-    }
-    
+        
     /**
      * 
      * @see org.apache.portals.graffito.jcr.session.JcrSession#getObject(java.lang.Class,
java.lang.String)
@@ -212,9 +132,9 @@
                 throw new JcrMappingException("Path already exists : " + path);
             }
         }
-        catch (RepositoryException re)
+        catch (RepositoryException e)
         {
-            throw new JcrMappingException(re.getMessage());
+            throw new JcrMappingException("Impossible to insert the object at " + path, e);
         }
         
         
@@ -235,9 +155,9 @@
                 throw new JcrMappingException("Path is not existing : " + path);
             }
         }
-        catch (RepositoryException re)
+        catch (RepositoryException e)
         {
-            throw new JcrMappingException(re.getMessage());
+            throw new JcrMappingException("Impossible to update", e);
         }
         
         objectConverter.update(session, path, object);  
@@ -257,9 +177,9 @@
             item.remove();
             parent.save();
         }
-        catch (RepositoryException re)
+        catch (RepositoryException e)
         {
-            throw new JcrMappingException(re.getMessage());
+            throw new JcrMappingException("Impossible to remove the object at " + path);
         }
     }
     
@@ -273,29 +193,31 @@
         {
             return session.itemExists(path);
         }
-        catch (RepositoryException re)
+        catch (RepositoryException e)
         {
-            throw new JcrMappingException(re.getMessage());
+            throw new JcrMappingException("Impossible to check if the object exist", e);
         }
     }
 
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getJcrCustomNodeTypeCreator()
-     */
-    public CustomNodeTypeCreator getJcrCustomNodeTypeCreator()
-    {
-        return jcrCustomNodeTypeCreator;
-    }
 
     /**
      * 
-     * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#setJcrCustomNodeTypeCreator(org.apache.portals.graffito.jcr.persistence.CustomNodeTypeCreator)
+     * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#logout()
      */
-    public void setJcrCustomNodeTypeCreator(CustomNodeTypeCreator object)
+    public void logout() throws JcrMappingException
     {
-        this.jcrCustomNodeTypeCreator = object;
+        try 
+        {
+           session.save();
+           session.logout();
+        }
+        catch (Exception e)
+        {
+            throw new JcrMappingException("Impossible to logout", e);
+        }
     }
+
+    
     
   
 }



Mime
View raw message