incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r225702 - in /incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store: ./ impl/ impl/fs/ impl/ojb/
Date Thu, 28 Jul 2005 05:42:51 GMT
Author: clombart
Date: Wed Jul 27 22:42:43 2005
New Revision: 225702

URL: http://svn.apache.org/viewcvs?rev=225702&view=rev
Log:
Review object model (see GRFT-25)

Modified:
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/ContentStore.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/AbstractGraffitoStore.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/fs/FileSystemContentStore.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureArrayList.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureIterator.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/SpringOjbFactory.java

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/ContentStore.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/ContentStore.java?rev=225702&r1=225701&r2=225702&view=diff
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/ContentStore.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/ContentStore.java Wed Jul 27 22:42:43 2005
@@ -1,191 +1,192 @@
-/*
- * 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.store;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.portals.graffito.persistence.ContentPersistenceException;
-import org.apache.portals.graffito.exception.CmsPermissionException;
-import org.apache.portals.graffito.model.CmsObject;
-import org.apache.portals.graffito.model.Document;
-import org.apache.portals.graffito.model.HistoryElement;
-import org.apache.portals.graffito.search.Filter;
-
-
-/**
- * Graffito content store.
- * 
- * This interface can be used to plug any content server into Graffito. 
- *
- * Depending on the content server type, the implementation has to manage the permissions.
- * 
- */
-public interface ContentStore
-{
-    
-    /**
-     * Get a cms object
-     * @param uri The cms object uri
-     * @return The cms object found or null  
-     * @throws CmsPermissionException when the user has not suffisiant privileges  
-     */
-    public CmsObject getCmsObject(String uri) throws CmsPermissionException ;
-    
-    /**
-     * Get cms object childen found in a folder.
-     * @param parentUri The parent folder uri from which the cms objects have to be retrieved
-     * @throws CmsPermissionException when the user has not suffisiant privileges  
-     * 
-     * @return a collection of cms object found
-     */
-    public Collection getChildren(String parentUri) throws CmsPermissionException ;
-
-    /**
-     * Get folders found in a parent folder.
-     * @param parentUri The parent folder uri from which the folders have to be retrieved
-     * @throws CmsPermissionException when the user has not suffisiant privileges  
-     * 
-     * @return a collection of folder children found
-     */
-    public Collection getFolders(String parentUri) throws CmsPermissionException ;  
-
-    /**
-     * Get documents found in a parent folder.
-     * @param parentUri The parent folder uri from which the documents have to be retrieved
-     * @throws CmsPermissionException when the user has not suffisiant privileges  
-     * 
-     * @return a collection of document children found
-     */
-    public Collection getDocuments(String parentUri) throws CmsPermissionException ;  
-
-    /**
-     * Get links found in a parent folder.
-     * @param parentUri The parent folder uri from which the links have to be retrieved
-     * @throws CmsPermissionException when the user has not suffisiant privileges  
-     * 
-     * @return a collection of link children found
-     */
-    public Collection getLinks(String parentUri) throws CmsPermissionException ;  
-    
-    /**
-     * Add a new history element
-     * 
-     * @param historyElement
-     * @throws ContentPersistenceException when it is not possible to insert the object
-     * @throws CmsPermissionException when the user has not suffisiant privileges
-     */
-    public void insertHistoryElement(HistoryElement historyElement) throws ContentPersistenceException, CmsPermissionException ;
-    
-    
-    /**
-     * Get the version history element defined from a Document. From this history element, it is possible to find previous version history element by calling {@link HistoryElement#getPrevious()} 
-     * @param document The document for which the version history has be found
-     * @return The History element found
-     * 
-     * @throws CmsPermissionException when the user has not suffisiant privileges
-     */
-    public HistoryElement getHistory(Document document) throws CmsPermissionException;
-    
-    
-    /**
-     * Instantiate a new empty filter object
-     * @return the instantiated filter object
-     */
-    public Filter newFilter();
-    
-
-    /**
-     * Get an object matching to a query
-     * @param clazz The class on which the query has to be exexuted
-     * @param filter The filter used by the query 
-     * @return The object found or null
-     * @throws CmsPermissionException when the user has not suffisiant privileges 
-     */
-    public Object getObjectByQuery(Class clazz, Filter filter) throws CmsPermissionException ;
-        
-    /**
-     * Get collection of object matching to a query 
-     * @param clazz The class on which the query has to be exexuted
-     * @param filter The filter used by the query 
-     * @return a collection of {@link CmsObject} 
-     * 
-     * @throws CmsPermissionException when the user has not suffisiant privileges  
-     */
-    public Collection getCollectionByQuery(Class clazz, Filter filter) throws CmsPermissionException ;;
-
-    
-    /**
-     * Get an iterator of object matching to a query    
-     * @param clazz The class on which the query has to be exexuted
-     * @param filter The filter used by the query 
-     * @return an iterator of of {@link CmsObject} 
-     * 
-     * @throws CmsPermissionException when the user has not suffisiant privileges  
-     */
-    public Iterator getIteratorByQuery(Class clazz, Filter filter) throws CmsPermissionException ;;
-    
-    /**
-     * Delete any kind of object (CmsObject, Server, HistoryElement,  ...)
-     * @param object The object to delete
-     * @throws ContentPersistenceException when it is not possible to delete the object
-     * @throws CmsPermissionException when the user has not suffisiant privileges 
-     */
-    public void delete(Object object) throws ContentPersistenceException, CmsPermissionException;
-
-    /**
-     * Delete all object matching to a query 
-     * @param clazz The class on which the query has to be exexuted
-     * @param filter The filter used by the query 
-     * @throws ContentPersistenceException when it is not possible to delete the objects
-     * @throws CmsPermissionException when the user has not suffisiant privileges 
-     */
-    public void deleteAll(Class clazz, Filter filter) throws ContentPersistenceException, CmsPermissionException;
-
-    /**
-     * Insert a new object in the content store
-     * @param object The object to insert
-     * @throws ContentPersistenceException when it is not possible to insert the object
-     * @throws CmsPermissionException when the user has not suffisiant privileges 
-     */
-    public void insert(Object object) throws ContentPersistenceException, CmsPermissionException;
-
-    /**
-     * Update a new object in the content store
-     * @param object The object to update
-     * @throws ContentPersistenceException when it is not possible to update the object
-     * @throws CmsPermissionException when the user has not suffisiant privileges 
-     */
-    public void update(Object object) throws ContentPersistenceException, CmsPermissionException;
-    
-    /**
-     * Check if the connection to this store is closed
-     * @return true if the connection is close
-     */
-    public boolean isClosed();
-    
-    /**
-     * Close the connection to this store
-     */
-    public void close();
-    
-    /**
-     * Get the content store scope
-     * @return the content store scope
-     */
-    public String getScope();
-    
-}
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.store;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.portals.graffito.exception.CmsPermissionException;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.model.core.HistoryElement;
+import org.apache.portals.graffito.model.core.VersionnedContent;
+import org.apache.portals.graffito.persistence.ContentPersistenceException;
+import org.apache.portals.graffito.services.search.Filter;
+
+
+/**
+ * Graffito content store.
+ * 
+ * This interface can be used to plug any kind of  content server into Graffito. 
+ *
+ * Depending on the content server type, the implementation has to manage the permissions.
+ * 
+ */
+public interface ContentStore
+{
+    
+    /**
+     * Get a cms object
+     * @param uri The cms object uri
+     * @return The cms object found or null  
+     * @throws CmsPermissionException when the user has not suffisiant privileges  
+     */
+    public CmsObject getCmsObject(String uri) throws CmsPermissionException ;
+    
+    /**
+     * Get cms object childen found in a folder.
+     * @param parentUri The parent folder uri from which the cms objects have to be retrieved
+     * @throws CmsPermissionException when the user has not suffisiant privileges  
+     * 
+     * @return a collection of cms object found
+     */
+    public Collection getChildren(String parentUri) throws CmsPermissionException ;
+
+    /**
+     * Get folders found in a parent folder.
+     * @param parentUri The parent folder uri from which the folders have to be retrieved
+     * @throws CmsPermissionException when the user has not suffisiant privileges  
+     * 
+     * @return a collection of folder children found
+     */
+    public Collection getFolders(String parentUri) throws CmsPermissionException ;  
+
+    /**
+     * Get contents found in a parent folder.
+     * @param parentUri The parent folder uri from which the contents have to be retrieved
+     * @return a collection of content children found
+     * @throws CmsPermissionException when the user has not suffisiant privileges  
+     */
+
+    public Collection getContents(String parentUri) throws CmsPermissionException ;  
+
+    /**
+     * Get links found in a parent folder.
+     * @param parentUri The parent folder uri from which the links have to be retrieved
+     * @throws CmsPermissionException when the user has not suffisiant privileges  
+     * 
+     * @return a collection of link children found
+     */
+    public Collection getLinks(String parentUri) throws CmsPermissionException ;  
+    
+    /**
+     * Add a new history element
+     * 
+     * @param historyElement
+     * @throws ContentPersistenceException when it is not possible to insert the object
+     * @throws CmsPermissionException when the user has not suffisiant privileges
+     */
+    public void insertHistoryElement(HistoryElement historyElement) throws ContentPersistenceException, CmsPermissionException ;
+    
+    
+    /**
+     * Get the version history element defined from a content. From this history element, it is possible to find previous version history element by calling {@link HistoryElement#getPrevious()} 
+     * @param versionnedContent The versionned content for which the version history has be found
+     * @return The History element found
+     * 
+     * @throws CmsPermissionException when the user has not suffisiant privileges
+     */
+    public HistoryElement getHistory(VersionnedContent versionnedContent) throws CmsPermissionException;
+    
+    
+    /**
+     * Instantiate a new empty filter object
+     * @return the instantiated filter object
+     */
+    public Filter newFilter();
+    
+
+    /**
+     * Get an object matching to a query
+     * @param clazz The class on which the query has to be exexuted
+     * @param filter The filter used by the query 
+     * @return The object found or null
+     * @throws CmsPermissionException when the user has not suffisiant privileges 
+     */
+    public Object getObjectByQuery(Class clazz, Filter filter) throws CmsPermissionException ;
+        
+    /**
+     * Get collection of object matching to a query 
+     * @param clazz The class on which the query has to be exexuted
+     * @param filter The filter used by the query 
+     * @return a collection of {@link CmsObject} 
+     * 
+     * @throws CmsPermissionException when the user has not suffisiant privileges  
+     */
+    public Collection getCollectionByQuery(Class clazz, Filter filter) throws CmsPermissionException ;;
+
+    
+    /**
+     * Get an iterator of object matching to a query    
+     * @param clazz The class on which the query has to be exexuted
+     * @param filter The filter used by the query 
+     * @return an iterator of of {@link CmsObject} 
+     * 
+     * @throws CmsPermissionException when the user has not suffisiant privileges  
+     */
+    public Iterator getIteratorByQuery(Class clazz, Filter filter) throws CmsPermissionException ;;
+    
+    /**
+     * Delete any kind of object (CmsObject, Server, HistoryElement,  ...)
+     * @param object The object to delete
+     * @throws ContentPersistenceException when it is not possible to delete the object
+     * @throws CmsPermissionException when the user has not suffisiant privileges 
+     */
+    public void delete(Object object) throws ContentPersistenceException, CmsPermissionException;
+
+    /**
+     * Delete all object matching to a query 
+     * @param clazz The class on which the query has to be exexuted
+     * @param filter The filter used by the query 
+     * @throws ContentPersistenceException when it is not possible to delete the objects
+     * @throws CmsPermissionException when the user has not suffisiant privileges 
+     */
+    public void deleteAll(Class clazz, Filter filter) throws ContentPersistenceException, CmsPermissionException;
+
+    /**
+     * Insert a new object in the content store
+     * @param object The object to insert
+     * @throws ContentPersistenceException when it is not possible to insert the object
+     * @throws CmsPermissionException when the user has not suffisiant privileges 
+     */
+    public void insert(Object object) throws ContentPersistenceException, CmsPermissionException;
+
+    /**
+     * Update a new object in the content store
+     * @param object The object to update
+     * @throws ContentPersistenceException when it is not possible to update the object
+     * @throws CmsPermissionException when the user has not suffisiant privileges 
+     */
+    public void update(Object object) throws ContentPersistenceException, CmsPermissionException;
+    
+    /**
+     * Check if the connection to this store is closed
+     * @return true if the connection is close
+     */
+    public boolean isClosed();
+    
+    /**
+     * Close the connection to this store
+     */
+    public void close();
+    
+    /**
+     * Get the content store scope
+     * @return the content store scope
+     */
+    public String getScope();
+    
+}

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/AbstractGraffitoStore.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/AbstractGraffitoStore.java?rev=225702&r1=225701&r2=225702&view=diff
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/AbstractGraffitoStore.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/AbstractGraffitoStore.java Wed Jul 27 22:42:43 2005
@@ -18,8 +18,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.portals.graffito.exception.CmsInstantiateException;
-import org.apache.portals.graffito.model.Server;
+import org.apache.portals.graffito.model.server.Server;
 import org.apache.portals.graffito.security.CmsAccessController;
 import org.apache.portals.graffito.store.ContentStore;
 
@@ -43,16 +42,11 @@
     /**
      * Constructor based on the a server object.
      * 
-     * @param server
-     *            The server object contains all information to connect to this
-     *            content store
-     * @param cmsAccessController
-     *            The CmsAccesController used to check the permissions
-     *            
-     * @throws CmsInstantiateException
-     *             when it is not possible to instantiate this store
+     * @param server  The server object contains all information to connect to this content store
+     * @param cmsAccessController  The CmsAccesController used to check the permissions
+     *              
      */
-    public AbstractGraffitoStore(Server server, CmsAccessController cmsAccessController) throws CmsInstantiateException
+    public AbstractGraffitoStore(Server server, CmsAccessController cmsAccessController)
     {
         this.cmsAccessController = cmsAccessController;
 

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/fs/FileSystemContentStore.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/fs/FileSystemContentStore.java?rev=225702&r1=225701&r2=225702&view=diff
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/fs/FileSystemContentStore.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/fs/FileSystemContentStore.java Wed Jul 27 22:42:43 2005
@@ -18,17 +18,16 @@
 import java.util.Collection;
 import java.util.Iterator;
 
-
 import org.apache.portals.graffito.exception.CmsInstantiateException;
 import org.apache.portals.graffito.exception.CmsPermissionException;
-import org.apache.portals.graffito.model.CmsObject;
-import org.apache.portals.graffito.model.Document;
-import org.apache.portals.graffito.model.FileSystemServer;
-import org.apache.portals.graffito.model.HistoryElement;
-import org.apache.portals.graffito.model.Server;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.model.core.HistoryElement;
+import org.apache.portals.graffito.model.core.VersionnedContent;
+import org.apache.portals.graffito.model.server.FileSystemServer;
+import org.apache.portals.graffito.model.server.Server;
 import org.apache.portals.graffito.persistence.ContentPersistenceException;
-import org.apache.portals.graffito.search.Filter;
 import org.apache.portals.graffito.security.CmsAccessController;
+import org.apache.portals.graffito.services.search.Filter;
 import org.apache.portals.graffito.store.ContentStore;
 import org.apache.portals.graffito.store.impl.AbstractGraffitoStore;
 
@@ -115,16 +114,25 @@
 
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.portals.graffito.store.ContentStore#getHistory(org.apache.portals.graffito.model.Document)
+    
+    
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getContents(java.lang.String)
      */
-    public HistoryElement getHistory(Document document)
-            throws CmsPermissionException
+    public Collection getContents(String parentUri) throws CmsPermissionException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getHistory(org.apache.portals.graffito.model.core.VersionnedContent)
+     */
+    public HistoryElement getHistory(VersionnedContent versionnedContent) throws CmsPermissionException
     {
         // TODO Auto-generated method stub
         return null;
     }
-
     /* (non-Javadoc)
      * @see org.apache.portals.graffito.store.ContentStore#newFilter()
      */

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java?rev=225702&r1=225701&r2=225702&view=diff
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java Wed Jul 27 22:42:43 2005
@@ -1,497 +1,503 @@
-/*
- * 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.store.impl.ojb;
-
-import java.net.URL;
-
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-
-import org.apache.ojb.broker.PBKey;
-import org.apache.ojb.broker.PersistenceBroker;
-import org.apache.ojb.broker.metadata.ConnectionRepository;
-import org.apache.ojb.broker.metadata.DescriptorRepository;
-import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
-import org.apache.ojb.broker.metadata.MetadataException;
-import org.apache.ojb.broker.metadata.MetadataManager;
-import org.apache.ojb.broker.metadata.RepositoryPersistor;
-import org.apache.ojb.broker.query.Criteria;
-import org.apache.ojb.broker.query.Query;
-import org.apache.ojb.broker.query.QueryFactory;
-import org.apache.portals.graffito.model.impl.DocumentImpl;
-import org.apache.portals.graffito.model.impl.FolderImpl;
-import org.apache.portals.graffito.persistence.ContentPersistenceException;
-import org.apache.portals.graffito.search.impl.FilterImpl;
-import org.apache.portals.graffito.security.CmsAccessController;
-import org.apache.portals.graffito.store.ContentStore;
-import org.apache.portals.graffito.store.impl.AbstractGraffitoStore;
-import org.apache.portals.graffito.exception.CmsInstantiateException;
-import org.apache.portals.graffito.exception.CmsPermissionException;
-import org.apache.portals.graffito.model.CmsObject;
-import org.apache.portals.graffito.model.CmsPermission;
-import org.apache.portals.graffito.model.Document;
-import org.apache.portals.graffito.model.Link;
-import org.apache.portals.graffito.model.Folder;
-import org.apache.portals.graffito.model.HistoryElement;
-import org.apache.portals.graffito.model.GraffitoServer;
-import org.apache.portals.graffito.model.Server;
-import org.apache.portals.graffito.search.Filter;
-/**
- * 
- * Implementation for an OJB (Persistence Broker) Store
- * 
- *  
- */
-public class GraffitoOJBStore extends AbstractGraffitoStore implements ContentStore
-{
-    
-    private OjbFactory ojbFactory;
-    private PBKey pbKey;
-
-    /**
-     * Constructor based on the a server object.
-     * 
-     * @param server
-     *            The server object contains all information to connect to this
-     *            content store
-     * @param cmsAccessController
-     *            The CmsAccesController used to check the permissions
-     *            
-     * @throws CmsInstantiateException
-     *             when it is not possible to instantiate this store
-     */
-    public GraffitoOJBStore(Server server, CmsAccessController cmsAccessController) throws CmsInstantiateException
-    {
-        super(server, cmsAccessController);
-
-        // TODO : replace the following lines.
-        // * OjbSecureArrayList is an OJB Managable collection used to check the
-        // permissions when the method pb.getCollectionByQuery is called
-        // * OjbSecureIterator is a secure iterator used by this store in order
-        // to filter cms object
-        OjbSecureArrayList.setCmsAccessController(cmsAccessController);
-        OjbSecureIterator.setCmsAccessController(cmsAccessController);
-
-        GraffitoServer graffitoServer = (GraffitoServer) server;
-        try
-        {
-
-            ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
-            // check if the server alias is already registred in the OJB
-            // repository
-            this.scope = server.getScope();
-            pbKey = cr.getStandardPBKeyForJcdAlias(server.getAlias());
-            if (pbKey == null)
-            {
-
-                JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor();
-                // Use the datasource if defined
-                if ((graffitoServer.getDatasource() != null) && (!graffitoServer.getDatasource().equals("")))
-                {
-                    jcd.setDatasourceName(graffitoServer.getDatasource());
-                }
-                else
-                {
-                    jcd.setUserName(graffitoServer.getLogin());
-                    jcd.setPassWord(graffitoServer.getPassword());
-                }
-
-                jcd.setJcdAlias(graffitoServer.getAlias());
-                jcd.setDbAlias(graffitoServer.getDbAlias());
-                jcd.setDbms(graffitoServer.getPlateform());
-                jcd.setDriver(graffitoServer.getDriver());
-                jcd.setJdbcLevel(graffitoServer.getJdbcLevel());
-                jcd.setProtocol(graffitoServer.getProtocol());
-                jcd.setSubProtocol(graffitoServer.getSubProtocol());
-
-                // Add new descriptor
-                cr.addDescriptor(jcd);
-                pbKey = new PBKey(server.getAlias(), graffitoServer.getLogin(), graffitoServer.getPassword());
-            }
-            mergeRepository();
-        }
-        catch (MetadataException e)
-        {
-            // if the connection already exist
-            log.error("An error occurs when building a Graffito : " + server.getAlias(), e);
-            throw new CmsInstantiateException("An error occurs when building a GraffitoStore : "
-                    + server.getAlias(), e);
-        }
-
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getCmsObject(String)
-     */
-    public CmsObject getCmsObject(String uri) throws CmsPermissionException
-    {
-        if (!cmsAccessController.hasPermission(uri, CmsPermission.VIEW))
-        {
-            throw new CmsPermissionException("Not sufficient permission to get the cms object : " + uri);
-        }
-        Criteria criteria = new Criteria();
-        criteria.addEqualTo("uri", uri);
-        Query query = QueryFactory.newQuery(CmsObject.class, criteria);
-        CmsObject cmsObject = (CmsObject) getBroker().getObjectByQuery(query);
-        return cmsObject;
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getChildren(java.lang.String)
-     */
-    public Collection getChildren(String parentUri)  throws CmsPermissionException 
-    {
-        Filter filter = this.newFilter();
-        
-        // Check if the parenturi is the root store uri
-        if (this.scope.equals(parentUri))
-        {           
-            filter.addIsNull("parentId");
-        }
-        else
-        {                 
-            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
-            filter.addEqualTo("parentId", folder.getObjectId());
-        }
-
-        Collection c = this.getCollectionByQuery(CmsObject.class, filter);
-        
-        return c;
-        
-
-    }
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.store.ContentStore#getLinks(java.lang.String)
-     */
-    public Collection getLinks(String parentUri) throws CmsPermissionException 
-    {
-        Filter filter = this.newFilter();
-
-        // Check if the parenturi is the root store uri
-        if (this.scope.equals(parentUri))
-        {
-            filter.addIsNull("parentId");
-        }
-        else
-        {
-            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
-            filter.addEqualTo("parentId", folder.getObjectId());
-        }
-
-        return this.getCollectionByQuery(Link.class, filter);
-    }
-    
-    
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getDocuments(java.lang.String)
-     */
-    public Collection getDocuments(String parentUri) throws CmsPermissionException 
-    {
-        Filter filter = this.newFilter();
-
-        // Check if the parenturi is the root store uri
-        if (this.scope.equals(parentUri))
-        {
-            filter.addIsNull("parentId");
-        }
-        else
-        {
-            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
-            filter.addEqualTo("parentId", folder.getObjectId());
-        }
-
-        return this.getCollectionByQuery(Document.class, filter);
-    }
-    
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getFolders(java.lang.String)
-     */
-    public Collection getFolders(String parentUri) throws CmsPermissionException 
-    {
-        Filter filter = this.newFilter();
-
-        // Check if the parenturi is the root store uri
-        if (this.scope.equals(parentUri))
-        {
-            filter.addIsNull("parentId");
-        }
-        else
-        {
-            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
-            filter.addEqualTo("parentId", folder.getObjectId());
-        }
-
-        return this.getCollectionByQuery(Folder.class, filter);
-    }
-    
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getHistory(org.apache.portals.graffito.model.Document)
-     */
-    public HistoryElement getHistory(Document document) throws CmsPermissionException
-    {
-        // Find the first element in the history
-        Filter filter = this.newFilter();
-        filter.setScope(document.getUri());
-        filter.addEqualTo("documentId", ((DocumentImpl) document).getObjectId());
-        HistoryElement historyElement = (HistoryElement) this.getObjectByQuery(HistoryElement.class, filter);
-        return historyElement;
-
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#insertHistoryElement(org.apache.portals.graffito.model.HistoryElement)
-     */
-    public void insertHistoryElement(HistoryElement historyElement) throws ContentPersistenceException,
-            CmsPermissionException
-    {
-        this.insert(historyElement);
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#newFilter()
-     */
-    public Filter newFilter()
-    {
-        Filter filter = new FilterImpl();
-        return filter;
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getObjectByQuery(Class,
-     *      Filter)
-     */
-    public Object getObjectByQuery(Class clazz, Filter filter) throws CmsPermissionException
-    {
-        Query query = this.convert2Query(clazz, filter);
-        Object object = getBroker().getObjectByQuery(query);
-        if (!cmsAccessController.hasPermission(object, CmsPermission.VIEW))
-        {
-            throw new CmsPermissionException("Not sufficient permission to get the object by query");
-        }
-        return object;
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getCollectionByQuery(Class,
-     *      Filter)
-     */
-    public Collection getCollectionByQuery(Class clazz, Filter filter)
-    {
-
-        Query query = this.convert2Query(clazz, filter);
-        OjbSecureArrayList result = (OjbSecureArrayList) getBroker().getCollectionByQuery(
-                OjbSecureArrayList.class, query);
-        return result;
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getIteratorByQuery(Class,
-     *      Filter)
-     */
-    public Iterator getIteratorByQuery(Class clazz, Filter filter)
-    {
-        Query query = this.convert2Query(clazz, filter);
-        Iterator iterator = getBroker().getIteratorByQuery(query);
-        return new OjbSecureIterator(iterator);
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#delete(Object)
-     */
-    public void delete(Object object) throws ContentPersistenceException, CmsPermissionException
-    {
-
-        try
-        {
-            if (!cmsAccessController.hasPermission(object, CmsPermission.DELETE))
-            {
-                throw new CmsPermissionException("Not sufficient permission to delete the object");
-            }
-            getBroker().delete(object);
-        }
-        catch (Exception e)
-        {
-            throw new ContentPersistenceException(e);
-        }
-
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#deleteAll(Class, Filter)
-     */
-    public void deleteAll(Class clazz, Filter filter) throws ContentPersistenceException,
-            CmsPermissionException
-    {
-        try
-        {
-
-            // Convert Graffito filter object into OJB criteria
-            Criteria criteria = ((FilterImpl) filter).getCriteria();
-
-            Query query = QueryFactory.newQuery(clazz, criteria);
-
-            Collection deletes = getBroker().getCollectionByQuery(query);
-            Iterator itr = deletes.iterator();
-            while (itr.hasNext())
-            {
-                Object object = itr.next();
-                if (!cmsAccessController.hasPermission(object, CmsPermission.DELETE))
-                {
-                    throw new CmsPermissionException("Not sufficient permission to delete the object");
-                }
-                getBroker().delete(object);
-            }
-        }
-        catch (Exception e)
-        {
-            throw new ContentPersistenceException(e);
-        }
-
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#insert(java.lang.Object)
-     */
-    public void insert(Object object) throws ContentPersistenceException, CmsPermissionException
-    {
-        if (!cmsAccessController.hasPermission(object, CmsPermission.INSERT))
-        {
-            throw new CmsPermissionException("Not sufficient permission to insert the object");
-        }
-        this.store(object);
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#update(java.lang.Object)
-     */
-    public void update(Object object) throws ContentPersistenceException, CmsPermissionException
-    {
-        if (!cmsAccessController.hasPermission(object, CmsPermission.UPDATE))
-        {
-            throw new CmsPermissionException("Not sufficient permission to update the object");
-        }
-        this.store(object);
-    }
-
-    private void store(Object object) throws ContentPersistenceException
-    {
-        try
-        {
-            getBroker().store(object);
-
-        }
-        catch (Exception e)
-        {
-            throw new ContentPersistenceException(e);
-        }
-
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#isClosed()
-     */
-    public boolean isClosed()
-    {
-        return getBroker().isClosed();
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#close()
-     */
-    public void close()
-    {
-        getBroker().close();
-        ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
-        cr.removeDescriptor(pbKey);
-    }
-
-    /**
-     * @see org.apache.portals.graffito.store.ContentStore#getScope()
-     */
-    public String getScope()
-    {
-        return this.scope;
-    }
-    
-    private PersistenceBroker getBroker()
-    {
-
-        PersistenceBroker broker = ojbFactory.getPersistenceBroker(this.pbKey, true);
-        return broker;
-    }
-
-    private void mergeRepository()
-    {
-        URL descriptorUrl = null;
-        try
-        {
-            MetadataManager metaManager = MetadataManager.getInstance();
-            RepositoryPersistor persistor = new RepositoryPersistor();
-            Enumeration descriptors = getClass().getClassLoader()
-                    .getResources("META-INF/repository_graffito.xml");
-            while (descriptors.hasMoreElements())
-            {
-                descriptorUrl = (URL) descriptors.nextElement();
-                log.info("Merging OJB respository: " + descriptorUrl);
-                DescriptorRepository repo = persistor.readDescriptorRepository(descriptorUrl.openStream());
-                metaManager.mergeDescriptorRepository(repo);
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            log.warn("Impossible to merge descriptor : " + descriptorUrl);
-        }
-    }
-
-    /**
-     * Convert Graffito filter object into OJB query object
-     * 
-     * @param filter
-     *            The Graffito filter object to convert
-     * @param clazz
-     *            The class on which the query has to be executed
-     * @return The OJB query
-     */
-    private Query convert2Query(Class clazz, Filter filter)
-    {
-        Criteria criteria = ((FilterImpl) filter).getCriteria();
-        String filterScope = filter.getScope();
-        // if the class is a CmsObject, check the filter scope is defined in
-        // order to limit the search on this one
-        if (clazz.equals(CmsObject.class) && filterScope != null && !filterScope.equals(""))
-        {
-            criteria.addLike("uri", filterScope + "%");
-        }
-        Query query = QueryFactory.newQuery(clazz, criteria);
-        return query;
-
-    }
-
-    /**
-     * Initialise the Ojb factory to use with this PB content store.
-     * 
-     * @param ojbFactory
-     *            The ojbFactory to set.
-     */
-    public void setOjbFactory(OjbFactory ojbFactory)
-    {
-        this.ojbFactory = ojbFactory;
-    }
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.store.impl.ojb;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+
+import org.apache.ojb.broker.PBKey;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.metadata.ConnectionRepository;
+import org.apache.ojb.broker.metadata.DescriptorRepository;
+import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
+import org.apache.ojb.broker.metadata.MetadataException;
+import org.apache.ojb.broker.metadata.MetadataManager;
+import org.apache.ojb.broker.metadata.RepositoryPersistor;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.Query;
+import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.portals.graffito.exception.CmsInstantiateException;
+import org.apache.portals.graffito.exception.CmsPermissionException;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.model.core.Content;
+import org.apache.portals.graffito.model.core.Folder;
+import org.apache.portals.graffito.model.core.HistoryElement;
+import org.apache.portals.graffito.model.core.Link;
+import org.apache.portals.graffito.model.core.VersionnedContent;
+import org.apache.portals.graffito.model.core.impl.FolderImpl;
+import org.apache.portals.graffito.model.core.impl.VersionnedContentImpl;
+import org.apache.portals.graffito.model.permission.CmsPermission;
+import org.apache.portals.graffito.model.server.GraffitoServer;
+import org.apache.portals.graffito.model.server.Server;
+import org.apache.portals.graffito.persistence.ContentPersistenceException;
+import org.apache.portals.graffito.security.CmsAccessController;
+import org.apache.portals.graffito.services.search.Filter;
+import org.apache.portals.graffito.services.search.impl.FilterImpl;
+import org.apache.portals.graffito.store.ContentStore;
+import org.apache.portals.graffito.store.impl.AbstractGraffitoStore;
+
+/**
+ * 
+ * Implementation for an OJB (Persistence Broker) Store
+ * 
+ *  
+ */
+public class GraffitoOJBStore extends AbstractGraffitoStore implements ContentStore
+{
+    
+    private OjbFactory ojbFactory;
+    private PBKey pbKey;
+
+    /**
+     * Constructor based on the a server object.
+     * 
+     * @param server
+     *            The server object contains all information to connect to this
+     *            content store
+     * @param cmsAccessController
+     *            The CmsAccesController used to check the permissions
+     *            
+     * @throws CmsInstantiateException
+     *             when it is not possible to instantiate this store
+     */
+    public GraffitoOJBStore(Server server, CmsAccessController cmsAccessController) throws CmsInstantiateException
+    {
+        super(server, cmsAccessController);
+
+        // TODO : replace the following lines.
+        // * OjbSecureArrayList is an OJB Managable collection used to check the
+        // permissions when the method pb.getCollectionByQuery is called
+        // * OjbSecureIterator is a secure iterator used by this store in order
+        // to filter cms object
+        OjbSecureArrayList.setCmsAccessController(cmsAccessController);
+        OjbSecureIterator.setCmsAccessController(cmsAccessController);
+
+        GraffitoServer graffitoServer = (GraffitoServer) server;
+        try
+        {
+
+            ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
+            // check if the server alias is already registred in the OJB
+            // repository
+            this.scope = server.getScope();
+            pbKey = cr.getStandardPBKeyForJcdAlias(server.getAlias());
+            if (pbKey == null)
+            {
+
+                JdbcConnectionDescriptor jcd = new JdbcConnectionDescriptor();
+                // Use the datasource if defined
+                if ((graffitoServer.getDatasource() != null) && (!graffitoServer.getDatasource().equals("")))
+                {
+                    jcd.setDatasourceName(graffitoServer.getDatasource());
+                }
+                else
+                {
+                    jcd.setUserName(graffitoServer.getLogin());
+                    jcd.setPassWord(graffitoServer.getPassword());
+                }
+
+                jcd.setJcdAlias(graffitoServer.getAlias());
+                jcd.setDbAlias(graffitoServer.getDbAlias());
+                jcd.setDbms(graffitoServer.getPlateform());
+                jcd.setDriver(graffitoServer.getDriver());
+                jcd.setJdbcLevel(graffitoServer.getJdbcLevel());
+                jcd.setProtocol(graffitoServer.getProtocol());
+                jcd.setSubProtocol(graffitoServer.getSubProtocol());
+
+                // Add new descriptor
+                cr.addDescriptor(jcd);
+                pbKey = new PBKey(server.getAlias(), graffitoServer.getLogin(), graffitoServer.getPassword());
+            }
+            mergeRepository();
+        }
+        catch (MetadataException e)
+        {
+            // if the connection already exist
+            log.error("An error occurs when building a Graffito : " + server.getAlias(), e);
+            throw new CmsInstantiateException("An error occurs when building a GraffitoStore : "
+                    + server.getAlias(), e);
+        }
+
+    }
+
+ /**
+     * @see org.apache.portals.graffito.store.ContentStore#getCmsObject(String)
+     */
+    public CmsObject getCmsObject(String uri) throws CmsPermissionException
+    {
+        if (!cmsAccessController.hasPermission(uri, CmsPermission.VIEW))
+        {
+            throw new CmsPermissionException("Not sufficient permission to get the cms object : " + uri);
+        }
+        Criteria criteria = new Criteria();
+        criteria.addEqualTo("uri", uri);
+        Query query = QueryFactory.newQuery(CmsObject.class, criteria);
+        CmsObject cmsObject = (CmsObject) getBroker().getObjectByQuery(query);
+        return cmsObject;
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getChildren(java.lang.String)
+     */
+    public Collection getChildren(String parentUri)  throws CmsPermissionException 
+    {
+        Filter filter = this.newFilter();
+        
+        // Check if the parenturi is the root store uri
+        if (this.scope.equals(parentUri))
+        {           
+            filter.addIsNull("parentId");
+        }
+        else
+        {                 
+            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
+            filter.addEqualTo("parentId", folder.getObjectId());
+        }
+
+        Collection c = this.getCollectionByQuery(CmsObject.class, filter);
+        
+        return c;
+        
+
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.store.ContentStore#getLinks(java.lang.String)
+     */
+    public Collection getLinks(String parentUri) throws CmsPermissionException 
+    {
+        Filter filter = this.newFilter();
+
+        // Check if the parenturi is the root store uri
+        if (this.scope.equals(parentUri))
+        {
+            filter.addIsNull("parentId");
+        }
+        else
+        {
+            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
+            filter.addEqualTo("parentId", folder.getObjectId());
+        }
+
+        return this.getCollectionByQuery(Link.class, filter);
+    }
+    
+    
+ /**
+     * @see org.apache.portals.graffito.store.ContentStore#getContents(java.lang.String)
+     */
+
+    public Collection getContents(String parentUri) throws CmsPermissionException 
+    {
+        Filter filter = this.newFilter();
+
+        // Check if the parenturi is the root store uri
+        if (this.scope.equals(parentUri))
+        {
+            filter.addIsNull("parentId");
+        }
+        else
+        {
+            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
+            filter.addEqualTo("parentId", folder.getObjectId());
+        }
+
+        return this.getCollectionByQuery(Content.class, filter);
+    }
+    
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getFolders(java.lang.String)
+     */
+    public Collection getFolders(String parentUri) throws CmsPermissionException 
+    {
+        Filter filter = this.newFilter();
+
+        // Check if the parenturi is the root store uri
+        if (this.scope.equals(parentUri))
+        {
+            filter.addIsNull("parentId");
+        }
+        else
+        {
+            FolderImpl folder = (FolderImpl) this.getCmsObject(parentUri);
+            filter.addEqualTo("parentId", folder.getObjectId());
+        }
+
+        return this.getCollectionByQuery(Folder.class, filter);
+    }
+    
+ 
+    /**
+     * 
+     * @see org.apache.portals.graffito.store.ContentStore#getHistory(org.apache.portals.graffito.model.core.VersionnedContent)
+     */
+    public HistoryElement getHistory(VersionnedContent content) throws CmsPermissionException
+    {
+        // Find the first element in the history
+        Filter filter = this.newFilter();
+        filter.setScope(content.getUri());
+        filter.addEqualTo("versionnedContentId", ((VersionnedContentImpl) content).getObjectId());
+        HistoryElement historyElement = (HistoryElement) this.getObjectByQuery(HistoryElement.class, filter);
+        return historyElement;
+
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.store.ContentStore#insertHistoryElement(org.apache.portals.graffito.model.core.HistoryElement)
+     */
+    public void insertHistoryElement(HistoryElement historyElement) throws ContentPersistenceException, CmsPermissionException
+    {
+        this.insert(historyElement);
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#newFilter()
+     */
+    public Filter newFilter()
+    {
+        Filter filter = new FilterImpl();
+        return filter;
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getObjectByQuery(Class,
+     *      Filter)
+     */
+    public Object getObjectByQuery(Class clazz, Filter filter) throws CmsPermissionException
+    {
+        Query query = this.convert2Query(clazz, filter);
+        Object object = getBroker().getObjectByQuery(query);
+        if (!cmsAccessController.hasPermission(object, CmsPermission.VIEW))
+        {
+            throw new CmsPermissionException("Not sufficient permission to get the object by query");
+        }
+        return object;
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getCollectionByQuery(Class,
+     *      Filter)
+     */
+    public Collection getCollectionByQuery(Class clazz, Filter filter)
+    {
+
+        Query query = this.convert2Query(clazz, filter);
+        OjbSecureArrayList result = (OjbSecureArrayList) getBroker().getCollectionByQuery(
+                OjbSecureArrayList.class, query);
+        return result;
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getIteratorByQuery(Class,
+     *      Filter)
+     */
+    public Iterator getIteratorByQuery(Class clazz, Filter filter)
+    {
+        Query query = this.convert2Query(clazz, filter);
+        Iterator iterator = getBroker().getIteratorByQuery(query);
+        return new OjbSecureIterator(iterator);
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#delete(Object)
+     */
+    public void delete(Object object) throws ContentPersistenceException, CmsPermissionException
+    {
+
+        try
+        {
+            if (!cmsAccessController.hasPermission(object, CmsPermission.DELETE))
+            {
+                throw new CmsPermissionException("Not sufficient permission to delete the object");
+            }
+            getBroker().delete(object);
+        }
+        catch (Exception e)
+        {
+            throw new ContentPersistenceException(e);
+        }
+
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#deleteAll(Class, Filter)
+     */
+    public void deleteAll(Class clazz, Filter filter) throws ContentPersistenceException,
+            CmsPermissionException
+    {
+        try
+        {
+
+            // Convert Graffito filter object into OJB criteria
+            Criteria criteria = ((FilterImpl) filter).getCriteria();
+
+            Query query = QueryFactory.newQuery(clazz, criteria);
+
+            Collection deletes = getBroker().getCollectionByQuery(query);
+            Iterator itr = deletes.iterator();
+            while (itr.hasNext())
+            {
+                Object object = itr.next();
+                if (!cmsAccessController.hasPermission(object, CmsPermission.DELETE))
+                {
+                    throw new CmsPermissionException("Not sufficient permission to delete the object");
+                }
+                getBroker().delete(object);
+            }
+        }
+        catch (Exception e)
+        {
+            throw new ContentPersistenceException(e);
+        }
+
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#insert(java.lang.Object)
+     */
+    public void insert(Object object) throws ContentPersistenceException, CmsPermissionException
+    {
+        if (!cmsAccessController.hasPermission(object, CmsPermission.INSERT))
+        {
+            throw new CmsPermissionException("Not sufficient permission to insert the object");
+        }
+        this.store(object);
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#update(java.lang.Object)
+     */
+    public void update(Object object) throws ContentPersistenceException, CmsPermissionException
+    {
+        if (!cmsAccessController.hasPermission(object, CmsPermission.UPDATE))
+        {
+            throw new CmsPermissionException("Not sufficient permission to update the object");
+        }
+        this.store(object);
+    }
+
+    private void store(Object object) throws ContentPersistenceException
+    {
+        try
+        {
+            getBroker().store(object);
+
+        }
+        catch (Exception e)
+        {
+            throw new ContentPersistenceException(e);
+        }
+
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#isClosed()
+     */
+    public boolean isClosed()
+    {
+        return getBroker().isClosed();
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#close()
+     */
+    public void close()
+    {
+        getBroker().close();
+        ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
+        cr.removeDescriptor(pbKey);
+    }
+
+    /**
+     * @see org.apache.portals.graffito.store.ContentStore#getScope()
+     */
+    public String getScope()
+    {
+        return this.scope;
+    }
+    
+    private PersistenceBroker getBroker()
+    {
+
+        PersistenceBroker broker = ojbFactory.getPersistenceBroker(this.pbKey, true);
+        return broker;
+    }
+
+    private void mergeRepository()
+    {
+        URL descriptorUrl = null;
+        try
+        {
+            MetadataManager metaManager = MetadataManager.getInstance();
+            RepositoryPersistor persistor = new RepositoryPersistor();
+            Enumeration descriptors = getClass().getClassLoader()
+                    .getResources("META-INF/repository_graffito.xml");
+            while (descriptors.hasMoreElements())
+            {
+                descriptorUrl = (URL) descriptors.nextElement();
+                log.info("Merging OJB respository: " + descriptorUrl);
+                DescriptorRepository repo = persistor.readDescriptorRepository(descriptorUrl.openStream());
+                metaManager.mergeDescriptorRepository(repo);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            log.warn("Impossible to merge descriptor : " + descriptorUrl);
+        }
+    }
+
+    /**
+     * Convert Graffito filter object into OJB query object
+     * 
+     * @param filter
+     *            The Graffito filter object to convert
+     * @param clazz
+     *            The class on which the query has to be executed
+     * @return The OJB query
+     */
+    private Query convert2Query(Class clazz, Filter filter)
+    {
+        Criteria criteria = ((FilterImpl) filter).getCriteria();
+        String filterScope = filter.getScope();
+        // if the class is a CmsObject, check the filter scope is defined in
+        // order to limit the search on this one
+        if (clazz.equals(CmsObject.class) && filterScope != null && !filterScope.equals(""))
+        {
+            criteria.addLike("uri", filterScope + "%");
+        }
+        Query query = QueryFactory.newQuery(clazz, criteria);
+        return query;
+
+    }
+
+    /**
+     * Initialise the Ojb factory to use with this PB content store.
+     * 
+     * @param ojbFactory
+     *            The ojbFactory to set.
+     */
+    public void setOjbFactory(OjbFactory ojbFactory)
+    {
+        this.ojbFactory = ojbFactory;
+    }
 }

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureArrayList.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureArrayList.java?rev=225702&r1=225701&r2=225702&view=diff
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureArrayList.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureArrayList.java Wed Jul 27 22:42:43 2005
@@ -14,15 +14,14 @@
  */
 
 package org.apache.portals.graffito.store.impl.ojb;
+import java.util.ArrayList;
+import java.util.Iterator;
+
 import org.apache.ojb.broker.ManageableCollection;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.portals.graffito.model.CmsPermission;
+import org.apache.portals.graffito.model.permission.CmsPermission;
 import org.apache.portals.graffito.security.CmsAccessController;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
 
 /**
  * This class is used by GraffitoOJBStore (ojb implementation) in order to filter objects

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureIterator.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureIterator.java?rev=225702&r1=225701&r2=225702&view=diff
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureIterator.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbSecureIterator.java Wed Jul 27 22:42:43 2005
@@ -17,7 +17,7 @@
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-import org.apache.portals.graffito.model.CmsPermission;
+import org.apache.portals.graffito.model.permission.CmsPermission;
 import org.apache.portals.graffito.security.CmsAccessController;
 
 /**

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/SpringOjbFactory.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/SpringOjbFactory.java?rev=225702&r1=225701&r2=225702&view=diff
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/SpringOjbFactory.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/SpringOjbFactory.java Wed Jul 27 22:42:43 2005
@@ -20,7 +20,7 @@
 
 /**
  * Spring implementation for the OJB factory. 
- * This factory is managing the persistence broker instance per thread
+ * This factory is managing the persistenceService broker instance per thread
  *  
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe</a>
  * 



Mime
View raw message