incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r125529 - in incubator/graffito/trunk/components/src: java/org/apache/portals/graffito/model/impl java/org/apache/portals/graffito/util test/org/apache/portals/graffito/impl test/org/apache/portals/graffito/persistence/impl test/org/apache/portals/graffito/util
Date Tue, 18 Jan 2005 18:56:09 GMT
Author: clombart
Date: Tue Jan 18 10:56:08 2005
New Revision: 125529

URL: http://svn.apache.org/viewcvs?view=rev&rev=125529
Log:
Add getPath method
Modified:
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java
   incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/util/CmsUtil.java
   incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java
   incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/persistence/impl/TestPersistenceService.java
   incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/util/TestUriUtil.java

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=125529&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java&r1=125528&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/CmsObjectImpl.java&r2=125529
==============================================================================
--- 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
Tue Jan 18 10:56:08 2005
@@ -209,6 +209,20 @@
         this.title = title;
     }
     
+    
+    /**
+     * 
+     * @see org.apache.portals.graffito.model.CmsObject#getPath()
+     */
+    public String[] getPath()
+    {
+        return uri.substring(1).split(URI_SEPARATOR);
+    }
+    
+    /**
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
     public boolean equals(Object cmsObject)
     {
         if (cmsObject == null)

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/util/CmsUtil.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/util/CmsUtil.java?view=diff&rev=125529&p1=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/util/CmsUtil.java&r1=125528&p2=incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/util/CmsUtil.java&r2=125529
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/util/CmsUtil.java
(original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/util/CmsUtil.java
Tue Jan 18 10:56:08 2005
@@ -15,6 +15,7 @@
 package org.apache.portals.graffito.util;
 
 import org.apache.portals.graffito.exception.CmsInvalidObjectException;
+import org.apache.portals.graffito.model.CmsObject;
 
 
 
@@ -27,8 +28,6 @@
  */
 public class CmsUtil
 {
-     private final static String ROOT_FOLDER = "/";
-     private final static String FOLDER_SEPARATOR = "/";     
      
      /**
       * Check if the the cms object uri is valid
@@ -38,9 +37,9 @@
      public static boolean isValidUri(String uri)
      {
          if ((uri == null) ||
-             (uri.equals(ROOT_FOLDER)) ||
-             (uri.endsWith(FOLDER_SEPARATOR)) ||
-             (! uri.startsWith(FOLDER_SEPARATOR)) || 
+             (uri.equals(CmsObject.URI_SEPARATOR)) ||
+             (uri.endsWith(CmsObject.URI_SEPARATOR)) ||
+             (! uri.startsWith(CmsObject.URI_SEPARATOR)) || 
              uri.equals("") )
          {
              return false; 
@@ -63,7 +62,7 @@
              throw new CmsInvalidObjectException("Incorrect uri : " + uri);
          }
          
-         String[] path = uri.split(FOLDER_SEPARATOR);         
+         String[] path = uri.split(CmsObject.URI_SEPARATOR);         
          
          // Firts path element should be = empty string because a uri always start with '/'
          // So, if len=2, means it is a root folder like '/foo'. 
@@ -77,7 +76,7 @@
          {   
              if (! path[i].equals(""))
              {    
-                parentUri += ROOT_FOLDER + path[i];
+                parentUri += CmsObject.URI_SEPARATOR + path[i];
              }
          }                  
          return parentUri;

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=125529&p1=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java&r1=125528&p2=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/impl/TestContentModelService.java&r2=125529
==============================================================================
--- 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
Tue Jan 18 10:56:08 2005
@@ -273,8 +273,6 @@
             log.info("Add Document");
             modelService.addDocument(document);
 
-//            persistenceBroker.commitTransaction();
-//            persistenceBroker.beginTransaction();
 
             // ---------------------------------------------------------------------------------------
             // Get a document
@@ -613,7 +611,6 @@
             byte[] content = StreamUtil.getContentByte(file);
             document.getContent().setContent(content);
 
-            //document.setContentType("application/pdf");
             document.setContentType("text/xml");
             document.setOwner("Christophe");
             document.setSize(content.length);
@@ -623,8 +620,6 @@
             document.setParentFolder(parent);
             log.info("Add document : " + document.getUri());
             modelService.addDocument(document);
-            
-            
         }
 
     }

Modified: incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/persistence/impl/TestPersistenceService.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/persistence/impl/TestPersistenceService.java?view=diff&rev=125529&p1=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/persistence/impl/TestPersistenceService.java&r1=125528&p2=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/persistence/impl/TestPersistenceService.java&r2=125529
==============================================================================
--- incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/persistence/impl/TestPersistenceService.java
(original)
+++ incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/persistence/impl/TestPersistenceService.java
Tue Jan 18 10:56:08 2005
@@ -79,10 +79,10 @@
                        
 
         Folder folder = (Folder) persistenceService.createObject("Folder");
-        assertNotNull("Folder is null", folder);
+        assertNotNull("Folder is null", folder);               
 
-         Document versionnedDocument = (Document) persistenceService.createObject("Document");
-         assertNotNull("VersionnedDocument is null", versionnedDocument);         
+        Document versionnedDocument = (Document) persistenceService.createObject("Document");
+        assertNotNull("VersionnedDocument is null", versionnedDocument);         
          
     }
     

Modified: incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/util/TestUriUtil.java
Url: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/util/TestUriUtil.java?view=diff&rev=125529&p1=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/util/TestUriUtil.java&r1=125528&p2=incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/util/TestUriUtil.java&r2=125529
==============================================================================
--- incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/util/TestUriUtil.java
(original)
+++ incubator/graffito/trunk/components/src/test/org/apache/portals/graffito/util/TestUriUtil.java
Tue Jan 18 10:56:08 2005
@@ -19,6 +19,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.portals.graffito.model.Folder;
+import org.apache.portals.graffito.model.impl.FolderImpl;
 import org.apache.portals.graffito.util.CmsUtil;
 import org.apache.portals.graffito.exception.CmsInvalidObjectException;
 
@@ -130,4 +132,13 @@
         }
     }
 
+    public void testPath()
+    {
+          Folder folder = new FolderImpl();
+          folder.setUri("/test1/test2/test3");
+          String path[] = folder.getPath();
+          assertTrue("Incorrect path", path[0].equals("test1"));
+          assertTrue("Incorrect path", path[1].equals("test2"));
+          assertTrue("Incorrect path", path[2].equals("test3"));
+    }
 }

Mime
View raw message