incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r225704 [1/2] - in /incubator/graffito/trunk/components/src/java/org/apache/portals/graffito: services/ services/core/ services/core/impl/ services/dm/ services/dm/impl/ services/search/ services/search/impl/ store/impl/ojb/
Date Thu, 28 Jul 2005 05:43:59 GMT
Author: clombart
Date: Wed Jul 27 22:43:51 2005
New Revision: 225704

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

Added:
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/AbstractModelServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/BaseContentServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentModelServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentPermissionServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentServerServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentVersionServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/dm/
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/dm/impl/
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/dm/impl/DocumentModelServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentSearchServiceImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/FilterImpl.java
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/OjbCmsPropertyCollection.java

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/AbstractModelServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/AbstractModelServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/AbstractModelServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/AbstractModelServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,90 @@
+/*
+ * 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.services.core.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.exception.CmsInvalidObjectException;
+import org.apache.portals.graffito.exception.CmsInvalidUriException;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.util.UriUtil;
+
+
+
+/**
+ * Astract class for all model service (ContentModelService, DocumentModelService, ...).
+ *
+ * @version $Id:  Exp $
+ *
+ */
+public abstract class AbstractModelServiceImpl extends BaseContentServiceImpl
+{
+    protected final static Log logger = LogFactory.getLog(AbstractModelServiceImpl.class);
+
+    
+    /**
+     * @param persistenceService
+     */
+    public AbstractModelServiceImpl(ContentPersistenceService persistenceService)
+    {
+        super(persistenceService);
+       
+    }
+    /**
+     * Check if the cms object uri is correct
+     * @param uri The uri to validate
+     * 
+     * @throws CmsInvalidObjectException when the uri is not correct
+     */
+    protected void validateUri(String uri) throws CmsInvalidObjectException
+    {
+        // Check the cms object URI
+        if (! UriUtil.isValidUri(uri))
+        {
+            String message = "Failed to insert/update document object in ContentModelServiceImpl : incorrect Uri";
+            throw new CmsInvalidObjectException(message);             
+        }
+
+    }
+    
+    /**
+     * Check if the cms object parent folder is correct
+     * 
+     * @param cmsObject to validate
+     * @throws CmsInvalidUriException when the parent folder is not correct
+     */
+    protected void validateParentFolder(CmsObject cmsObject) throws CmsInvalidUriException
+    {
+        // If the object has not parent, end of validations
+        if (cmsObject.getParentFolder() == null)
+        {
+            return;
+        }
+
+        // Check if Cms object uri start with the parent uri path
+        String parentUri = UriUtil.getParentUri(cmsObject.getUri());        
+        if (! parentUri.equals(cmsObject.getParentFolder().getUri()))
+        {
+            String message = "Failed to insert/update document object in ContentModelServiceImpl : incorrect Parent Uri";
+            throw new CmsInvalidUriException(message);                    
+        }
+        
+    }  
+    
+
+}

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/BaseContentServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/BaseContentServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/BaseContentServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/BaseContentServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,102 @@
+/*
+ * 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.services.core.impl;
+
+import org.apache.portals.graffito.exception.CmsInvalidObjectException;
+import org.apache.portals.graffito.exception.CmsInvalidUriException;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.util.UriUtil;
+
+
+/**
+ * 
+ * Base class for all High level Graffito services : Model, Query, security, Version, ... . 
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ */
+public abstract class BaseContentServiceImpl
+{
+
+    protected ContentPersistenceService persistenceService;
+
+    /**
+     * Constructor : initialise with the persistenceService service
+     * 
+     * @param persistenceService The reference to the PersistenceService
+     */
+    public BaseContentServiceImpl(ContentPersistenceService persistenceService)
+    {
+        if (persistenceService == null)
+        {
+            throw new IllegalArgumentException("persistenceService cannot be null for BaseContentServiceImpl");
+        }
+        this.persistenceService = persistenceService;
+        
+    }
+
+    /**
+     * Check if the cms object uri is correct
+     * @param uri The uri to validate
+     * 
+     * @throws CmsInvalidObjectException when the uri is not correct
+     */
+    protected void validateUri(String uri) throws CmsInvalidObjectException
+    {
+        // Check the cms object URI
+        if (! UriUtil.isValidUri(uri))
+        {
+            String message = "Failed to insert/update document object in ContentModelServiceImpl : incorrect Uri";
+            throw new CmsInvalidObjectException(message);             
+        }
+
+    }
+    
+    /**
+     * Check if the cms object parent folder is correct
+     * 
+     * @param cmsObject to validate
+     * @throws CmsInvalidUriException when the parent folder is not correct
+     */
+    protected void validateParentFolder(CmsObject cmsObject) throws CmsInvalidUriException
+    {
+        // If the object has not parent, end of validations
+        if (cmsObject.getParentFolder() == null)
+        {
+            return;
+        }
+
+        // Check if Cms object uri start with the parent uri path
+        String parentUri = UriUtil.getParentUri(cmsObject.getUri());        
+        if (! parentUri.equals(cmsObject.getParentFolder().getUri()))
+        {
+            String message = "Failed to insert/update document object in ContentModelServiceImpl : incorrect Parent Uri";
+            throw new CmsInvalidUriException(message);                    
+        }
+        
+    }      
+
+    /**
+     * Get the persistenceService service 
+     * @return The persistenceService service.
+     */
+    protected ContentPersistenceService getPersistenceService()
+    {
+        return persistenceService;
+    }
+}

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentModelServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentModelServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentModelServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentModelServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,637 @@
+/*
+ * 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.services.core.impl;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.exception.CmsInstantiateException;
+import org.apache.portals.graffito.exception.ContentManagementException;
+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.dm.Document;
+import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.services.core.ContentModelService;
+import org.apache.portals.graffito.services.core.ContentVersionService;
+import org.apache.portals.graffito.util.UriUtil;
+
+
+
+/**
+ * Default implementation for {@link ContentModelService}.
+ *
+ * 
+ * @version $Id: ContentModelServiceImpl.java,v 1.1 2004/12/22 20:37:00 christophe Exp $
+ *
+ */
+public class ContentModelServiceImpl extends BaseContentServiceImpl implements ContentModelService
+{
+    protected final static Log logger = LogFactory.getLog(ContentModelServiceImpl.class);
+
+    private ContentVersionService contentVersionService;
+    /**
+     * 
+     * Constructor : initialise with the persistenceService service & the search service.
+     * 
+     * @param persistenceService The associated PersistenceService
+     * @param contentVersionService The associated version service
+     */
+    public ContentModelServiceImpl(ContentPersistenceService persistenceService, ContentVersionService contentVersionService)
+    {
+        super(persistenceService);        
+        this.contentVersionService = contentVersionService;
+    }    
+    
+    // ========================================================================
+    // F O L D E R
+    // ========================================================================
+
+    /**
+     *  @see ContentModelService#createFolder()
+     */
+    public Folder createFolder() throws ContentManagementException
+    {
+        Folder folder = null;
+        try
+        {
+            folder = (Folder) persistenceService.createObject(ContentPersistenceService.FOLDER);
+        }
+        catch (CmsInstantiateException e)
+        {
+            String message = "Failed to create folder object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+        return folder;
+    }
+
+    /**
+     *  @see ContentModelService#addFolder(Folder)
+     */
+    public void addFolder(Folder folder) throws ContentManagementException
+    {
+            this.validateUri(folder.getUri());
+            
+            // Check if the folder uri is already used
+            if (persistenceService.getCmsObject(folder.getUri()) != null )
+            {
+                throw new ContentManagementException("Impossible to add " + folder.getUri() + 
+                " - This uri is already used");                  
+            }
+
+            
+            // Check if the parent folder uri is correct
+            String parentUri = UriUtil.getParentUri(folder.getUri());
+            
+            //parentUri is null when the folder uri match to a server scope         
+            if (parentUri ==null)
+            {
+                throw new ContentManagementException("Impossible to add " + folder.getUri() + 
+                " - This uri doesn't match to a correct uri - no parent folder found");                 
+            }
+
+            // Refresh the parentFolder attribute in order to be conform to the folder uri
+            Folder parentFolder = this.getFolder(parentUri);
+            folder.setParentFolder(parentFolder);
+
+            persistenceService.insert(folder);
+    }
+
+    /**
+     *  @see ContentModelService#removeFolder(Folder)
+     */
+    public void removeFolder(Folder folder) throws ContentManagementException
+    {
+
+        try
+        {
+            persistenceService.delete(folder);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to remove folder object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    
+    /**
+     * 
+     * @see org.apache.portals.graffito.ContentModelService#removeAll(java.lang.String[])
+     */
+    public void removeAll(String[] uris) throws ContentManagementException
+    {
+        try
+        {
+            for (int i= 0; i< uris.length; i++)
+            {
+                persistenceService.delete(uris[i]);
+            }
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to remove cms objects in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+
+
+    }
+    /**
+     *  @see ContentModelService#getFolder(String)
+     */
+    public Folder getFolder(String uri) throws ContentManagementException
+    {
+
+        try
+        {
+            return (Folder) persistenceService.getCmsObject(uri);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get folder object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *  @see ContentModelService#updateFolder(Folder)
+     */
+    public void updateFolder(Folder folder) throws ContentManagementException
+    {
+
+        try
+        {
+            // Check if the document is valid - Throws CmsInvalidObjectException if it is invalid
+            this.validateUri(folder.getUri());
+            this.validateParentFolder(folder);
+            persistenceService.update(folder);
+
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to update folder object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    // ========================================================================
+    // L I N K S
+    // ========================================================================
+
+    /**
+     *  @see ContentModelService#createLink()
+     */
+    public Link createLink() throws ContentManagementException
+    {
+        Link link = null;
+        try
+        {
+
+            link = (Link) persistenceService.createObject(ContentPersistenceService.LINK);
+
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to create link object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+
+        }
+        return link;
+    }
+
+    /**
+     *  @see ContentModelService#addLink(Link)
+     */
+    public void addLink(Link link) throws ContentManagementException
+    {
+
+        try
+        {
+            this.validateUri(link.getUri());
+            
+            if (persistenceService.getCmsObject(link.getUri()) != null )
+            {
+                throw new ContentManagementException("Impossible to add " + link.getUri() + 
+                " - This uri is already used");                  
+            }
+            
+            persistenceService.insert(link);
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to add link object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+
+        }
+
+    }
+
+    /**
+     *  @see ContentModelService#getLink(String)
+     */
+    public Link getLink(String uri) throws ContentManagementException
+    {
+
+        try
+        {
+            return (Link) persistenceService.getCmsObject(uri);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get Link object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);            
+        }
+    }
+           
+
+    
+    /**
+     *  @see ContentModelService#removeLink(Link)
+     */
+    public void removeLink(Link link) throws ContentManagementException
+    {
+
+        try
+        {
+            persistenceService.delete(link);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to remove link object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+
+    }
+
+    
+    /**
+     *  @see ContentModelService#updateLink(Link)
+     */
+    public void updateLink(Link link) throws ContentManagementException
+    {
+
+        try
+        {
+            // Check if the link is valid - Throws CmsInvalidObjectException if it is invalid
+            this.validateUri(link.getUri());
+            this.validateParentFolder(link);
+            persistenceService.update(link);
+
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to update link object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+    
+    // ========================================================================
+    // C O N T E N T S
+    // ========================================================================
+    
+    /**
+     *  @see ContentModelService#addContent(org.apache.portals.graffito.model.core.Content)
+     */
+    public void addContent(Content content) throws ContentManagementException
+    {          
+            this.validateUri(content.getUri());
+            
+            // Check if the document uri is already used
+            if (persistenceService.getCmsObject(content.getUri()) != null )
+            {
+                throw new ContentManagementException("Impossible to add " + content.getUri() + 
+                " - This uri is already used");                  
+            }
+            
+            // Check if the parent folder uri is correct
+            String parentUri = UriUtil.getParentUri(content.getUri());
+            
+            //parentUri is null when the document uri match to a server scope         
+            if (parentUri ==null)
+            {
+                throw new ContentManagementException("Impossible to add " + content.getUri() + 
+                " - This uri doesn't match to a correct uri - no parent folder found");                 
+            } 
+            
+            Folder parentFolder = (Folder) persistenceService.getCmsObject(parentUri);
+
+            content.setParentFolder(parentFolder);
+
+            persistenceService.insert(content);
+            
+    }
+
+    /**
+     *  @see ContentModelService#createContent()
+     */
+    public Content createContent() throws ContentManagementException
+    {
+        return this.createContent(ContentPersistenceService.CONTENT);
+    }    
+
+    /**
+     *  @see ContentModelService#createContent(java.lang.String)
+     */
+    public Content createContent(String contentName) throws ContentManagementException
+    {
+        Content content = null;
+        try
+        {
+            content = (Content) persistenceService.createObject(contentName);
+        }
+        catch (CmsInstantiateException e)
+        {
+            String message = "Failed to create content object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+        return content;
+    }
+
+    /**
+     *  @see ContentModelService#getContent(java.lang.String)
+     */
+    public Content getContent(String uri) throws ContentManagementException
+    {
+
+        try
+        {
+            return (Content) persistenceService.getCmsObject(uri); 
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get content object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *  @see ContentModelService#removeContent(org.apache.portals.graffito.model.core.Content)
+     */
+    public void removeContent(Content content) throws ContentManagementException
+    {
+
+        try
+        {            
+            persistenceService.delete(content);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to remove content object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *  @see ContentModelService#updateContent(org.apache.portals.graffito.model.core.Content)
+     */
+    public void updateContent(Content content) throws ContentManagementException
+    {
+
+        try
+        {            
+            this.validateUri(content.getUri());
+            this.validateParentFolder(content);
+            persistenceService.update(content);
+
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to update versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    
+    // ========================================================================
+    // V E R S I O N N E D    C O N T E N T S
+    // ========================================================================
+    
+    /**
+     *  @see ContentModelService#addVersionnedContent(org.apache.portals.graffito.model.core.VersionnedContent)
+     */
+    public void addVersionnedContent(VersionnedContent content) throws ContentManagementException
+    {          
+            this.validateUri(content.getUri());
+            
+            // Check if the document uri is already used
+            if (persistenceService.getCmsObject(content.getUri()) != null )
+            {
+                throw new ContentManagementException("Impossible to add " + content.getUri() + 
+                " - This uri is already used");                  
+            }
+            
+            // Check if the parent folder uri is correct
+            String parentUri = UriUtil.getParentUri(content.getUri());
+            
+            //parentUri is null when the document uri match to a server scope         
+            if (parentUri ==null)
+            {
+                throw new ContentManagementException("Impossible to add " + content.getUri() + 
+                " - This uri doesn't match to a correct uri - no parent folder found");                 
+            } 
+            
+            Folder parentFolder = (Folder) persistenceService.getCmsObject(parentUri);
+
+            content.setParentFolder(parentFolder);
+
+            persistenceService.insert(content);
+            contentVersionService.addInHistory(content.getUri(), null, content);
+    }
+
+    /**
+     *  @see ContentModelService#createVersionnedContent()
+     */
+    
+    public VersionnedContent createVersionnedContent() throws ContentManagementException
+    {
+        return this.createVersionnedContent(ContentPersistenceService.VERSIONNED_CONTENT);
+    }
+    
+    /**
+     *  @see ContentModelService#createVersionnedContent(java.lang.String)
+     */
+    
+    public VersionnedContent createVersionnedContent(String contentName) throws ContentManagementException
+    {
+        VersionnedContent versionnedContent = null;
+        try
+        {
+            versionnedContent = (VersionnedContent) persistenceService.createObject(contentName);
+            // Init the version number
+            versionnedContent.setVersionNumber("1.0");
+        }
+        catch (CmsInstantiateException e)
+        {
+            String message = "Failed to create versionned content object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+        return versionnedContent;
+    }
+
+    /**
+     *  @see ContentModelService#getDocument(String uri)
+     */
+    public VersionnedContent getVersionnedContent(String uri) throws ContentManagementException
+    {
+
+        try
+        {
+            return (VersionnedContent) persistenceService.getCmsObject(uri, null); //null = lasted version
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *  @see ContentModelService#getDocument(String uri, String versionNumber)
+     */
+    public VersionnedContent getVersionnedContent(String uri, String versionNumber) throws ContentManagementException
+    {
+
+        try
+        {
+            return (VersionnedContent) persistenceService.getCmsObject(uri, versionNumber);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+    /**
+     *  @see ContentModelService#removeDocument(Document document)
+     */
+    public void removeVersionnedContent(VersionnedContent versionnedContent) throws ContentManagementException
+    {
+
+        try
+        {
+            HistoryElement historyElement = contentVersionService.getHistory(versionnedContent.getUri());
+            persistenceService.delete(historyElement);
+            persistenceService.delete(versionnedContent);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to remove versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *  @see ContentModelService#updateDocument(Document document)
+     */
+    public void updateVersionnedContent(VersionnedContent versionnedContent) throws ContentManagementException
+    {
+
+        try
+        {
+            // Check if the document is valid - Throws CmsInvalidObjectException if it is invalid
+            this.validateUri(versionnedContent.getUri());
+            this.validateParentFolder(versionnedContent);
+            persistenceService.update(versionnedContent);
+
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to update versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+    
+    /**
+     * @see org.apache.portals.graffito.ContentModelService#getChildren(org.apache.portals.graffito.model.Folder)
+     */
+    public Collection getChildren(Folder folder) throws ContentManagementException
+    {
+        return this.getChildren(folder.getUri());
+    }
+    
+    /**
+     * @see org.apache.portals.graffito.ContentModelService#getChildren(String)
+     */
+    public Collection getChildren(String parentUri) throws ContentManagementException
+    {
+        return persistenceService.getChildren(parentUri);
+    }
+    
+
+    /**
+     * @see org.apache.portals.graffito.ContentModelService#getDocuments(java.lang.String)
+     */
+    public Collection getContents(String parentUri) throws ContentManagementException
+    {
+        return persistenceService.getContents(parentUri);
+    }
+    
+    /**
+     * @see org.apache.portals.graffito.ContentModelService#getFolders(java.lang.String)
+     */
+    public Collection getFolders(String parentUri) throws ContentManagementException
+    {
+        return persistenceService.getFolders(parentUri);
+    }
+
+    /**
+     * @see org.apache.portals.graffito.ContentModelService#getLinks(java.lang.String)
+     */
+    public Collection getLinks(String parentUri) throws ContentManagementException
+    {
+        return persistenceService.getLinks(parentUri);
+    }
+    
+          
+    /**
+     * 
+     * @see org.apache.portals.graffito.ContentModelService#getCmsObject(java.lang.String)
+     */
+    public CmsObject getCmsObject(String uri) throws ContentManagementException
+    {
+        return persistenceService.getCmsObject(uri);
+    }
+}

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentPermissionServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentPermissionServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentPermissionServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentPermissionServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,220 @@
+/*
+ * 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.services.core.impl;
+
+import java.lang.reflect.Constructor;
+import java.security.Permission;
+import java.security.Permissions;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.apache.jetspeed.security.impl.PermissionManagerImpl;
+import org.apache.jetspeed.security.om.InternalPermission;
+import org.apache.jetspeed.security.om.InternalPrincipal;
+import org.apache.jetspeed.security.om.impl.InternalPermissionImpl;
+import org.apache.jetspeed.security.om.impl.InternalPrincipalImpl;
+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.ContentManagementException;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.model.pemission.impl.CmsPermissionImpl;
+import org.apache.portals.graffito.model.permission.CmsPermission;
+import org.apache.portals.graffito.services.core.ContentPermissionService;
+
+
+/**
+ * Default implementation for {@link org.apache.portals.graffito.services.core.ContentPermissionService}
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class ContentPermissionServiceImpl extends PermissionManagerImpl implements ContentPermissionService
+{
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentPermissionService#createPermission(java.lang.String, java.lang.String)
+     */
+    public CmsPermission createPermission(String name, String actions) throws ContentManagementException
+    {
+        return new CmsPermissionImpl(name, actions);
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentPermissionService#getPermissions(org.apache.portals.graffito.model.core.CmsObject)
+     */
+    public Permissions getPermissions(CmsObject cmsObject)
+    {       
+        return this.getPermissions(cmsObject.getUri());
+    }
+    
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentPermissionService#getPermissions(java.lang.String)
+     */
+    public Permissions getPermissions(String uri)
+    {
+        Criteria criteria = new Criteria();
+        
+        // Some permission can contains special char like "*", "-" (see CmsPermissionImpl)
+        ArrayList values = new ArrayList();
+        values.add(uri);
+        values.add(uri + "/*");
+        values.add(uri + "/-");
+        
+        criteria.addIn("name", values);
+        Query query = QueryFactory.newQuery(InternalPermissionImpl.class, criteria);
+        Collection internalPermissions = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+        
+        Permissions permissions = appendSecurityPermissions(internalPermissions);
+        return permissions;
+    }
+
+    
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentPermissionService#grantPermission(java.lang.String, org.apache.portals.graffito.model.permission.CmsPermission)
+     */
+    public void grantPermission(String fullPath, CmsPermission permission) throws ContentManagementException
+    {
+       
+        Collection internalPermissions = new ArrayList();
+
+        InternalPrincipal internalPrincipal = getInternalPrincipal(fullPath);
+        if (null == internalPrincipal)
+        {
+            throw new ContentManagementException("Impossible to find the principal for " + fullPath);
+        }
+        InternalPermission internalPermission = getInternalPermission(permission);
+        if (null == internalPermission)
+        {
+            throw new ContentManagementException("Impossible to find the internal permission");
+        }
+
+        if (null != internalPrincipal.getPermissions())
+        {
+            internalPermissions.addAll(internalPrincipal.getPermissions());
+        }
+        if (!internalPermissions.contains(internalPermission))
+        {
+            internalPermissions.add(internalPermission);
+        }
+        try
+        {
+            internalPrincipal.setModifiedDate(new Timestamp(System.currentTimeMillis()));
+            internalPrincipal.setPermissions(internalPermissions);
+            
+            getPersistenceBrokerTemplate().store(internalPrincipal);
+        }
+        catch (Exception e)
+        {
+            throw new ContentManagementException("Impossible to grant the permission " , e);
+        }
+
+
+    }
+    
+    /**
+     * 
+     * Iterate through a collection of {@link InternalPermission}and build a
+     *  map with key = the principal and value =  a collection of {@link Permission}
+     * </p>
+     * 
+     * @param omPermissions The collection of {@link InternalPermission}.
+     *  
+     * @return The collection of {@link java.security.Permission}.
+     */
+    private Permissions appendSecurityPermissions(Collection omPermissions)
+    {     
+        Permissions permissions = new Permissions();
+        Iterator internalPermissionsIter = omPermissions.iterator();
+        while (internalPermissionsIter.hasNext())
+        {
+            InternalPermission internalPermission = (InternalPermission) internalPermissionsIter.next();
+            
+            Permission permission = null;
+            try
+            {
+                                
+                ArrayList fullPaths = new ArrayList();
+                Iterator internalPrincipalsIter = internalPermission.getPrincipals().iterator();
+                while (internalPrincipalsIter.hasNext())
+                {
+                    InternalPrincipal internalPrincipal = (InternalPrincipal) internalPrincipalsIter.next();
+                    fullPaths.add(internalPrincipal.getFullPath());
+                }
+
+                Class permissionClass = Class.forName(internalPermission.getClassname());
+                Class[] parameterTypes = { String.class, String.class, Collection.class };
+                Constructor permissionConstructor = permissionClass.getConstructor(parameterTypes);
+                Object[] initArgs = { internalPermission.getName(), internalPermission.getActions(), fullPaths };
+                permission = (Permission) permissionConstructor.newInstance(initArgs);
+                if(!Collections.list(permissions.elements()).contains(permission))
+                {                    
+                    permissions.add(permission);
+                }
+
+                
+            }
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+        return permissions;
+    }
+
+    /**
+     *
+     * Returns the {@link InternalPrincipal} from the full path.
+     *      
+     * @param fullPath The full path.
+     * @return The {@link InternalPrincipal}.
+     */
+    InternalPrincipal getInternalPrincipal(String fullPath)
+    {
+        Criteria filter = new Criteria();
+        filter.addEqualTo("fullPath", fullPath);
+        Query query = QueryFactory.newQuery(InternalPrincipalImpl.class, filter);
+        InternalPrincipal internalPrincipal = (InternalPrincipal) getPersistenceBrokerTemplate().getObjectByQuery(query);
+        return internalPrincipal;
+    }
+    
+    /**
+     * <p>
+     * Returns the {@link InternalPermission} from a Permission object
+     * </p>
+     * 
+     * @param permission The permision 
+     * @return The {@link InternalPermission}.
+     */
+    InternalPermission getInternalPermission(CmsPermission permission)
+    {
+        Criteria filter = new Criteria();
+        filter.addEqualTo("classname", permission.getClass().getName());
+        filter.addEqualTo("name", permission.getName());
+        filter.addEqualTo("actions", permission.getActions());
+        Query query = QueryFactory.newQuery(InternalPermissionImpl.class, filter);
+        InternalPermission internalPermission = (InternalPermission) getPersistenceBrokerTemplate().getObjectByQuery(query);
+        return internalPermission;
+    }
+    
+}
\ No newline at end of file

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentServerServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentServerServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentServerServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentServerServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,230 @@
+/*
+ * 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.services.core.impl;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.exception.CmsInstantiateException;
+import org.apache.portals.graffito.exception.ContentManagementException;
+import org.apache.portals.graffito.model.server.FileSystemServer;
+import org.apache.portals.graffito.model.server.GraffitoServer;
+import org.apache.portals.graffito.model.server.Server;
+import org.apache.portals.graffito.model.server.WebdavServer;
+import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.services.core.ContentServerService;
+
+
+
+/**
+ * Default implementation for {@link org.apache.portals.graffito.services.core.ContentServerService}
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe</a>
+ * 
+ * @version $Id: ContentServerServiceImpl.java,v 1.1 2004/12/22 20:37:00 christophe Exp $
+ *
+ */
+public class ContentServerServiceImpl extends BaseContentServiceImpl implements ContentServerService
+{
+    protected final static Log logger = LogFactory.getLog(ContentServerServiceImpl.class);   
+    
+    /**
+     * 
+     * Constructor
+     * 
+     * @param persistenceService - Persistence Service used to access to the different persistenceService storages 
+     * 
+     */
+    public ContentServerServiceImpl(ContentPersistenceService persistenceService)
+    {
+        super(persistenceService);                  
+    }    
+    
+    // ========================================================================
+    // W E B D A V   S E R V E R
+    // ========================================================================
+
+    /**
+     *
+     *  @see org.apache.portals.graffito.services.core.ContentServerService#createWebdavServer()
+     *
+     */
+    public WebdavServer createWebdavServer() throws ContentManagementException
+    {
+        WebdavServer server= null;
+        try
+        {
+            server = (WebdavServer) persistenceService.createObject(ContentPersistenceService.WEBDAV_SERVER);
+            
+        }
+        catch (CmsInstantiateException e)
+        {
+            String message = "Failed to create webdav server object in ContentServerServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+        return server;
+    }
+
+    // ========================================================================
+    // J C M S    S T O R E   S E R V E R
+    // ========================================================================
+
+    /**
+     *
+     *  @see ContentServerService#createGraffitoServer()
+     *
+     */
+    public GraffitoServer createGraffitoServer() throws ContentManagementException
+    {
+        GraffitoServer server= null;
+        try
+        {
+            server = (GraffitoServer) persistenceService.createObject(ContentPersistenceService.GRAFFITO_SERVER);
+        }
+        catch (CmsInstantiateException e)
+        {
+            String message = "Failed to create graffito store server object in ContentServerServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+        return server;
+    }
+
+    // ========================================================================
+    // F I L E  S Y S T E M   S E R V E R
+    // ========================================================================
+
+    /**
+     *
+     *  @see ContentServerService#createFileSystemServer()
+     *
+     */
+    public FileSystemServer createFileSystemServer() throws ContentManagementException
+    {
+        FileSystemServer server = null;
+        try
+        {
+            server = (FileSystemServer) persistenceService.createObject(ContentPersistenceService.FILE_SYSTEM_SERVER);
+        }
+        catch (CmsInstantiateException e)
+        {
+            String message = "Failed to create File System store server object in ContentServerServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+        return server;
+    }
+
+    
+    // ========================================================================
+    //  S E R V E R
+    // ========================================================================
+    
+    /**
+     *
+     *  @see ContentServerService#addServer(Server)
+     *
+     */
+    public void addServer(Server server) throws ContentManagementException
+    {
+        try
+        {
+            persistenceService.registerServer(server);
+            persistenceService.insert(server);            
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to add server object in ContentServerServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *
+     *  @see ContentServerService#removeServer(Server)
+     *
+     */
+    public void removeServer(Server server) throws ContentManagementException
+    {
+
+        try
+        {
+            persistenceService.unRegisterServer(server);
+            persistenceService.delete(server);
+            
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to remove server object in ContentServerServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *
+     *  @see ContentServerService#getServer(String)
+     *
+     */
+    public Server getServer(String scope) throws ContentManagementException
+    {
+
+        try
+        {
+            return persistenceService.getServer(scope);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get server object in ContentServerServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+    /**
+     *  @see ContentServerService#updateServer(Server)
+     */
+    public void updateServer(Server server) throws ContentManagementException
+    {
+
+        try
+        {
+            persistenceService.update(server);  
+            //TODO : reinit the associated GraffitoStore
+            
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to update folder object in ContentModelServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+    
+    
+    /**
+     * @see org.apache.portals.graffito.services.core.ContentServerService#getAllServers()
+     */
+    public Collection getAllServers() throws ContentManagementException
+    {
+         return persistenceService.getServers(true);
+    }
+}

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentVersionServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentVersionServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentVersionServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/core/impl/ContentVersionServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,234 @@
+/*
+ * 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.services.core.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.exception.CmsInstantiateException;
+import org.apache.portals.graffito.exception.CmsInvalidObjectException;
+import org.apache.portals.graffito.exception.ContentManagementException;
+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.ContentPersistenceService;
+import org.apache.portals.graffito.services.core.ContentVersionService;
+
+/**
+ * Default implementation for {@link ContentVersionService}.
+ * 
+ * 
+ * @version $Id: ContentVersionServiceImpl.java,v 1.1 2004/12/22 20:36:59 christophe Exp $
+ *
+ */
+public class ContentVersionServiceImpl extends BaseContentServiceImpl implements ContentVersionService
+{
+    protected final static Log logger = LogFactory.getLog(ContentVersionServiceImpl.class);
+
+    /**
+     * Constructor : initialise with the persistenceService service
+     * 
+     * @param persistenceService the associated PersistenceService
+     */
+    public ContentVersionServiceImpl(ContentPersistenceService persistenceService)
+    {
+        super(persistenceService);
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentVersionService#createMajorVersion(java.lang.String)
+     */
+    public VersionnedContent createMajorVersion(String uri) throws CmsInstantiateException
+    {
+        try
+        {
+            CmsObject cmsObject = persistenceService.getCmsObject(uri, null); //null means get the lastest version
+            if (!(cmsObject instanceof VersionnedContent))
+            {
+                throw new CmsInstantiateException("Impossible to create a new major version for : " + uri
+                        + " - This cmsobject is not a versionned content");
+            }
+
+            VersionnedContent content = (VersionnedContent) cmsObject;
+            VersionnedContent newContent = this.createNewVersion(content, true);
+            content.setLastVersion(false);
+            persistenceService.update(content);
+            persistenceService.insert(newContent);
+            this.addInHistory(uri, content, newContent);
+
+            return newContent;
+        } catch (Exception e)
+        {
+            throw new CmsInstantiateException("Impossible to create a new major version for : " + uri, e);
+        }
+    }
+
+    /**
+     * @see org.apache.portals.graffito.services.core.ContentVersionService#createMinorVersion(java.lang.String)
+     */
+    public VersionnedContent createMinorVersion(String uri) throws CmsInstantiateException
+    {
+        try
+        {
+            CmsObject cmsObject = persistenceService.getCmsObject(uri, null); //null means get the lastest version
+            if (!(cmsObject instanceof VersionnedContent))
+            {
+                throw new CmsInstantiateException("Impossible to create a new major version for : " + uri
+                        + " - This cmsobject is not a versionned content");
+            }
+
+            VersionnedContent content = (VersionnedContent) cmsObject;
+            VersionnedContent newContent = this.createNewVersion(content, false);
+            content.setLastVersion(false);
+            persistenceService.update(content);
+            persistenceService.insert(newContent);
+            this.addInHistory(uri, content, newContent);
+
+            return newContent;
+        } catch (Exception e)
+        {
+            throw new CmsInstantiateException("Impossible to create a new major version for : " + uri, e);
+        }
+    }
+
+    /**
+     * @see org.apache.portals.graffito.services.core.ContentVersionService#getHistory(java.lang.String)
+     */
+    public HistoryElement getHistory(String uri) throws ContentManagementException
+    {
+        try
+        {
+            // Get the lastest version associated to the uri
+            CmsObject cmsObject = persistenceService.getCmsObject(uri, null);
+            
+            if (cmsObject == null)  return null;
+            if (cmsObject instanceof VersionnedContent)
+            {
+                return this.getHistory((VersionnedContent) cmsObject);
+            }
+            throw new ContentManagementException("Impossible to get the history element for : " + uri + 
+                                                 " - This cms object is not a versionned content");
+
+        } catch (Exception e)
+        {
+            logger.warn("Impossible to get the history for uri = " + uri, e);
+            return null;
+        }
+
+    }
+
+    /**
+     * @see org.apache.portals.graffito.services.core.ContentVersionService#getHistory(org.apache.portals.graffito.model.core.VersionnedContent)
+     */
+    public HistoryElement getHistory(VersionnedContent content) throws ContentManagementException
+    {
+        try
+        {
+           return persistenceService.getHistory(content);
+
+        }
+        catch (Exception e)
+        {
+            throw new ContentManagementException("Impossible to get the history element for : " + content.getUri(), e);            
+        }
+
+    }    
+    
+    /**
+     * Create a new versionned content based on the last one
+     * @param content The versionned content from which a new version has to be created 
+     * @param isNewMajorVersion if true, create a new major version number otherwise create a new minor version number
+     * @return a new versionned content 
+     * @throws CmsInstantiateException
+     */
+    private VersionnedContent createNewVersion(VersionnedContent content, boolean isNewMajorVersion) throws CmsInstantiateException
+    {
+        try
+        {
+            String newVersionNumber = null;
+            if (isNewMajorVersion)
+            {
+                newVersionNumber = this.createMajorNumber(content.getVersionNumber());
+            } else
+            {
+                newVersionNumber = this.createMinorNumber(content.getVersionNumber());
+            }
+
+            VersionnedContent newContent = (VersionnedContent) content.clone();
+            newContent.setVersionNumber(newVersionNumber);
+            return newContent;
+        } catch (Exception e)
+        {
+            throw new CmsInstantiateException("Impossible to create a new major version for : " + content.getUri(), e);
+        }
+    }
+
+    private String createMajorNumber(String versionNumber) throws CmsInvalidObjectException
+    {
+        String[] numbers = versionNumber.split("\\.");
+        if (numbers.length != 2)
+        {
+            throw new CmsInvalidObjectException("Incorrect version number");
+        }
+
+        int majorVersionNumber = new Integer(numbers[0]).intValue();
+        return new Integer(++majorVersionNumber) + ".0";
+
+    }
+
+    private String createMinorNumber(String versionNumber) throws CmsInvalidObjectException
+    {
+        String[] numbers = versionNumber.split("\\.");
+        if (numbers.length != 2)
+        {
+            throw new CmsInvalidObjectException("Incorrect version number");
+        }
+
+        int minorVersionNumber = new Integer(numbers[1]).intValue();
+        return numbers[0] + "." + new Integer(++minorVersionNumber);
+
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentVersionService#addInHistory(java.lang.String, org.apache.portals.graffito.model.core.VersionnedContent, org.apache.portals.graffito.model.core.VersionnedContent)
+     */
+    public void addInHistory(String uri, VersionnedContent previousContent, VersionnedContent newContent) throws CmsInstantiateException
+    {
+        try
+        {
+            // Get the lasted history element 
+            HistoryElement previousHistoryElement = null;
+            if (previousContent != null)
+            {
+               previousHistoryElement = this.getHistory(previousContent);
+            }
+
+            // Create a new history element
+            HistoryElement newHistoryElement = (HistoryElement) persistenceService.createObject(ContentPersistenceService.HISTPORY);
+            newHistoryElement.setVersionnedContent(newContent);
+            newHistoryElement.setPrevious(previousHistoryElement);
+            persistenceService.insertHistoryElement(newHistoryElement);
+        } catch (Exception e)
+        {
+            throw new CmsInstantiateException("Impossible to create a new history element", e);
+        }
+
+    }
+
+}
\ No newline at end of file

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/dm/impl/DocumentModelServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/dm/impl/DocumentModelServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/dm/impl/DocumentModelServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/dm/impl/DocumentModelServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,219 @@
+/*
+ * 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.services.dm.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.exception.CmsInstantiateException;
+import org.apache.portals.graffito.exception.ContentManagementException;
+import org.apache.portals.graffito.model.core.Folder;
+import org.apache.portals.graffito.model.core.HistoryElement;
+import org.apache.portals.graffito.model.dm.Document;
+import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.services.core.ContentVersionService;
+import org.apache.portals.graffito.services.core.impl.BaseContentServiceImpl;
+import org.apache.portals.graffito.services.dm.DocumentModelService;
+import org.apache.portals.graffito.util.UriUtil;
+
+
+
+/**
+ * Default implementation for {@link org.apache.portals.graffito.services.dm.DocumentModelService}.
+ *
+ * 
+ * @version $Id: ContentModelServiceImpl.java,v 1.1 2004/12/22 20:37:00 christophe Exp $
+ *
+ */
+public class DocumentModelServiceImpl extends BaseContentServiceImpl implements DocumentModelService
+{
+    protected final static Log logger = LogFactory.getLog(DocumentModelServiceImpl.class);
+
+    private ContentVersionService contentVersionService;
+    
+    /**
+     * 
+     * Constructor : initialise with the persistenceService service & the search service.
+     * 
+     * @param persistenceService The associated PersistenceService
+     * @param contentVersionService The associated version service
+     */
+    public DocumentModelServiceImpl(ContentPersistenceService persistenceService, ContentVersionService contentVersionService)
+    {
+        super(persistenceService);        
+        this.contentVersionService = contentVersionService;
+    }    
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.dm.DocumentModelService#addDocument(org.apache.portals.graffito.model.dm.Document)
+     */
+    public void addDocument(Document document) throws ContentManagementException
+    {          
+            this.validateUri(document.getUri());
+            
+            // Check if the document has a content
+            if (document.getDocumentStream() == null)
+            {
+                throw new ContentManagementException("Impossible to add " + document.getUri() + 
+                            " - no content has been initialised");  
+            }
+            
+            // Check if the content type is defined
+            if (document.getContentType() == null)
+            {
+                throw new ContentManagementException("Impossible to add " + document.getUri() + 
+                            " - no content type has been initialised");  
+            }
+            
+            // Check if the document uri is already used
+            if (persistenceService.getCmsObject(document.getUri()) != null )
+            {
+                throw new ContentManagementException("Impossible to add " + document.getUri() + 
+                " - This uri is already used");                  
+            }
+            
+            // Check if the parent folder uri is correct
+            String parentUri = UriUtil.getParentUri(document.getUri());
+            
+            //parentUri is null when the document uri match to a server scope         
+            if (parentUri ==null)
+            {
+                throw new ContentManagementException("Impossible to add " + document.getUri() + 
+                " - This uri doesn't match to a correct uri - no parent folder found");                 
+            } 
+            
+            Folder parentFolder = (Folder) persistenceService.getCmsObject(parentUri);
+
+            document.setParentFolder(parentFolder);
+
+            persistenceService.insert(document);
+            contentVersionService.addInHistory(document.getUri(), null, document);
+    }
+
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.dm.DocumentModelService#createDocument()
+     */
+    public Document createDocument() throws ContentManagementException
+    {
+        Document document = null;
+        try
+        {
+            document = (Document) persistenceService.createObject(ContentPersistenceService.DOCUMENT);
+            // Init the version number
+            document.setVersionNumber("1.0");
+        }
+        catch (CmsInstantiateException e)
+        {
+            String message = "Failed to create document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+        return document;
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.dm.DocumentModelService#getDocument(java.lang.String)
+     */
+    public Document getDocument(String uri) throws ContentManagementException
+    {
+
+        try
+        {
+            return (Document) persistenceService.getCmsObject(uri, null); //null = lasted version
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.dm.DocumentModelService#getDocument(java.lang.String, java.lang.String)
+     */
+    public Document getDocument(String uri, String versionNumber) throws ContentManagementException
+    {
+
+        try
+        {
+            return (Document) persistenceService.getCmsObject(uri, versionNumber);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to get versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.dm.DocumentModelService#removeDocument(org.apache.portals.graffito.model.dm.Document)
+     */
+    public void removeDocument(Document document) throws ContentManagementException
+    {
+
+        try
+        {
+            HistoryElement historyElement = contentVersionService.getHistory(document.getUri());
+            persistenceService.delete(historyElement);
+            persistenceService.delete(document);
+        }
+        catch (Exception e)
+        {
+            String message = "Failed to remove versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.dm.DocumentModelService#updateDocument(org.apache.portals.graffito.model.dm.Document)
+     */
+    public void updateDocument(Document document) throws ContentManagementException
+    {
+
+        try
+        {
+            // Check if the document is valid - Throws CmsInvalidObjectException if it is invalid
+            this.validateUri(document.getUri());
+            this.validateParentFolder(document);
+            persistenceService.update(document);
+
+        }
+        catch (Exception e)
+        {
+
+            String message = "Failed to update versionned document object in ContentVersionServiceImpl";
+            logger.error(message, e);
+            throw new ContentManagementException(message, e);
+        }
+    }
+       
+}

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentIndexServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,241 @@
+/*
+ * 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.services.search.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.DateField;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Searcher;
+import org.apache.portals.graffito.exception.ContentManagementException;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.model.core.VersionnedContent;
+import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.services.search.ContentIndexService;
+
+/**
+ * 
+ * Default implementation for {@link org.apache.portals.graffito.services.core.ContentIndexService}
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ * TODO : complete the implementation 
+ * 
+ * @version $Id: ContentIndexServiceImpl.java,v 1.1 2004/12/22 20:37:00 christophe Exp $
+ *
+ */
+public class ContentIndexServiceImpl  implements ContentIndexService
+{
+
+    private final static Log log = LogFactory.getLog(ContentIndexServiceImpl.class);
+    
+    private static File rootDir = null;
+
+    /** URI document field name */
+    public static final String URI_FIELD = "uri";
+        
+    /** Name document field name */
+    public static final String NAME_FIELD = "name";
+    
+    /** Revision document field name */
+    public static final String REVISION_FIELD = "revision";
+    
+    /** Creation date document field name */
+    public static final String CREATION_DATE_FIELD = "creationDate";
+    
+    /** Last modified document field name */
+    public static final String LAST_MODIFIED_DATE_FIELD = "lastModifiedDate";
+    
+    /** Content type document field name */
+    public static final String CONTENT_TYPE_FIELD = "contentType";
+    
+    /** Language  document field name */
+    public static final String LANGUAGE_FIELD = "language";
+    
+    /** Owner document field name */
+    public static final String OWNER_FIELD = "owner";
+    
+    /** Size document field name */
+    public static final String SIZE_FIELD = "size";
+    
+    /** Content text document field name */
+    public static final String CONTENT_TEXT = "content";
+        
+    /**  The associated persistenceService service */
+    private ContentPersistenceService persistenceService;
+    
+    /** Folder used to store the index */
+    private String indexRoot;
+    
+    /**
+     * Constructor - Initialise with the PersistenceService and the index root folder.
+     * 
+     * @param persistenceService The associated PersistenceStore
+     * @param indexRoot The directory folder used to create the index
+     * 
+     * @throws ContentManagementException
+     */
+    public ContentIndexServiceImpl(ContentPersistenceService persistenceService, String indexRoot) throws ContentManagementException
+    {
+        this.persistenceService = persistenceService;
+        this.indexRoot = indexRoot;
+        
+        try
+        {
+            rootDir = new File(indexRoot);
+
+            if (!rootDir.exists())
+            {
+                rootDir.mkdir();
+            }
+
+            // Check if the IndexSearcher can be created on this indexRoot
+            Searcher searcher = null;
+            searcher = new IndexSearcher(rootDir.getPath());
+            searcher.close();
+        }
+        catch (Exception e)
+        {
+            try
+            {
+                // Impossible to create an IndexSearcher, so try to initialize the index writer
+                IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), true);
+                indexWriter.close();
+                indexWriter = null;
+            }
+            catch (IOException e1)
+            {
+                // Impossible to init the IndexWriter
+                throw new ContentManagementException("Impossible to init the Lucene IndexWriter in the SearchServiceImpl");
+            }
+        }
+        
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentIndexService#add(org.apache.portals.graffito.model.core.CmsObject)
+     */
+    public boolean add(CmsObject cmsObject)
+    {
+        boolean result = false;
+
+        IndexWriter indexWriter = null;
+        try
+        {
+            indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), false);
+
+            // Create Lucene document
+            Document doc = new Document();
+
+            // Add CmsObject attributes
+            doc.add(Field.Keyword(URI_FIELD, cmsObject.getUri().toString()));                        
+            doc.add(Field.Text(NAME_FIELD, cmsObject.getName()));
+            doc.add(Field.Keyword(CREATION_DATE_FIELD, DateField.dateToString(cmsObject.getCreationDate())));
+            doc.add(Field.Keyword(LAST_MODIFIED_DATE_FIELD, DateField.dateToString(cmsObject.getLastModified())));
+            
+            // Add version info 
+            if (cmsObject instanceof VersionnedContent)
+            {
+                //TODO : add Version infos
+            }
+          
+
+            indexWriter.addDocument(doc);
+            indexWriter.optimize();
+            result = true;
+        }
+        catch (IOException e)
+        {
+            log.error("Error while adding document into the Lucene index " , e);
+        }
+        finally
+        {
+            try
+            {
+                if (indexWriter != null)
+                {
+                    indexWriter.close();
+                }
+            }
+            catch (IOException e)
+            {
+                log.error("Error while closing index writer", e);
+            }
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentIndexService#add(java.util.Collection)
+     */
+    public boolean add(Collection cmsObjects)
+    {
+        return false;
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentIndexService#remove(org.apache.portals.graffito.model.core.CmsObject)
+     */
+    public boolean remove(CmsObject cmsObject)
+    {
+        return false;
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentIndexService#remove(java.util.Collection)
+     */
+    public boolean remove(Collection cmsObjects)
+    {
+        return false;
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentIndexService#update(org.apache.portals.graffito.model.core.CmsObject)
+     */
+    public boolean update(CmsObject cmsObject)
+    {
+        return false;
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.core.ContentIndexService#update(java.util.Collection)
+     */
+    public boolean update(Collection cmsObjects)
+    {
+        return false;
+    }
+
+
+
+}

Added: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentSearchServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentSearchServiceImpl.java?rev=225704&view=auto
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentSearchServiceImpl.java (added)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/services/search/impl/ContentSearchServiceImpl.java Wed Jul 27 22:43:51 2005
@@ -0,0 +1,157 @@
+/*
+ * 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.services.search.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Searcher;
+import org.apache.portals.graffito.exception.ContentManagementException;
+import org.apache.portals.graffito.model.core.CmsObject;
+import org.apache.portals.graffito.persistence.ContentPersistenceService;
+import org.apache.portals.graffito.services.search.ContentSearchService;
+import org.apache.portals.graffito.services.search.Filter;
+import org.apache.portals.graffito.services.search.SearchResults;
+
+/**
+ * 
+ * @author Christophe
+ *
+ */
+public class ContentSearchServiceImpl  implements ContentSearchService
+{
+
+    private final static Log log = LogFactory.getLog(ContentSearchServiceImpl.class);
+
+   
+
+    public static final String URI_FIELD = "uri";
+    public static final String DESCRIPTION_FIELD = "description";
+    public static final String TITLE_FIELD = "title";
+    public static final String NAME_FIELD = "name";
+    public static final String REVISION_FIELD = "revision";
+    public static final String CREATION_DATE_FIELD = "creationDate";    
+    public static final String LAST_MODIFIED_DATE_FIELD = "lastModifiedDate";    
+    public static final String CONTENT_TYPE_FIELD = "contentType";
+    public static final String LANGUAGE_FIELD = "language";
+    public static final String OWNER_FIELD = "owner";                
+    public static final String SIZE_FIELD = "size";    
+    public static final String CONTENT_TEXT = "content";
+    
+    public static final String NO_VERSION = "none";
+    
+    
+    private ContentPersistenceService persistenceService;
+    private String indexRoot;
+    
+
+    /**
+     * Constructor
+     * @param persistenceService The persistence service 
+     * @param indexRoot the Lucene root index folder
+     * @throws ContentManagementException
+     */
+    public ContentSearchServiceImpl(ContentPersistenceService persistenceService, String indexRoot) throws ContentManagementException
+    {
+        this.persistenceService = persistenceService;
+        this.indexRoot = indexRoot;
+
+        File rootDir = null;
+        try
+        {
+            rootDir = new File(indexRoot);
+
+            if (!rootDir.exists())
+            {
+                rootDir.mkdir();
+            }
+
+            // Check if the IndexSearcher can be created on this indexRoot
+            Searcher searcher = null;
+            searcher = new IndexSearcher(rootDir.getPath());
+            searcher.close();
+        }
+        catch (Exception e)
+        {
+            try
+            {
+                // Impossible to create an IndexSearcher, so try to initialize the index writer
+                IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), true);
+                indexWriter.close();
+                indexWriter = null;
+            }
+            catch (IOException e1)
+            {
+                // Impossible to init the IndexWriter
+                throw new ContentManagementException("Impossible to init the Lucene IndexWriter in the SearchServiceImpl");
+            }
+        }
+        
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.search.ContentSearchService#newFilter()
+     */
+    public Filter newFilter()
+    {
+        return persistenceService.newFilter();
+    }
+    
+    /** 
+     * @see org.apache.portals.graffito.services.search.ContentSearchService#searchCmsObjects(org.apache.portals.graffito.services.search.Filter)
+     */
+    public SearchResults searchCmsObjects(Filter filter) throws ContentManagementException
+    {
+       
+        // TODO : check if the filter contains a full text search and do it into lucene
+        //        or makes all search (full text + prop into lucene) ?        
+        Collection result = persistenceService.getCollectionByQuery(CmsObject.class, filter);
+
+        SearchResults results = new SearchResults();
+        results.addAll(result);
+        
+        
+        return results;        
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.services.search.ContentSearchService#searchCmsObjects(java.lang.Class, org.apache.portals.graffito.services.search.Filter)
+     */
+    public SearchResults searchCmsObjects(Class cmsObjectClass, Filter filter) throws ContentManagementException
+    {
+
+        // TODO : check if the filter contains a full text search and do it into lucene
+        //        or makes all search (full text + prop into lucene) ?
+        
+        Collection result = persistenceService.getCollectionByQuery(cmsObjectClass, filter);
+        
+        SearchResults results = new SearchResults();
+        results.addAll(result);
+        
+        return results;        
+    }    
+}



Mime
View raw message