portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r789003 - in /portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE: components/serializer/src/java/org/apache/jetspeed/serializer/ components/serializer/src/java/org/apache/jetspeed/serializer/objects/ installer/etc/database/
Date Sat, 27 Jun 2009 17:57:13 GMT
Author: rwatler
Date: Sat Jun 27 17:57:12 2009
New Revision: 789003

URL: http://svn.apache.org/viewvc?rev=789003&view=rev
Log:
JS-1034: add user prefs import/export to installer; extend user prefs import to support load
on empty registry for migration use case

Modified:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/build.xml

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java?rev=789003&r1=789002&r2=789003&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerApplication.java
Sat Jun 27 17:57:12 2009
@@ -40,7 +40,7 @@
  * <p>-b bootPath : directory to Spring boot files,   overwrite the default assembly/boot/
or bootPath  property in properties file)</p>  
  * <p>-c configPath : directory to Spring config files,   overwrite the default assembly/
or configPath property in properties file)</p>
  * 
- * <p>-O optionstring : overwrite default "ALL,REPLACE"</p>
+ * <p>-O optionstring : overwrite default "ALL"</p>
  * <p>optionstring: 
  *      ALL - extract/import all (with exception of PREFERENCES)
  *      USER - extract/import users, groups, roles
@@ -536,4 +536,4 @@
         }
 
         
-}
\ No newline at end of file
+}

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java?rev=789003&r1=789002&r2=789003&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/JetspeedSerializerSecondaryImpl.java
Sat Jun 27 17:57:12 2009
@@ -191,8 +191,6 @@
 					entities.add(jsEntity);
 
 			}
-			System.out.println("-----processedAnyEntities for PD="
-					+ pd.getName());
 			portlet.setEntities(entities);
 			return portlet;
 
@@ -215,8 +213,6 @@
 		{
 			if (!(Preferences.userRoot().nodeExists(rootForEntity)))
 			{
-				// System.out.println("No preferences exist for entity "+
-				// entity.getId());
 				return jsEntity;
 			}
 
@@ -233,8 +229,6 @@
 					if (permission != null)
 						permissions.add(permission);
 				}
-				System.out.println("processed preferences for entity="
-						+ entity.getId());
 				jsEntity.setEntityPreferences(permissions);
 				return jsEntity;
 				// processPreferenceNode(entity,prefNode,null);
@@ -301,8 +295,6 @@
 	{
 
 		JSApplication app = new JSApplication();
-		System.out.println("--processed PA " + pa.getName() + " with id="
-				+ pa.getId());
 		app.setID(pa.getId().toString());
 		app.setName(pa.getName());
 		/**
@@ -322,13 +314,8 @@
 				JSPortlet p = exportPD(pd);
 				if (p != null)
 				{
-					System.out.println("--processed PA " + pa.getName()
-							+ " with pd=" + pd.getName());
 					portlets.add(p);
-				} else
-					System.out.println("--processed PA " + pa.getName()
-							+ " with NULL pd=" + pd.getName());
-
+				}
 			} catch (Exception e)
 			{
 				throw new SerializerException(
@@ -491,31 +478,32 @@
 							.create("org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"));
 		
 		JSApplications applications = ((JSSecondaryData)this.getSnapshot()).getApplications();
-
 		if (applications == null)
 		{
-			System.out.println("NO DATA!!!!!!");
 			return;
 		}
-		Iterator it = applications.iterator();
-		while (it.hasNext())
-		{
-			JSApplication app = (JSApplication)it.next();
-			MutablePortletApplication portletApp = registry.getPortletApplication(app.getName());
-			if (portletApp != null)
-			{
-				importPA(app,portletApp);
-			}
+
+		// import preferences for registered portlets if applications
+		// have been registered; otherwise, import all preferences
+		boolean importAll = registry.getPortletApplications().isEmpty();
+		if (!applications.isEmpty())
+		{
+		    Iterator it = applications.iterator();
+		    while (it.hasNext())
+		    {
+		        JSApplication app = (JSApplication)it.next();
+		        MutablePortletApplication portletApp = registry.getPortletApplication(app.getName());
+		        if ((portletApp != null) || importAll)
+		        {
+		            importPA(app,portletApp);
+		        }
+		    }
 		}
 	}
 
 	void importPA(JSApplication app, MutablePortletApplication pa)
 	throws SerializerException
 	{
-
-		
-		System.out.println("--processed PA " + pa.getName() + " with id="
-		+ pa.getId());
 		/**
 		 * while more PAs for each portletDef
 		 * list:entityMan:getPortletEntity(pd)
@@ -525,10 +513,17 @@
 		while (pi.hasNext())
 		{
 			JSPortlet portlet = (JSPortlet)pi.next();
-			PortletDefinition pd  = pa.getPortletDefinitionByName(portlet.getName());
-			if (pd != null)
+			if (pa != null)
 			{
-				importPD(portlet,pd); 
+			    PortletDefinition pd  = pa.getPortletDefinitionByName(portlet.getName());
+			    if (pd != null)
+			    {
+			        importPD(portlet,pd); 
+			    }
+			}
+			else
+			{
+                importPD(portlet,null);			    
 			}
 		}
 	}
@@ -541,26 +536,31 @@
 		while (it.hasNext())
 		{
 			JSEntity entity = (JSEntity)it.next();
-			MutablePortletEntity portletEntity = entityAccess.getPortletEntity(entity.getId());
-			if (portletEntity == null)
+			if (pd != null)
 			{
-				portletEntity = entityAccess.newPortletEntityInstance(pd, entity.getId());
-				try
-				{
-					entityAccess.storePortletEntity(portletEntity);
-				}
-				catch (Exception e)
-				{
-					e.printStackTrace();
-				}
+			    MutablePortletEntity portletEntity = entityAccess.getPortletEntity(entity.getId());
+			    if (portletEntity == null)
+			    {
+			        portletEntity = entityAccess.newPortletEntityInstance(pd, entity.getId());
+			        try
+			        {
+			            entityAccess.storePortletEntity(portletEntity);
+			        }
+			        catch (Exception e)
+			        {
+			            e.printStackTrace();
+			        }
+			    }
+			    importEntityPref(entity, portletEntity);
+			}
+			else
+			{
+                importEntityPref(entity, null);			    
 			}
-			// check preferences
-			
-			importEntityPref(entity , portletEntity);
 		}
 	}
 
-	private void importEntityPref(JSEntity entity , MutablePortletEntity portletEntity)
+	private void importEntityPref(JSEntity entity, MutablePortletEntity portletEntity)
 	{
 
 		// do I carry any preferences?
@@ -570,9 +570,9 @@
 		
 		
 		//since I do have preferences let us make sure we have a root node
-		
+		String entityId = ((portletEntity != null) ? portletEntity.getId().toString() : entity.getId().toString());
 		String rootForEntity = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/"
-				+ portletEntity.getId();
+				+ entityId;
 		try
 		{
 			Preferences.userRoot().node(rootForEntity); // will create it if it doesn't exist
@@ -584,7 +584,7 @@
 				JSEntityPreference preference = (JSEntityPreference)it.next();
 				
 				// do we have preferences for this one?
-				importPreferenceNode(preference,portletEntity);
+				importPreferenceNode(preference,entityId);
 			}
 			
 		
@@ -596,13 +596,13 @@
 
 	}
 
-	private void importPreferenceNode(JSEntityPreference preference, MutablePortletEntity entity)
+    private void importPreferenceNode(JSEntityPreference preference, String entityId)
 	{
 
 		String child = preference.getName();
 		
 		String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/"
-				+ entity.getId() + "/" + child + "/"
+				+ entityId + "/" + child + "/"
 				+ PrefsPreference.PORTLET_PREFERENCES_ROOT;
 		Preferences prefNode = Preferences.userRoot().node(prefNodePath);
 
@@ -624,11 +624,9 @@
 				Preference p = preferenceSet.get(key);
 				if ((p == null) || (overwrite))
 				{
-					
 					Vector v = new Vector();
 					v.add(value);
 					preferenceSet.add(key, v);
-System.out.println("Entity " + entity.getId() + " updated with preference " + key + "=" +
value);					
 				}
 			}
 			preferenceSet.flush();

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java?rev=789003&r1=789002&r2=789003&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/serializer/src/java/org/apache/jetspeed/serializer/objects/JSSecondaryData.java
Sat Jun 27 17:57:12 2009
@@ -64,7 +64,6 @@
     public JSSecondaryData()
     {
     	super();
-        System.out.println("JSSecondaryData Class created");
     }
 
     public JSSecondaryData(String name)

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/build.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/build.xml?rev=789003&r1=789002&r2=789003&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/build.xml
(original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/build.xml
Sat Jun 27 17:57:12 2009
@@ -133,12 +133,13 @@
 
   <target name="exportDB" depends="checkDerby,setupAssemblyAndPaths,setupImportClasses"
unless="_derby" if="exportDataDir">
 
-    <echo>Export Jetspeed database to ${exportDataDir}/j2-data.xml</echo>
+    <echo>Export Jetspeed database to ${exportDataDir}/j2-prefs-data.xml</echo>
 
     <mkdir dir="${exportDataDir}"/>
     <java classname="org.apache.jetspeed.serializer.JetspeedSerializerApplication" fork="yes">
       <classpath refid="assemblyClasspath"/>
       <arg line="-E &quot;${exportDataDir}/j2-data.xml&quot; 
+        -O &quot;ALL&quot;
         -a &quot;${basedir}/../webapps/${portalName}&quot;
         -b &quot;file:${basedir}/assembly/boot/&quot;
         -c &quot;file:${basedir}/assembly/&quot;
@@ -148,7 +149,22 @@
         -dp &quot;${_db.password}&quot;" />
     </java>
 
-    <echo>Export Jetspeed database pages to ${exportDataDir}/pages</echo>
+    <echo>Export Jetspeed database to ${exportDataDir}/j2-prefs-data.xml</echo>
+
+    <java classname="org.apache.jetspeed.serializer.JetspeedSerializerApplication" fork="yes">
+      <classpath refid="assemblyClasspath"/>
+      <arg line="-E &quot;${exportDataDir}/j2-prefs-data.xml&quot;
+        -O &quot;PREFS&quot;
+        -a &quot;${basedir}/../webapps/${portalName}&quot;
+        -b &quot;file:${basedir}/assembly/boot/&quot;
+        -c &quot;file:${basedir}/assembly/&quot;
+        -dc &quot;${_jdbc.driver.class}&quot;
+        -ds &quot;${_jdbc.url}&quot;
+        -du &quot;${_db.username}&quot;
+        -dp &quot;${_db.password}&quot;" />
+    </java>
+
+    <echo>Export Jetspeed database pages to ${exportDataDir}/pages directory</echo>
 
     <mkdir dir="${exportDataDir}/pages"/>
     <property name="org.apache.jetspeed.page.import.configuration" value="${basedir}/import/export.properties"/>
@@ -180,11 +196,25 @@
 
   <target name="importDB" depends="checkDerby,setupAssemblyAndPaths,setupImportClasses"
unless="_derby" if="importDataDir">
 
+    <available file="${importDataDir}/j2-data.xml" type="file" property="_importData"/>
+    <antcall target="importData"/>
+    <available file="${importDataDir}/j2-prefs-data.xml" type="file" property="_importPrefs"/>
+    <antcall target="importPrefs"/>
+    <available file="${importDataDir}/pages" type="dir" property="_importPages"/>
+    <antcall target="importPages"/>
+
+    <echo>Import Jetspeed database complete!</echo>
+
+  </target>
+
+  <target name="importData" if="_importData">
+
     <echo>Import Jetspeed database from ${importDataDir}/j2-data.xml</echo>
 
     <java classname="org.apache.jetspeed.serializer.JetspeedSerializerApplication" fork="yes">
       <classpath refid="assemblyClasspath"/>
       <arg line="-I &quot;${importDataDir}/j2-data.xml&quot; 
+        -O &quot;ALL&quot;
         -a &quot;${basedir}/../webapps/${portalName}&quot;
         -b &quot;file:${basedir}/assembly/boot/&quot;
         -c &quot;file:${basedir}/assembly/&quot;
@@ -193,17 +223,30 @@
         -du &quot;${_db.username}&quot;
         -dp &quot;${_db.password}&quot;" />
     </java>
+  </target>
 
-    <echo>Import Jetspeed database pages from ${importDataDir}/pages</echo>
+  <target name="importPrefs" if="_importPrefs">
 
-    <available file="${importDataDir}/pages" type="dir" property="_importPages"/>
-    <antcall target="importPages"/>
-
-    <echo>Import Jetspeed database complete!</echo>
+    <echo>Import Jetspeed database from ${importDataDir}/j2-prefs-data.xml</echo>
 
+    <java classname="org.apache.jetspeed.serializer.JetspeedSerializerApplication" fork="yes">
+      <classpath refid="assemblyClasspath"/>
+      <arg line="-I &quot;${importDataDir}/j2-prefs-data.xml&quot; 
+        -O &quot;PREFS&quot;
+        -a &quot;${basedir}/../webapps/${portalName}&quot;
+        -b &quot;file:${basedir}/assembly/boot/&quot;
+        -c &quot;file:${basedir}/assembly/&quot;
+        -dc &quot;${_jdbc.driver.class}&quot;
+        -ds &quot;${_jdbc.url}&quot;
+        -du &quot;${_db.username}&quot;
+        -dp &quot;${_db.password}&quot;" />
+    </java>
   </target>
 
   <target name="importPages" if="_importPages">
+
+    <echo>Import Jetspeed database pages from ${importDataDir}/pages directory</echo>
+
     <property name="org.apache.jetspeed.page.import.configuration" value="${basedir}/import/import.properties"/>
     <property name="org.apache.jetspeed.page.import.pages" value="${importDataDir}/pages"/>
     <java classname="org.apache.jetspeed.page.PageImporter" fork="yes" dir="${basedir}">



---------------------------------------------------------------------
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