incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r128433 - in incubator/graffito/trunk/components/src: java/META-INF java/org/apache/portals/graffito/impl java/org/apache/portals/graffito/model/impl java/org/apache/portals/graffito/persistence/impl java/org/apache/portals/graffito/store/impl/ojb test/org/apache/portals/graffito/impl
Date Thu, 27 Jan 2005 22:23:21 GMT
Author: clombart
Date: Thu Jan 27 14:23:20 2005
New Revision: 128433

URL: http://svn.apache.org/viewcvs?view=rev&rev=128433
Log:
* Move attributes isLastVersion & version num from the Document interface into the CmsObject
interface. By this way, versionning can be apply on folders.

* add method getContentAsString in the Content interface

* Bug fix in getCmsObject() and in getChildren
Modified:
   incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/impl/ContentModelServiceImpl.java
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/DocumentImpl.java
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/persistence/impl/ContentPersistenceServiceImpl.java
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java
   incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java

Modified: incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml&r1=128432&p2=incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml&r2=128433
==============================================================================
--- incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml	(original)
+++ incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml	Thu Jan
27 14:23:20 2005
@@ -60,6 +60,20 @@
 		column="PARENT_ID" 
 		
 	    />
+		
+	    <field-descriptor 
+		name="versionNumber" 
+		jdbc-type="VARCHAR"
+		column="VERSION_NUM"		
+	    />  	    
+	    
+	    <field-descriptor 
+		name="isLastVersion" 
+		jdbc-type="INTEGER"
+		column="IS_LAST_VERSION"	
+               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
	
+	    />  		    
+				
 	    <field-descriptor 
 		name="name" 
 		jdbc-type="VARCHAR"
@@ -145,6 +159,20 @@
 		primarykey="true"
 		autoincrement="true"
 	    />
+		
+	    <field-descriptor 
+		name="versionNumber" 
+		jdbc-type="VARCHAR"
+		column="VERSION_NUM"		
+	    />  	    
+	    
+	    <field-descriptor 
+		name="isLastVersion" 
+		jdbc-type="INTEGER"
+		column="IS_LAST_VERSION"	
+               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
	
+	    />  		    
+		
 	    <field-descriptor 
 		name="parentId" 
 		jdbc-type="BIGINT"
@@ -230,12 +258,6 @@
 		primarykey="true"
 		autoincrement="true"
 	    />
-	    
-	    <field-descriptor 
-		name="versionNumber" 
-		jdbc-type="VARCHAR"
-		column="VERSION_NUM"		
-	    />  	    
 
 	    <field-descriptor 
 		name="contentId" 
@@ -244,11 +266,18 @@
 	    />	    
 	    
 	    <field-descriptor 
+		name="versionNumber" 
+		jdbc-type="VARCHAR"
+		column="VERSION_NUM"		
+	    />  	    
+	    
+	    <field-descriptor 
 		name="isLastVersion" 
 		jdbc-type="INTEGER"
 		column="IS_LAST_VERSION"	
                conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
	
 	    />  		    
+		
 	    <field-descriptor 
 		name="parentId" 
 		jdbc-type="BIGINT"

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/impl/ContentModelServiceImpl.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/impl/ContentModelServiceImpl.java?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/impl/ContentModelServiceImpl.java&r1=128432&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/impl/ContentModelServiceImpl.java&r2=128433
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/impl/ContentModelServiceImpl.java
(original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/impl/ContentModelServiceImpl.java
Thu Jan 27 14:23:20 2005
@@ -28,6 +28,7 @@
 import org.apache.portals.graffito.ContentModelService;
 import org.apache.portals.graffito.ContentVersionService;
 import org.apache.portals.graffito.exception.*;
+import org.apache.portals.graffito.model.CmsObject;
 import org.apache.portals.graffito.model.Folder;
 import org.apache.portals.graffito.model.Link;
 
@@ -131,6 +132,29 @@
         }
     }
 
+    
+    /**
+     * 
+     * @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++)
+            {
+                persistence.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)
      */
@@ -309,6 +333,13 @@
                             " - 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 (persistence.getCmsObject(document.getUri()) != null )
             {
@@ -508,4 +539,12 @@
         
     }  
     
+    /**
+     * 
+     * @see org.apache.portals.graffito.ContentModelService#getCmsObject(java.lang.String)
+     */
+    public CmsObject getCmsObject(String uri) throws ContentManagementException
+    {
+        return persistence.getCmsObject(uri);
+    }
 }

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java&r1=128432&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java&r2=128433
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java
(original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java
Thu Jan 27 14:23:20 2005
@@ -36,6 +36,7 @@
     protected Long objectId;
     
     protected boolean isLastVersion = true;
+    protected String versionNumber;  
     
     protected Long parentId;  //parent folder id
     protected Folder parentFolder;
@@ -64,6 +65,41 @@
         ojbConcreteClass = this.getClass().getName();       
     }
     
+    
+    /**
+     * @see org.apache.portals.graffito.model.Document#isLastVersion()
+     */
+    public boolean isLastVersion()
+    {
+        return isLastVersion;
+    }
+    
+    /**
+     * @see org.apache.portals.graffito.model.Document#setLastVersion(boolean)
+     */
+    public void setLastVersion(boolean isLastVersion)
+    {
+        this.isLastVersion = isLastVersion;
+
+    }
+    
+    /**
+     * 
+     * @see org.apache.portals.graffito.model.Document#setVersionNumber(java.lang.String)
+     */
+    public void setVersionNumber(String versionNumber)
+    {
+        this.versionNumber = versionNumber;
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.model.Document#getVersionNumber()
+     */
+    public String getVersionNumber()
+    {
+        return versionNumber;
+    }    
     /**
      * @return Returns the parentFolder.
      */

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java&r1=128432&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java&r2=128433
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java
(original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java
Thu Jan 27 14:23:20 2005
@@ -54,9 +54,19 @@
      */
     public byte[] getContentByte()
     {
+        
         return content;
     }
 
+    /**
+     * 
+     * @see org.apache.portals.graffito.model.Content#getContentAsString()
+     */
+    public String getContentAsString()
+    {        
+        return new String(content);
+    }
+    
     /**
      * @param stream The content to set.
      */

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/DocumentImpl.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/DocumentImpl.java?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/DocumentImpl.java&r1=128432&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/DocumentImpl.java&r2=128433
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/DocumentImpl.java
(original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/DocumentImpl.java
Thu Jan 27 14:23:20 2005
@@ -38,8 +38,6 @@
 {
     protected final static Log log =  LogFactory.getLog(DocumentImpl.class);
     
-    
-    protected String versionNumber;    
     protected long size;
     protected String contentType;
     protected String language;
@@ -48,42 +46,7 @@
     protected Long contentId; 
     protected Content content;
 
-    
-    /**
-     * 
-     * @see org.apache.portals.graffito.model.Document#setVersionNumber(java.lang.String)
-     */
-    public void setVersionNumber(String versionNumber)
-    {
-        this.versionNumber = versionNumber;
-    }
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.model.Document#getVersionNumber()
-     */
-    public String getVersionNumber()
-    {
-        return versionNumber;
-    }
-
-    
-    /**
-     * @see org.apache.portals.graffito.model.Document#isLastVersion()
-     */
-    public boolean isLastVersion()
-    {
-        return isLastVersion;
-    }
-    
-    /**
-     * @see org.apache.portals.graffito.model.Document#setLastVersion(boolean)
-     */
-    public void setLastVersion(boolean isLastVersion)
-    {
-        this.isLastVersion = isLastVersion;
 
-    }
     /** 
      * @see org.apache.portals.graffito.model.Document#getContentType()
      */

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/persistence/impl/ContentPersistenceServiceImpl.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/persistence/impl/ContentPersistenceServiceImpl.java?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/persistence/impl/ContentPersistenceServiceImpl.java&r1=128432&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/persistence/impl/ContentPersistenceServiceImpl.java&r2=128433
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/persistence/impl/ContentPersistenceServiceImpl.java
(original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/persistence/impl/ContentPersistenceServiceImpl.java
Thu Jan 27 14:23:20 2005
@@ -232,17 +232,8 @@
      */
     public CmsObject getCmsObject(String uri) throws ContentPersistenceException, CmsPermissionException
     {
-
-        ContentStore store = findPersistenceStore(uri);
-        if (store == null)
-        {
-            throw new ContentPersistenceException("Impossible to find the associated store");
-        }
         
-        Filter filter = store.newFilter();
-        filter.addEqualTo("uri", uri);
-        CmsObject object = (CmsObject) store.getObjectByQuery(CmsObject.class, filter);
-        return object;
+          return this.getCmsObject(uri, null);
     }
 
     /**
@@ -271,7 +262,7 @@
         }
 
         filter.addEqualTo("uri", uri);
-        CmsObject object = (CmsObject) store.getObjectByQuery(Document.class, filter);
+        CmsObject object = (CmsObject) store.getObjectByQuery(CmsObject.class, filter);
         return object;
     }
     

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?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java&r1=128432&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/store/impl/ojb/GraffitoOJBStore.java&r2=128433
==============================================================================
--- 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
Thu Jan 27 14:23:20 2005
@@ -177,7 +177,7 @@
         // Check if the parenturi is the root store uri
         if (this.scope.equals(parentUri))
         {
-            filter.addIsNull("parentFolder.uri");
+            filter.addIsNull("parentId");
         }
         else
         {
@@ -200,7 +200,7 @@
         // Check if the parenturi is the root store uri
         if (this.scope.equals(parentUri))
         {
-            filter.addIsNull("parentFolder.uri");
+            filter.addIsNull("parentId");
         }
         else
         {
@@ -220,7 +220,7 @@
         // Check if the parenturi is the root store uri
         if (this.scope.equals(parentUri))
         {
-            filter.addIsNull("parentFolder.uri");
+            filter.addIsNull("parentId");
         }
         else
         {
@@ -464,7 +464,7 @@
         Criteria criteria = ((FilterImpl) filter).getCriteria();
         String filterScope = filter.getScope();
         // if the class is a CmsObject, check the filter scope is defined in
-        // orer to limit the search on this one
+        // order to limit the search on this one
         if (clazz.equals(CmsObject.class) && filterScope != null && !filterScope.equals(""))
         {
             criteria.addLike("uri", filterScope + "%");

Modified: incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java?view=diff&rev=128433&p1=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java&r1=128432&p2=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java&r2=128433
==============================================================================
--- incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java
(original)
+++ incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java
Thu Jan 27 14:23:20 2005
@@ -149,6 +149,14 @@
         assertTrue("Invalid title for /folder1", folder.getTitle().equals("Folder 1 Title
modified"));
 
         // ---------------------------------------------------------------------------------------
+        // Get folders
+        // ---------------------------------------------------------------------------------------
               
+        log.info("Get folders");
+        Collection folders = modelService.getFolders("/graffitotest");
+        assertNotNull("Folders is null", folders);
+        assertTrue("Invalid number of folders in  /graffitotest",  folders.size() == 1);
+        
+        // ---------------------------------------------------------------------------------------
         // Remove a folder
         // ---------------------------------------------------------------------------------------
               
         log.info("Remove folder");
@@ -286,7 +294,7 @@
             assertNotNull("Document content is null", document.getContent().getContentByte());
             
             // ---------------------------------------------------------------------------------------
-            // Update a  document and its last version
+            // Update a document and its last version
             // ---------------------------------------------------------------------------------------
           
             log.info("Update document");
             document.setDescription("New description for Document 1");
@@ -298,24 +306,31 @@
             document.setContentType("application/msword");
             document.getContent().setContent(xmlContent);
             modelService.updateDocument(document);
-//            persistenceBroker.commitTransaction();
-//            persistenceBroker.beginTransaction();
 
             // ---------------------------------------------------------------------------------------
-            // Update a  document and its last version
+            // Get the modified document
             // ---------------------------------------------------------------------------------------
-
             log.info("Get modified  document");
             document = modelService.getDocument("/graffitotest/document1");
             assertNotNull("/graffitotest/document1 is null", document);
             assertTrue("Invalid description for /graffitotest/document1", document.getDescription().equals("New
description for Document 1"));
 
+            
+            // ---------------------------------------------------------------------------------------
+            // Get a all documents
+            // ---------------------------------------------------------------------------------------
                     
+            log.info("Get all documents");
+            Collection documents = modelService.getDocuments("/graffitotest");
+            assertNotNull("/graffitotest is null", documents);
+            assertTrue("Invalid number of documents in /graffitotest", documents.size() ==
1);
+            document = (Document) documents.iterator().next();
+            assertNotNull("Document content is null", document.getContent().getContentByte());
+                        
             // ---------------------------------------------------------------------------------------
             // Remove a  document and its versions
             // ---------------------------------------------------------------------------------------
       
             log.info("Remove document and its content");
-            modelService.removeDocument(document);
-//            persistenceBroker.commitTransaction();        
+            modelService.removeDocument(document);     
             
         }
         catch (Exception e)

Mime
View raw message