portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r959194 - /portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/tools/migration/JetspeedRegistryMigration.java
Date Wed, 30 Jun 2010 05:30:56 GMT
Author: rwatler
Date: Wed Jun 30 05:30:56 2010
New Revision: 959194

URL: http://svn.apache.org/viewvc?rev=959194&view=rev
Log:
Jetspeed Migration: ensure portlet preference values have owning parent before inserting on
2.1.X to 2.2.X migration since orphan preferences will be dropped

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/tools/migration/JetspeedRegistryMigration.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/tools/migration/JetspeedRegistryMigration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/tools/migration/JetspeedRegistryMigration.java?rev=959194&r1=959193&r2=959194&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/tools/migration/JetspeedRegistryMigration.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/tools/migration/JetspeedRegistryMigration.java
Wed Jun 30 05:30:56 2010
@@ -516,15 +516,30 @@ public class JetspeedRegistryMigration i
             case JETSPEED_SCHEMA_VERSION_2_1_4:
             {
                 portletPreferenceValueResultSet = portletPreferenceValueQueryStatement.executeQuery("SELECT
V.PROPERTY_VALUE_ID, N.NODE_ID, V.PROPERTY_NAME, V.PROPERTY_VALUE FROM PREFS_PROPERTY_VALUE
V, PREFS_NODE N, PREFS_NODE NV WHERE NV.NODE_ID = V.NODE_ID AND NV.FULL_PATH LIKE '%/values'
AND N.NODE_ID = NV.PARENT_NODE_ID");
+                PreparedStatement portletPreferenceIdQueryStatement = targetConnection.prepareStatement("SELECT
ID FROM PORTLET_PREFERENCE WHERE ID = ?");
                 while (portletPreferenceValueResultSet.next())
                 {
-                    portletPreferenceValueInsertStatement.setInt(1, portletPreferenceValueResultSet.getInt(1));
-                    portletPreferenceValueInsertStatement.setInt(2, portletPreferenceValueResultSet.getInt(2));
-                    portletPreferenceValueInsertStatement.setShort(3, Short.parseShort(portletPreferenceValueResultSet.getString(3)));
-                    portletPreferenceValueInsertStatement.setString(4, portletPreferenceValueResultSet.getString(4));
-                    portletPreferenceValueInsertStatement.executeUpdate();
-                    rowsMigrated++;
+                    int portletPreferenceId = portletPreferenceValueResultSet.getInt(2);
+                    portletPreferenceIdQueryStatement.setInt(1, portletPreferenceId);
+                    ResultSet portletPreferenceIdResultSet = portletPreferenceIdQueryStatement.executeQuery();
+                    boolean portletPreferenceIdExists = portletPreferenceIdResultSet.next();
+                    portletPreferenceIdResultSet.close();
+                    
+                    if (portletPreferenceIdExists)
+                    {
+                        portletPreferenceValueInsertStatement.setInt(1, portletPreferenceValueResultSet.getInt(1));
+                        portletPreferenceValueInsertStatement.setInt(2, portletPreferenceId);
+                        portletPreferenceValueInsertStatement.setShort(3, Short.parseShort(portletPreferenceValueResultSet.getString(3)));
+                        portletPreferenceValueInsertStatement.setString(4, portletPreferenceValueResultSet.getString(4));
+                        portletPreferenceValueInsertStatement.executeUpdate();
+                        rowsMigrated++;
+                    }
+                    else
+                    {
+                        rowsDropped++;
+                    }
                 }
+                portletPreferenceIdQueryStatement.close();
             }
             break;
             case JETSPEED_SCHEMA_VERSION_2_2_0:



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