portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r330387 - in /portals/jetspeed-2/trunk/components/page-manager/src/test: database-page-manager.xml import-page-manager.xml org/apache/jetspeed/page/TestCastorXmlPageManager.java org/apache/jetspeed/page/TestPageImporter.java
Date Wed, 02 Nov 2005 23:51:00 GMT
Author: taylor
Date: Wed Nov  2 15:50:57 2005
New Revision: 330387

URL: http://svn.apache.org/viewcvs?rev=330387&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-395

implementing PSML import functionality

Added:
    portals/jetspeed-2/trunk/components/page-manager/src/test/import-page-manager.xml
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java
Modified:
    portals/jetspeed-2/trunk/components/page-manager/src/test/database-page-manager.xml
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/database-page-manager.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/database-page-manager.xml?rev=330387&r1=330386&r2=330387&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/database-page-manager.xml (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/database-page-manager.xml Wed
Nov  2 15:50:57 2005
@@ -42,6 +42,7 @@
         <property name="transactionAttributes">
             <props>
                 <prop key="*">PROPAGATION_SUPPORTS</prop>
+                <prop key="update*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
                               
             </props>
         </property>
     </bean>

Added: portals/jetspeed-2/trunk/components/page-manager/src/test/import-page-manager.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/import-page-manager.xml?rev=330387&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/import-page-manager.xml (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/import-page-manager.xml Wed
Nov  2 15:50:57 2005
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<!--
+Copyright 2004 The Apache Software Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<beans>
+
+  <bean id="org.apache.jetspeed.page.PageManagerImpl" 
+        name="pageManagerImpl"
+        init-method="init"
+        class="org.apache.jetspeed.page.impl.DatabasePageManager">
+      <!-- OJB configuration file resource path -->
+      <constructor-arg index="0"><value>JETSPEED-INF/ojb/page-manager-repository.xml</value></constructor-arg>
      
+      <!-- folder/page/link cache size, default=128 -->
+      <constructor-arg index="1"><value>128</value></constructor-arg>
+      <!-- permissions security enabled flag, default=false -->
+      <constructor-arg index="2"><value>false</value></constructor-arg>
+      <!-- constraints security enabled flag, default=true -->
+      <constructor-arg index="3"><value>false</value></constructor-arg>
+  </bean>
+
+    <!-- Proxying -->
+    <bean id="org.apache.jetspeed.page.PageManager" name="dbPageManager" parent="baseTransactionProxy">
+        <property name="proxyInterfaces">
+            <value>org.apache.jetspeed.page.PageManager</value>
+        </property>
+        <property name="target">
+            <ref bean="pageManagerImpl" />
+        </property>
+        <property name="transactionAttributes">
+            <props>
+                <prop key="*">PROPAGATION_SUPPORTS</prop>
+                <prop key="update*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
               
+            </props>
+        </property>
+    </bean>
+
+  <!-- PageManager -->
+  <bean id="PsmlDocumentHandler"      
+       class="org.apache.jetspeed.page.document.psml.CastorFileSystemDocumentHandler" >
        
+       <constructor-arg index="0"><value>/JETSPEED-INF/castor/page-mapping.xml</value></constructor-arg>
+       <constructor-arg index="1"><value>.psml</value></constructor-arg>
+       <constructor-arg index="2" ><value>org.apache.jetspeed.om.page.Page</value></constructor-arg>
      
+       <constructor-arg index="3" ><value>../../src/webapp/WEB-INF/pages</value></constructor-arg>
+       <constructor-arg index="4" ><ref bean="PageFileCache"/></constructor-arg>
+  </bean>
+  
+  <bean id="LinkDocumentHandler"       
+       class="org.apache.jetspeed.page.document.psml.CastorFileSystemDocumentHandler" >
        
+       <constructor-arg index="0"><value>/JETSPEED-INF/castor/page-mapping.xml</value></constructor-arg>
+       <constructor-arg index="1"><value>.link</value></constructor-arg>
+       <constructor-arg index="2" ><value>org.apache.jetspeed.om.page.Link</value></constructor-arg>
      
+       <constructor-arg index="3" ><value>../../src/webapp/WEB-INF/pages</value></constructor-arg>
+       <constructor-arg index="4" ><ref bean="PageFileCache"/></constructor-arg>
+  </bean>
+  
+  <bean id="FolderMetaDataDocumentHandler"         
+       class="org.apache.jetspeed.page.document.psml.CastorFileSystemDocumentHandler" >
        
+       <constructor-arg index="0"><value>/JETSPEED-INF/castor/page-mapping.xml</value></constructor-arg>
+       <constructor-arg index="1"><value>folder.metadata</value></constructor-arg>
+       <constructor-arg index="2" ><value>org.apache.jetspeed.om.folder.FolderMetaData</value></constructor-arg>
      
+       <constructor-arg index="3" ><value>../../src/webapp/WEB-INF/pages</value></constructor-arg>
+       <constructor-arg index="4" ><ref bean="PageFileCache"/></constructor-arg>
+  </bean>
+  
+  <bean id="PageSecurityDocumentHandler"       
+       class="org.apache.jetspeed.page.document.psml.CastorFileSystemDocumentHandler" >
        
+       <constructor-arg index="0"><value>/JETSPEED-INF/castor/page-mapping.xml</value></constructor-arg>
+       <constructor-arg index="1"><value>page.security</value></constructor-arg>
+       <constructor-arg index="2" ><value>org.apache.jetspeed.om.page.PageSecurity</value></constructor-arg>
      
+       <constructor-arg index="3" ><value>../../src/webapp/WEB-INF/pages</value></constructor-arg>
+       <constructor-arg index="4" ><ref bean="PageFileCache"/></constructor-arg>
+  </bean>
+  
+  <bean id="DocumentHandlerFactory"        
+       class="org.apache.jetspeed.page.document.psml.DocumentHandlerFactoryImpl" >   
  
+        <constructor-arg>
+        <map>
+          <entry key=".psml">
+            <ref bean="PsmlDocumentHandler" />
+          </entry>
+          <entry key=".link">
+            <ref bean="LinkDocumentHandler" />
+          </entry>  
+          <entry key="folder.metadata">
+            <ref bean="FolderMetaDataDocumentHandler" />
+          </entry>        
+          <entry key="page.security">
+            <ref bean="PageSecurityDocumentHandler" />
+          </entry>        
+        </map>
+       </constructor-arg>
+  </bean>
+  
+  <bean id="FolderHandler"         
+       class="org.apache.jetspeed.page.document.psml.FileSystemFolderHandler" >      
  
+       <constructor-arg index="0"><value>../../src/webapp/WEB-INF/pages</value></constructor-arg>
+       <constructor-arg index="1"><ref bean="DocumentHandlerFactory"/></constructor-arg>
+       <constructor-arg index="2"><ref bean="PageFileCache"/></constructor-arg>
       
+  </bean>
+    
+  <bean id="org.apache.jetspeed.page.CastorPageManager" 
+       name="castorPageManager"
+       class="org.apache.jetspeed.page.psml.CastorXmlPageManager">         
+       <constructor-arg index="0"><ref bean="IdGenerator"/></constructor-arg>
+       <constructor-arg index="1"><ref bean="DocumentHandlerFactory"/></constructor-arg>
+       <constructor-arg index="2"><ref bean="FolderHandler"/></constructor-arg>
+       <constructor-arg index="3"><ref bean="PageFileCache"/></constructor-arg>
       
+       <!-- permissions security enabled flag, default=false -->
+       <constructor-arg index="4"><value>false</value></constructor-arg>
+       <!-- constraints security enabled flag, default=true -->
+       <constructor-arg index="5"><value>false</value></constructor-arg>
+  </bean>
+
+    <!-- Page File Cache -->
+    <bean id="PageFileCache" class="org.apache.jetspeed.cache.file.FileCache" init-method="startFileScanner"
destroy-method="stopFileScanner">
+        <!-- Scan rate for changes in cached files on the file system -->
+        <constructor-arg index="0">
+            <value>10</value>
+        </constructor-arg>
+        <!-- Cache size -->
+        <constructor-arg index="1">
+            <value>100</value>
+        </constructor-arg>
+    </bean>
+
+    <bean id="IdGenerator" class="org.apache.jetspeed.idgenerator.JetspeedIdGenerator"
init-method="start" destroy-method="stop">
+        <!-- ID Start value -->
+        <constructor-arg index="0">
+            <value>65536</value>
+        </constructor-arg>
+        <!-- ID Prefix -->
+        <constructor-arg index="1">
+            <value>P-</value>
+        </constructor-arg>
+        <!-- ID Suffix -->
+        <constructor-arg index="2">
+            <value></value>
+        </constructor-arg>
+    </bean>
+
+
+</beans>

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java?rev=330387&r1=330386&r2=330387&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java
Wed Nov  2 15:50:57 2005
@@ -846,7 +846,7 @@
     {
         Page testpage = pageManager.getPage("/clonetest.psml");
         assertNotNull(testpage);
-        Page clone = pageManager.clonePage(testpage, "/cloned.psml");
+        Page clone = pageManager.copyPage(testpage, "/cloned.psml");
         assertNotNull(clone);
         
         assertTrue(clone.getId().equals("/cloned.psml"));

Added: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java?rev=330387&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java
(added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java
Wed Nov  2 15:50:57 2005
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.page;
+
+import java.util.Iterator;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.jetspeed.components.rdbms.ojb.ConnectionRepositoryEntry;
+import org.apache.jetspeed.components.test.AbstractSpringTestCase;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.Page;
+
+
+/**
+ * DatabasePageManager
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+
+public class TestPageImporter extends AbstractSpringTestCase
+{
+    private PageManager dbManager;
+    private PageManager castorManager;    
+    
+    public static void main(String args[])
+    {
+        junit.awtui.TestRunner.main(new String[]
+        { TestPageImporter.class.getName() });
+    }
+    
+    protected void setUp() throws Exception
+    {
+        super.setUp();        
+        dbManager = (PageManager)ctx.getBean("dbPageManager");
+        castorManager = (PageManager)ctx.getBean("castorPageManager");
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+    
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestPageImporter.class);
+    }
+    
+    protected String[] getConfigurations()
+    {
+        return new String[]
+        { "import-page-manager.xml", "transaction.xml" };
+    }
+
+    protected String[] getBootConfigurations()
+    {
+        return new String[]
+        { "test-repository-datasource-spring.xml" };
+    }
+     
+    public void testImporter()
+    throws Exception
+    {
+        System.out.println("Importer Test");
+        assertNotNull("db manager is null", dbManager);
+        assertNotNull("castor manager is null", castorManager);
+
+        // create root folder
+        Folder fsRoot = castorManager.getFolder("/");
+        Folder root = importFolder(fsRoot);                        
+        
+        // NOTE: this will delete EVERYTHING
+        // dbManager.removeFolder(root);
+        
+        System.out.println("Importer Test Completed.");
+        System.out.println(folderCount + " folders imported.");        
+        System.out.println(pageCount + " pages imported.");        
+    }
+    
+    private int folderCount = 0;
+    private int pageCount = 0;
+    
+    private Folder importFolder(Folder srcFolder)
+    throws Exception
+    {
+        System.out.println("copying folder " + srcFolder.getPath());
+        Folder dstFolder = dbManager.copyFolder(srcFolder, srcFolder.getPath());
+        dbManager.updateFolder(dstFolder);
+        folderCount++;
+        
+        Iterator pages = srcFolder.getPages().iterator();
+        while (pages.hasNext())
+        {
+            Page srcPage = (Page)pages.next();
+            System.out.println("copying page " + srcPage.getPath());
+            Page dstPage = dbManager.copyPage(srcPage, srcPage.getPath());
+            dbManager.updatePage(dstPage);
+            pageCount++;
+        }
+        
+        Iterator folders = srcFolder.getFolders().iterator();
+        while (folders.hasNext())
+        {
+            Folder folder = (Folder)folders.next();
+            importFolder(folder);
+        }
+        
+        return dstFolder;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message