portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r942663 [4/5] - in /portals/jetspeed-2/portal/trunk: components/jetspeed-capability/src/main/java/org/apache/jetspeed/tools/ components/jetspeed-capability/src/main/java/org/apache/jetspeed/tools/migration/ components/jetspeed-db-tools/ com...
Date Mon, 10 May 2010 06:11:50 GMT
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSecurityMigration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSecurityMigration.java?rev=942663&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSecurityMigration.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSecurityMigration.java Mon May 10 06:11:49 2010
@@ -0,0 +1,688 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.migration;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.jetspeed.security.PermissionFactory;
+import org.apache.jetspeed.security.SecurityDomain;
+
+/**
+ * Jetspeed Migration for Security component.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class JetspeedSecurityMigration implements JetspeedMigration
+{
+    private static final int SYSTEM_SECURITY_DOMAIN_ID = 0;
+    private static final int DEFAULT_SECURITY_DOMAIN_ID = 1;
+    
+    private static final char[] CREDENTIAL_VALUE_SCRAMBLER = "Jestspeed-2 is getting ready for release".toCharArray();
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#getName()
+     */
+    public String getName()
+    {
+        return "Security";
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#detectSourceVersion(java.sql.Connection, int)
+     */
+    public int detectSourceVersion(Connection sourceConnection, int sourceVersion) throws SQLException
+    {
+        // detect version of security schema
+        int sourceSecurityVersion = JETSPEED_SCHEMA_VERSION_2_1_3;
+        try
+        {
+            Statement securityDomainQueryStatement = sourceConnection.createStatement();
+            securityDomainQueryStatement.executeQuery("SELECT DOMAIN_ID FROM SECURITY_DOMAIN WHERE DOMAIN_ID = 0;");
+            sourceSecurityVersion = JETSPEED_SCHEMA_VERSION_2_2_0;
+        }
+        catch (SQLException sqle)
+        {
+        }
+        return ((sourceSecurityVersion >= sourceVersion) ? sourceSecurityVersion : sourceVersion);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#migrate(java.sql.Connection, int, java.sql.Connection)
+     */
+    public int migrate(Connection sourceConnection, int sourceVersion, Connection targetConnection) throws SQLException
+    {
+        int rowsMigrated = 0;
+        
+        // SECURITY_DOMAIN
+        int maxSecurityDomainId = -1;
+        PreparedStatement securityDomainInsertStatement = targetConnection.prepareStatement("INSERT INTO SECURITY_DOMAIN (DOMAIN_ID, DOMAIN_NAME, REMOTE, ENABLED, OWNER_DOMAIN_ID) VALUES (?, ?, ?, ?, ?);");
+        Statement securityDomainQueryStatement = sourceConnection.createStatement();
+        ResultSet securityDomainResultSet = null;
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                securityDomainInsertStatement.setInt(1, SYSTEM_SECURITY_DOMAIN_ID);
+                securityDomainInsertStatement.setString(2, SecurityDomain.SYSTEM_NAME);
+                securityDomainInsertStatement.setShort(3, (short)0);
+                securityDomainInsertStatement.setShort(4, (short)1);
+                securityDomainInsertStatement.setNull(5, Types.INTEGER);
+                securityDomainInsertStatement.executeUpdate();
+                rowsMigrated++;
+
+                securityDomainInsertStatement.setInt(1, DEFAULT_SECURITY_DOMAIN_ID);
+                securityDomainInsertStatement.setString(2, SecurityDomain.DEFAULT_NAME);
+                securityDomainInsertStatement.setShort(3, (short)0);
+                securityDomainInsertStatement.setShort(4, (short)1);
+                securityDomainInsertStatement.setNull(5, Types.INTEGER);
+                securityDomainInsertStatement.executeUpdate();
+                rowsMigrated++;
+                maxSecurityDomainId = DEFAULT_SECURITY_DOMAIN_ID;
+                
+                securityDomainResultSet = securityDomainQueryStatement.executeQuery("SELECT NAME FROM SSO_SITE;");
+                while (securityDomainResultSet.next())
+                {
+                    securityDomainInsertStatement.setInt(1, ++maxSecurityDomainId);
+                    securityDomainInsertStatement.setString(2, securityDomainResultSet.getString(1));
+                    securityDomainInsertStatement.setShort(3, (short)1);
+                    securityDomainInsertStatement.setShort(4, (short)1);
+                    securityDomainInsertStatement.setInt(5, DEFAULT_SECURITY_DOMAIN_ID);
+                    securityDomainInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+            }
+            break;
+            case JETSPEED_SCHEMA_VERSION_2_2_0:
+            case JETSPEED_SCHEMA_VERSION_2_2_1:
+            {
+                securityDomainResultSet = securityDomainQueryStatement.executeQuery("SELECT DOMAIN_ID, DOMAIN_NAME, REMOTE, ENABLED, OWNER_DOMAIN_ID FROM SECURITY_DOMAIN;");
+                while (securityDomainResultSet.next())
+                {
+                    securityDomainInsertStatement.setInt(1, securityDomainResultSet.getInt(1));
+                    securityDomainInsertStatement.setString(2, securityDomainResultSet.getString(2));
+                    Static.setNullableShort(securityDomainResultSet, 3, securityDomainInsertStatement);
+                    Static.setNullableShort(securityDomainResultSet, 4, securityDomainInsertStatement);
+                    Static.setNullableInt(securityDomainResultSet, 5, securityDomainInsertStatement);
+                    securityDomainInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+            }
+            break;
+        }
+        securityDomainResultSet.close();
+        securityDomainQueryStatement.close();
+        securityDomainInsertStatement.close();
+        
+        // SECURITY_PRINCIPAL
+        PreparedStatement securityPrincipalInsertStatement = targetConnection.prepareStatement("INSERT INTO SECURITY_PRINCIPAL (PRINCIPAL_ID, PRINCIPAL_TYPE, PRINCIPAL_NAME, IS_MAPPED, IS_ENABLED, IS_READONLY, IS_REMOVABLE, CREATION_DATE, MODIFIED_DATE, DOMAIN_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
+        Statement securityPrincipalQueryStatement = sourceConnection.createStatement();
+        ResultSet securityPrincipalResultSet = null;
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                securityPrincipalResultSet = securityPrincipalQueryStatement.executeQuery("SELECT PRINCIPAL_ID, IS_MAPPING_ONLY, IS_ENABLED, FULL_PATH, CREATION_DATE, MODIFIED_DATE FROM SECURITY_PRINCIPAL;");
+                PreparedStatement ssoSiteNameQueryStatement = sourceConnection.prepareStatement("SELECT NAME FROM SSO_SITE WHERE SITE_ID = ?");
+                PreparedStatement domainQueryStatement = targetConnection.prepareStatement("SELECT DOMAIN_ID FROM SECURITY_DOMAIN WHERE DOMAIN_NAME = ?");
+                while (securityPrincipalResultSet.next())
+                {
+                    String fullPath = securityPrincipalResultSet.getString(4);
+                    String principalType = null;
+                    String principalName = null;
+                    int domainId = DEFAULT_SECURITY_DOMAIN_ID;
+                    if (fullPath.startsWith("/user/"))
+                    {
+                        principalType = "user";
+                        principalName = fullPath.substring(6);
+                    }
+                    else if (fullPath.startsWith("/role/"))
+                    {
+                        principalType = "role";
+                        principalName = fullPath.substring(6);
+                    }
+                    else if (fullPath.startsWith("/group/"))
+                    {
+                        principalType = "group";
+                        principalName = fullPath.substring(7);
+                    }
+                    else if (fullPath.startsWith("/sso/"))
+                    {
+                        principalType = "sso_user";
+                        principalName = fullPath.substring(fullPath.lastIndexOf("/")+1);
+                        int ssoSiteId = Integer.parseInt(fullPath.substring(5, fullPath.indexOf("/", 5)));
+                        
+                        String ssoSiteName = null;
+                        ssoSiteNameQueryStatement.setInt(1, ssoSiteId);
+                        ResultSet ssoSiteNameResultSet = ssoSiteNameQueryStatement.executeQuery();
+                        if (ssoSiteNameResultSet.next())
+                        {
+                            ssoSiteName = ssoSiteNameResultSet.getString(1);
+                        }
+                        else
+                        {
+                            throw new SQLException("Unable to find SSO site name for id: "+ssoSiteId);
+                        }
+                        ssoSiteNameResultSet.close();
+                        
+                        domainQueryStatement.setString(1, ssoSiteName);
+                        ResultSet domainResultSet = domainQueryStatement.executeQuery();
+                        if (domainResultSet.next())
+                        {
+                            domainId = domainResultSet.getInt(1);
+                        }
+                        else
+                        {
+                            throw new SQLException("Unable to find domain id for SSO site name: "+ssoSiteName);
+                        }
+                        domainResultSet.close();
+                    }
+                    if ((principalType != null) && (principalName != null))
+                    {
+                        securityPrincipalInsertStatement.setInt(1, securityPrincipalResultSet.getInt(1));
+                        securityPrincipalInsertStatement.setString(2, principalType);
+                        securityPrincipalInsertStatement.setString(3, principalName);
+                        securityPrincipalInsertStatement.setShort(4, securityPrincipalResultSet.getShort(2));
+                        securityPrincipalInsertStatement.setShort(5, securityPrincipalResultSet.getShort(3));
+                        securityPrincipalInsertStatement.setShort(6, (short)0);
+                        securityPrincipalInsertStatement.setShort(7, (short)1);
+                        securityPrincipalInsertStatement.setTimestamp(8, securityPrincipalResultSet.getTimestamp(5));
+                        securityPrincipalInsertStatement.setTimestamp(9, securityPrincipalResultSet.getTimestamp(6));
+                        securityPrincipalInsertStatement.setInt(10, domainId);
+                        securityPrincipalInsertStatement.executeUpdate();
+                        rowsMigrated++;
+                    }
+                }
+                domainQueryStatement.close();
+                ssoSiteNameQueryStatement.close();
+            }
+            break;
+            case JETSPEED_SCHEMA_VERSION_2_2_0:
+            case JETSPEED_SCHEMA_VERSION_2_2_1:
+            {
+                securityPrincipalResultSet = securityPrincipalQueryStatement.executeQuery("SELECT PRINCIPAL_ID, PRINCIPAL_TYPE, PRINCIPAL_NAME, IS_MAPPED, IS_ENABLED, IS_READONLY, IS_REMOVABLE, CREATION_DATE, MODIFIED_DATE, DOMAIN_ID FROM SECURITY_PRINCIPAL;");
+                while (securityPrincipalResultSet.next())
+                {
+                    securityPrincipalInsertStatement.setInt(1, securityPrincipalResultSet.getInt(1));
+                    securityPrincipalInsertStatement.setString(2, securityPrincipalResultSet.getString(2));
+                    securityPrincipalInsertStatement.setString(3, securityPrincipalResultSet.getString(3));
+                    securityPrincipalInsertStatement.setShort(4, securityPrincipalResultSet.getShort(4));
+                    securityPrincipalInsertStatement.setShort(5, securityPrincipalResultSet.getShort(5));
+                    securityPrincipalInsertStatement.setShort(6, securityPrincipalResultSet.getShort(6));
+                    securityPrincipalInsertStatement.setShort(7, securityPrincipalResultSet.getShort(7));
+                    securityPrincipalInsertStatement.setTimestamp(8, securityPrincipalResultSet.getTimestamp(8));
+                    securityPrincipalInsertStatement.setTimestamp(9, securityPrincipalResultSet.getTimestamp(9));
+                    securityPrincipalInsertStatement.setInt(10, securityPrincipalResultSet.getInt(10));
+                    securityPrincipalInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+            }
+            break;
+        }
+        securityPrincipalResultSet.close();
+        securityPrincipalQueryStatement.close();
+        securityPrincipalInsertStatement.close();
+        
+        // SECURITY_ATTRIBUTE
+        boolean securityAttributeRowsMigrated = false;
+        PreparedStatement securityAttributeInsertStatement = targetConnection.prepareStatement("INSERT INTO SECURITY_ATTRIBUTE (ATTR_ID, PRINCIPAL_ID, ATTR_NAME, ATTR_VALUE) VALUES (?, ?, ?, ?);");
+        Statement securityAttributeQueryStatement = sourceConnection.createStatement();
+        ResultSet securityAttributeResultSet = null;
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                securityAttributeResultSet = securityAttributeQueryStatement.executeQuery("SELECT V.PROPERTY_VALUE_ID, NV.FULL_PATH, V.PROPERTY_NAME, V.PROPERTY_VALUE FROM PREFS_PROPERTY_VALUE V, PREFS_NODE NV WHERE NV.NODE_ID = V.NODE_ID AND NV.FULL_PATH LIKE '%/userinfo';");
+                PreparedStatement principalQueryStatement = targetConnection.prepareStatement("SELECT PRINCIPAL_ID FROM SECURITY_PRINCIPAL WHERE PRINCIPAL_TYPE = ? AND PRINCIPAL_NAME = ?");
+                while (securityAttributeResultSet.next())
+                {
+                    String fullPath = securityAttributeResultSet.getString(2);
+                    String principalType = null;
+                    String principalName = null;
+                    if (fullPath.startsWith("/user/"))
+                    {
+                        principalType = "user";
+                        principalName = fullPath.substring(6, fullPath.length()-9);
+                    }
+                    else if (fullPath.startsWith("/role/"))
+                    {
+                        principalType = "role";
+                        principalName = fullPath.substring(6, fullPath.length()-9);
+                    }
+                    else if (fullPath.startsWith("/group/"))
+                    {
+                        principalType = "group";
+                        principalName = fullPath.substring(7, fullPath.length()-9);
+                    }
+                    if ((principalType != null) && (principalName != null))
+                    {
+                        int principalId = 0;
+                        principalQueryStatement.setString(1, principalType);
+                        principalQueryStatement.setString(2, principalName);
+                        ResultSet principalResultSet = principalQueryStatement.executeQuery();
+                        if (principalResultSet.next())
+                        {
+                            principalId = principalResultSet.getInt(1);
+                        }
+                        else
+                        {
+                            throw new SQLException("Unable to find security principal id for principal: "+principalType+"/"+principalName);
+                        }
+                        principalResultSet.close();
+                    
+                        securityAttributeInsertStatement.setInt(1, securityAttributeResultSet.getInt(1));
+                        securityAttributeInsertStatement.setInt(2, principalId);
+                        securityAttributeInsertStatement.setString(3, securityAttributeResultSet.getString(3));
+                        securityAttributeInsertStatement.setString(4, securityAttributeResultSet.getString(4));
+                        securityAttributeInsertStatement.executeUpdate();
+                        rowsMigrated++;
+                        securityAttributeRowsMigrated = true;
+                    }
+                }                
+                principalQueryStatement.close();
+            }
+            break;
+            case JETSPEED_SCHEMA_VERSION_2_2_0:
+            case JETSPEED_SCHEMA_VERSION_2_2_1:
+            {
+                securityAttributeResultSet = securityAttributeQueryStatement.executeQuery("SELECT ATTR_ID, PRINCIPAL_ID, ATTR_NAME, ATTR_VALUE FROM SECURITY_ATTRIBUTE;");
+                while (securityAttributeResultSet.next())
+                {
+                    securityAttributeInsertStatement.setInt(1, securityAttributeResultSet.getInt(1));
+                    securityAttributeInsertStatement.setInt(2, securityAttributeResultSet.getInt(2));
+                    securityAttributeInsertStatement.setString(3, securityAttributeResultSet.getString(3));
+                    securityAttributeInsertStatement.setString(4, securityAttributeResultSet.getString(4));
+                    securityAttributeInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+            }
+            break;
+        }
+        securityAttributeResultSet.close();
+        securityAttributeQueryStatement.close();
+        securityAttributeInsertStatement.close();
+        
+        // SECURITY_PRINCIPAL_ASSOC
+        PreparedStatement securityPrincipalAssocInsertStatement = targetConnection.prepareStatement("INSERT INTO SECURITY_PRINCIPAL_ASSOC (ASSOC_NAME, FROM_PRINCIPAL_ID, TO_PRINCIPAL_ID) VALUES (?, ?, ?);");
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                Statement securityPrincipalAssocQueryStatement1 = sourceConnection.createStatement();
+                ResultSet securityPrincipalAssocResultSet = securityPrincipalAssocQueryStatement1.executeQuery("SELECT USER_ID, ROLE_ID FROM SECURITY_USER_ROLE;");
+                while (securityPrincipalAssocResultSet.next())
+                {
+                    securityPrincipalAssocInsertStatement.setString(1, "isMemberOf");
+                    securityPrincipalAssocInsertStatement.setInt(2, securityPrincipalAssocResultSet.getInt(1));
+                    securityPrincipalAssocInsertStatement.setInt(3, securityPrincipalAssocResultSet.getInt(2));
+                    securityPrincipalAssocInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+                securityPrincipalAssocResultSet.close();
+                securityPrincipalAssocQueryStatement1.close();
+
+                Statement securityPrincipalAssocQueryStatement2 = sourceConnection.createStatement();
+                securityPrincipalAssocResultSet = securityPrincipalAssocQueryStatement2.executeQuery("SELECT USER_ID, GROUP_ID FROM SECURITY_USER_GROUP;");
+                while (securityPrincipalAssocResultSet.next())
+                {
+                    securityPrincipalAssocInsertStatement.setString(1, "isMemberOf");
+                    securityPrincipalAssocInsertStatement.setInt(2, securityPrincipalAssocResultSet.getInt(1));
+                    securityPrincipalAssocInsertStatement.setInt(3, securityPrincipalAssocResultSet.getInt(2));
+                    securityPrincipalAssocInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+                securityPrincipalAssocResultSet.close();
+                securityPrincipalAssocQueryStatement2.close();
+
+                Statement securityPrincipalAssocQueryStatement3 = sourceConnection.createStatement();
+                securityPrincipalAssocResultSet = securityPrincipalAssocQueryStatement3.executeQuery("SELECT GROUP_ID, ROLE_ID FROM SECURITY_GROUP_ROLE;");
+                while (securityPrincipalAssocResultSet.next())
+                {
+                    securityPrincipalAssocInsertStatement.setString(1, "isMemberOf");
+                    securityPrincipalAssocInsertStatement.setInt(2, securityPrincipalAssocResultSet.getInt(1));
+                    securityPrincipalAssocInsertStatement.setInt(3, securityPrincipalAssocResultSet.getInt(2));
+                    securityPrincipalAssocInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+                securityPrincipalAssocResultSet.close();
+                securityPrincipalAssocQueryStatement3.close();
+                
+                Statement ssoPrincipalQueryStatement = sourceConnection.createStatement();
+                ResultSet ssoPrincipalResultSet = ssoPrincipalQueryStatement.executeQuery("SELECT PRINCIPAL_ID, FULL_PATH FROM SECURITY_PRINCIPAL WHERE FULL_PATH LIKE '/sso/%';");
+                PreparedStatement principalQueryStatement = targetConnection.prepareStatement("SELECT PRINCIPAL_ID FROM SECURITY_PRINCIPAL WHERE PRINCIPAL_TYPE = 'user' AND DOMAIN_ID = "+DEFAULT_SECURITY_DOMAIN_ID+" AND PRINCIPAL_NAME = ?");
+                while (ssoPrincipalResultSet.next())
+                {
+                    String fullPath = ssoPrincipalResultSet.getString(2);
+                    int ssoPrincipalNameIndex = fullPath.lastIndexOf("/");
+                    int principalNameIndex = fullPath.lastIndexOf("/", ssoPrincipalNameIndex-1);
+                    String principalName = fullPath.substring(principalNameIndex+1, ssoPrincipalNameIndex);
+
+                    int principalId = 0;
+                    principalQueryStatement.setString(1, principalName);
+                    ResultSet principalResultSet = principalQueryStatement.executeQuery();
+                    if (principalResultSet.next())
+                    {
+                        principalId = principalResultSet.getInt(1);
+                    }
+                    else
+                    {
+                        throw new SQLException("Unable to find security principal id for principal: "+principalName);
+                    }
+                    principalResultSet.close();
+                    
+                    int ssoPrincipalId = ssoPrincipalResultSet.getInt(1);
+                    securityPrincipalAssocInsertStatement.setString(1, "isRemoteIdFor");
+                    securityPrincipalAssocInsertStatement.setInt(2, ssoPrincipalId);
+                    securityPrincipalAssocInsertStatement.setInt(3, principalId);
+                    securityPrincipalAssocInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+                principalQueryStatement.close();
+                ssoPrincipalResultSet.close();
+                ssoPrincipalQueryStatement.close();
+            }
+            break;
+            case JETSPEED_SCHEMA_VERSION_2_2_0:
+            case JETSPEED_SCHEMA_VERSION_2_2_1:
+            {
+                Statement securityPrincipalAssocQueryStatement = sourceConnection.createStatement();
+                ResultSet securityPrincipalAssocResultSet = securityPrincipalAssocQueryStatement.executeQuery("SELECT ASSOC_NAME, FROM_PRINCIPAL_ID, TO_PRINCIPAL_ID FROM SECURITY_PRINCIPAL_ASSOC;");
+                while (securityPrincipalAssocResultSet.next())
+                {
+                    securityPrincipalAssocInsertStatement.setString(1, securityPrincipalAssocResultSet.getString(1));
+                    securityPrincipalAssocInsertStatement.setInt(2, securityPrincipalAssocResultSet.getInt(2));
+                    securityPrincipalAssocInsertStatement.setInt(3, securityPrincipalAssocResultSet.getInt(3));
+                    securityPrincipalAssocInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+                securityPrincipalAssocResultSet.close();
+                securityPrincipalAssocQueryStatement.close();
+            }
+            break;
+        }
+        securityPrincipalAssocInsertStatement.close();
+        
+        // SECURITY_PERMISSION
+        PreparedStatement securityPermissionInsertStatement = targetConnection.prepareStatement("INSERT INTO SECURITY_PERMISSION (PERMISSION_ID, PERMISSION_TYPE, NAME, ACTIONS) VALUES (?, ?, ?, ?);");
+        Statement securityPermissionQueryStatement = sourceConnection.createStatement();
+        ResultSet securityPermissionResultSet = null;
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                securityPermissionResultSet = securityPermissionQueryStatement.executeQuery("SELECT PERMISSION_ID, CLASSNAME, NAME, ACTIONS FROM SECURITY_PERMISSION;");
+                while (securityPermissionResultSet.next())
+                {
+                    String className = securityPermissionResultSet.getString(2);
+                    String permissionType = null;
+                    if (className.equals("org.apache.jetspeed.security.FolderPermission"))
+                    {
+                        permissionType = PermissionFactory.FOLDER_PERMISSION;
+                    }
+                    else if (className.equals("org.apache.jetspeed.security.PagePermission"))
+                    {
+                        permissionType = PermissionFactory.PAGE_PERMISSION;
+                    }
+                    else if (className.equals("org.apache.jetspeed.security.PortletPermission"))
+                    {
+                        permissionType = PermissionFactory.PORTLET_PERMISSION;
+                    }
+                    else if (className.equals("org.apache.jetspeed.security.FragmentPermission"))
+                    {
+                        permissionType = PermissionFactory.FRAGMENT_PERMISSION;
+                    }
+                    if (permissionType != null)
+                    {
+                        securityPermissionInsertStatement.setInt(1, securityPermissionResultSet.getInt(1));
+                        securityPermissionInsertStatement.setString(2, permissionType);
+                        String name = securityPermissionResultSet.getString(3);
+                        if (permissionType.equals(PermissionFactory.PORTLET_PERMISSION))
+                        {
+                            String migratedPortlet = PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.get(name);
+                            name = ((migratedPortlet != null) ? migratedPortlet : name);
+                        }
+                        securityPermissionInsertStatement.setString(3, securityPermissionResultSet.getString(3));
+                        securityPermissionInsertStatement.setString(4, securityPermissionResultSet.getString(4));
+                        securityPermissionInsertStatement.executeUpdate();
+                        rowsMigrated++;
+                    }
+                }
+            }
+            break;
+            case JETSPEED_SCHEMA_VERSION_2_2_0:
+            case JETSPEED_SCHEMA_VERSION_2_2_1:
+            {
+                securityPermissionResultSet = securityPermissionQueryStatement.executeQuery("SELECT PERMISSION_ID, PERMISSION_TYPE, NAME, ACTIONS FROM SECURITY_PERMISSION;");
+                while (securityPermissionResultSet.next())
+                {
+                    securityPermissionInsertStatement.setInt(1, securityPermissionResultSet.getInt(1));
+                    securityPermissionInsertStatement.setString(2, securityPermissionResultSet.getString(2));
+                    securityPermissionInsertStatement.setString(3, securityPermissionResultSet.getString(3));
+                    securityPermissionInsertStatement.setString(4, securityPermissionResultSet.getString(4));
+                    securityPermissionInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+            }
+            break;
+        }
+        securityPermissionResultSet.close();
+        securityPermissionQueryStatement.close();
+        securityPermissionInsertStatement.close();
+        
+        // PRINCIPAL_PERMISSION
+        PreparedStatement principalPermissionInsertStatement = targetConnection.prepareStatement("INSERT INTO PRINCIPAL_PERMISSION (PRINCIPAL_ID, PERMISSION_ID) VALUES (?, ?);");
+        Statement principalPermissionQueryStatement = sourceConnection.createStatement();
+        ResultSet principalPermissionResultSet = principalPermissionQueryStatement.executeQuery("SELECT PRINCIPAL_ID, PERMISSION_ID FROM PRINCIPAL_PERMISSION;");
+        while (principalPermissionResultSet.next())
+        {
+            principalPermissionInsertStatement.setInt(1, principalPermissionResultSet.getInt(1));
+            principalPermissionInsertStatement.setInt(2, principalPermissionResultSet.getInt(2));
+            principalPermissionInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        principalPermissionResultSet.close();
+        principalPermissionQueryStatement.close();
+        principalPermissionInsertStatement.close();
+
+        // SECURITY_CREDENTIAL
+        PreparedStatement securityCredentialInsertStatement = targetConnection.prepareStatement("INSERT INTO SECURITY_CREDENTIAL (CREDENTIAL_ID, PRINCIPAL_ID, CREDENTIAL_VALUE, TYPE, UPDATE_ALLOWED, IS_STATE_READONLY, UPDATE_REQUIRED, IS_ENCODED, IS_ENABLED, AUTH_FAILURES, IS_EXPIRED, CREATION_DATE, MODIFIED_DATE, PREV_AUTH_DATE, LAST_AUTH_DATE, EXPIRATION_DATE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
+        Statement securityCredentialQueryStatement = sourceConnection.createStatement();
+        ResultSet securityCredentialResultSet = null;
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                securityCredentialResultSet = securityCredentialQueryStatement.executeQuery("SELECT CREDENTIAL_ID, PRINCIPAL_ID, COLUMN_VALUE, TYPE, UPDATE_REQUIRED, IS_ENCODED, IS_ENABLED, AUTH_FAILURES, IS_EXPIRED, CREATION_DATE, MODIFIED_DATE, PREV_AUTH_DATE, LAST_AUTH_DATE, EXPIRATION_DATE FROM SECURITY_CREDENTIAL;");
+                PreparedStatement principalTypeQueryStatement = targetConnection.prepareStatement("SELECT PRINCIPAL_TYPE FROM SECURITY_PRINCIPAL WHERE PRINCIPAL_ID = ?");
+                while (securityCredentialResultSet.next())
+                {
+                    int principalId = securityCredentialResultSet.getInt(2);
+                    String principalType = null;
+                    principalTypeQueryStatement.setInt(1, principalId);
+                    ResultSet principalTypeResultSet = principalTypeQueryStatement.executeQuery();
+                    if (principalTypeResultSet.next())
+                    {
+                        principalType = principalTypeResultSet.getString(1);
+                    }
+                    else
+                    {
+                        throw new SQLException("Unable to find principal type for principal id: "+principalId);
+                    }
+                    principalTypeResultSet.close();
+
+                    String credentialValue = securityCredentialResultSet.getString(3);
+                    boolean encoded = (securityCredentialResultSet.getShort(6) != 0);
+                    if (principalType.equals("sso_user") && !encoded)
+                    {
+                        credentialValue = unscrambleCredentialValue(credentialValue);
+                    }
+                    
+                    securityCredentialInsertStatement.setInt(1, securityCredentialResultSet.getInt(1));
+                    securityCredentialInsertStatement.setInt(2, principalId);
+                    securityCredentialInsertStatement.setString(3, credentialValue);
+                    securityCredentialInsertStatement.setShort(4, securityCredentialResultSet.getShort(4));
+                    securityCredentialInsertStatement.setShort(5, (short)1);
+                    securityCredentialInsertStatement.setShort(6, (short)0);
+                    securityCredentialInsertStatement.setShort(7, securityCredentialResultSet.getShort(5));
+                    securityCredentialInsertStatement.setShort(8, (encoded ? (short)1 : (short)0));
+                    securityCredentialInsertStatement.setShort(9, securityCredentialResultSet.getShort(7));
+                    securityCredentialInsertStatement.setShort(10, securityCredentialResultSet.getShort(8));
+                    securityCredentialInsertStatement.setShort(11, securityCredentialResultSet.getShort(9));
+                    securityCredentialInsertStatement.setTimestamp(12, securityCredentialResultSet.getTimestamp(10));
+                    securityCredentialInsertStatement.setTimestamp(13, securityCredentialResultSet.getTimestamp(11));
+                    securityCredentialInsertStatement.setTimestamp(14, securityCredentialResultSet.getTimestamp(12));
+                    securityCredentialInsertStatement.setTimestamp(15, securityCredentialResultSet.getTimestamp(13));
+                    securityCredentialInsertStatement.setDate(16, securityCredentialResultSet.getDate(14));
+                    securityCredentialInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+                principalTypeQueryStatement.close();
+            }
+            break;
+            case JETSPEED_SCHEMA_VERSION_2_2_0:
+            case JETSPEED_SCHEMA_VERSION_2_2_1:
+            {
+                securityCredentialResultSet = securityCredentialQueryStatement.executeQuery("SELECT CREDENTIAL_ID, PRINCIPAL_ID, CREDENTIAL_VALUE, TYPE, UPDATE_ALLOWED, IS_STATE_READONLY, UPDATE_REQUIRED, IS_ENCODED, IS_ENABLED, AUTH_FAILURES, IS_EXPIRED, CREATION_DATE, MODIFIED_DATE, PREV_AUTH_DATE, LAST_AUTH_DATE, EXPIRATION_DATE FROM SECURITY_CREDENTIAL;");
+                while (securityCredentialResultSet.next())
+                {
+                    securityCredentialInsertStatement.setInt(1, securityCredentialResultSet.getInt(1));
+                    securityCredentialInsertStatement.setInt(2, securityCredentialResultSet.getInt(2));
+                    securityCredentialInsertStatement.setString(3, securityCredentialResultSet.getString(3));
+                    securityCredentialInsertStatement.setShort(4, securityCredentialResultSet.getShort(4));
+                    securityCredentialInsertStatement.setShort(5, securityCredentialResultSet.getShort(5));
+                    securityCredentialInsertStatement.setShort(6, securityCredentialResultSet.getShort(6));
+                    securityCredentialInsertStatement.setShort(7, securityCredentialResultSet.getShort(7));
+                    securityCredentialInsertStatement.setShort(8, securityCredentialResultSet.getShort(8));
+                    securityCredentialInsertStatement.setShort(9, securityCredentialResultSet.getShort(9));
+                    securityCredentialInsertStatement.setShort(10, securityCredentialResultSet.getShort(10));
+                    securityCredentialInsertStatement.setShort(11, securityCredentialResultSet.getShort(11));
+                    securityCredentialInsertStatement.setTimestamp(12, securityCredentialResultSet.getTimestamp(12));
+                    securityCredentialInsertStatement.setTimestamp(13, securityCredentialResultSet.getTimestamp(13));
+                    securityCredentialInsertStatement.setTimestamp(14, securityCredentialResultSet.getTimestamp(14));
+                    securityCredentialInsertStatement.setTimestamp(15, securityCredentialResultSet.getTimestamp(15));
+                    securityCredentialInsertStatement.setDate(16, securityCredentialResultSet.getDate(16));
+                    securityCredentialInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+            }
+            break;
+        }
+        securityCredentialResultSet.close();
+        securityCredentialQueryStatement.close();
+        securityCredentialInsertStatement.close();
+
+        // OJB_HL_SEQ
+        PreparedStatement ojbInsertStatement = targetConnection.prepareStatement("INSERT INTO OJB_HL_SEQ (TABLENAME, FIELDNAME, MAX_KEY, GRAB_SIZE, VERSION) VALUES (?, ?, ?, ?, ?);");
+        Statement ojbQueryStatement = sourceConnection.createStatement();
+        ResultSet ojbResultSet = ojbQueryStatement.executeQuery("SELECT TABLENAME, FIELDNAME, MAX_KEY, GRAB_SIZE, VERSION FROM OJB_HL_SEQ WHERE TABLENAME IN ('SEQ_SECURITY_PRINCIPAL', 'SEQ_SECURITY_ATTRIBUTE', 'SEQ_SECURITY_PERMISSION', 'SEQ_SECURITY_CREDENTIAL', 'SEQ_SECURITY_DOMAIN');");
+        while (ojbResultSet.next())
+        {
+            ojbInsertStatement.setString(1, ojbResultSet.getString(1));
+            ojbInsertStatement.setString(2, ojbResultSet.getString(2));
+            ojbInsertStatement.setInt(3, ojbResultSet.getInt(3));
+            ojbInsertStatement.setInt(4, ojbResultSet.getInt(4));
+            ojbInsertStatement.setInt(5, ojbResultSet.getInt(5));
+            ojbInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        ojbResultSet.close();
+        ojbQueryStatement.close();
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                ojbQueryStatement = sourceConnection.createStatement();
+                ojbResultSet = ojbQueryStatement.executeQuery("SELECT TABLENAME, FIELDNAME, MAX_KEY, GRAB_SIZE, VERSION FROM OJB_HL_SEQ WHERE TABLENAME IN ('SEQ_PREFS_PROPERTY_VALUE');");
+                while (ojbResultSet.next())
+                {
+                    String tableName = ojbResultSet.getString(1);
+                    String migratedTableName = null;
+                    if (tableName.equals("SEQ_PREFS_PROPERTY_VALUE"))
+                    {
+                        if (securityAttributeRowsMigrated)
+                        {
+                            migratedTableName = "SEQ_SECURITY_ATTRIBUTE";
+                        }
+                    }
+                    if (migratedTableName != null)
+                    {
+                        ojbInsertStatement.setString(1, migratedTableName);
+                        ojbInsertStatement.setString(2, ojbResultSet.getString(2));
+                        ojbInsertStatement.setInt(3, ojbResultSet.getInt(3));
+                        ojbInsertStatement.setInt(4, ojbResultSet.getInt(4));
+                        ojbInsertStatement.setInt(5, ojbResultSet.getInt(5));
+                        ojbInsertStatement.executeUpdate();
+                        rowsMigrated++;
+                    }
+                }
+                ojbResultSet.close();
+                ojbQueryStatement.close();
+
+                if (maxSecurityDomainId > -1)
+                {
+                    int grabSize = 20;
+                    int version = (maxSecurityDomainId+(grabSize-1))/grabSize;
+                    int maxKey = version*grabSize;
+                    ojbInsertStatement.setString(1, "SEQ_SECURITY_DOMAIN");
+                    ojbInsertStatement.setString(2, "deprecatedColumn");
+                    ojbInsertStatement.setInt(3, maxKey);
+                    ojbInsertStatement.setInt(4, grabSize);
+                    ojbInsertStatement.setInt(5, version);
+                    ojbInsertStatement.executeUpdate();
+                    rowsMigrated++;                    
+                }
+            }
+            break;
+        }
+        ojbInsertStatement.close();
+        
+        return rowsMigrated;
+    }
+    
+    /**
+     * Unscramble a 2.1.X scrambled SSO remote password.
+     * 
+     * @param credentialValue scrambled credential value
+     * @return clear text password
+     */
+    private String unscrambleCredentialValue(String credentialValue)
+    {
+        byte[] valueBytes = credentialValue.getBytes();
+        valueBytes = Base64.decodeBase64(valueBytes);
+        char[] valueChars = new String(valueBytes).toCharArray();
+        int len = Math.min(valueChars.length, CREDENTIAL_VALUE_SCRAMBLER.length);
+        char[] unscrambledValueChars = new char[len];
+        for (int i = 0; (i < len); i++)
+        {
+            unscrambledValueChars[i] = (char)(valueChars[i]^CREDENTIAL_VALUE_SCRAMBLER[i]);
+        }
+        return new String(unscrambledValueChars);
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSSOSecurityMigration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSSOSecurityMigration.java?rev=942663&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSSOSecurityMigration.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/main/java/org/apache/jetspeed/tools/migration/JetspeedSSOSecurityMigration.java Mon May 10 06:11:49 2010
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.migration;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Jetspeed Migration for SSO Security component.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class JetspeedSSOSecurityMigration implements JetspeedMigration
+{
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#getName()
+     */
+    public String getName()
+    {
+        return "SSO Security";
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#detectSourceVersion(java.sql.Connection, int)
+     */
+    public int detectSourceVersion(Connection sourceConnection, int sourceVersion) throws SQLException
+    {
+        // detect version of security schema
+        int sourceSecurityVersion = JETSPEED_SCHEMA_VERSION_2_1_3;
+        try
+        {
+            Statement securityDomainQueryStatement = sourceConnection.createStatement();
+            securityDomainQueryStatement.executeQuery("SELECT DOMAIN_ID FROM SSO_SITE WHERE SITE_ID = 0;");
+            sourceSecurityVersion = JETSPEED_SCHEMA_VERSION_2_2_0;
+        }
+        catch (SQLException sqle)
+        {
+        }
+        return ((sourceSecurityVersion >= sourceVersion) ? sourceSecurityVersion : sourceVersion);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#migrate(java.sql.Connection, int, java.sql.Connection)
+     */
+    public int migrate(Connection sourceConnection, int sourceVersion, Connection targetConnection) throws SQLException
+    {
+        int rowsMigrated = 0;
+        
+        // SSO_SITE
+        PreparedStatement ssoSiteInsertStatement = targetConnection.prepareStatement("INSERT INTO SSO_SITE (SITE_ID, NAME, URL, ALLOW_USER_SET, REQUIRES_CERTIFICATE, CHALLENGE_RESPONSE_AUTH, FORM_AUTH, FORM_USER_FIELD, FORM_PWD_FIELD, REALM, DOMAIN_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
+        Statement ssoSiteQueryStatement = sourceConnection.createStatement();
+        ResultSet ssoSiteResultSet = null;
+        switch (sourceVersion)
+        {
+            case JETSPEED_SCHEMA_VERSION_2_1_3:
+            case JETSPEED_SCHEMA_VERSION_2_1_4:
+            {
+                ssoSiteResultSet = ssoSiteQueryStatement.executeQuery("SELECT SITE_ID, NAME, URL, ALLOW_USER_SET, REQUIRES_CERTIFICATE, CHALLENGE_RESPONSE_AUTH, FORM_AUTH, FORM_USER_FIELD, FORM_PWD_FIELD, REALM FROM SSO_SITE;");
+                PreparedStatement domainQueryStatement = targetConnection.prepareStatement("SELECT DOMAIN_ID FROM SECURITY_DOMAIN WHERE DOMAIN_NAME = ?");
+                while (ssoSiteResultSet.next())
+                {
+                    String name = ssoSiteResultSet.getString(2);
+                    int domainId = 0;
+                    domainQueryStatement.setString(1, name);
+                    ResultSet domainResultSet = domainQueryStatement.executeQuery();
+                    if (domainResultSet.next())
+                    {
+                        domainId = domainResultSet.getInt(1);
+                    }
+                    else
+                    {
+                        throw new SQLException("Unable to find security domain id for SSO site: "+name);
+                    }
+                    domainResultSet.close();
+                    
+                    ssoSiteInsertStatement.setInt(1, ssoSiteResultSet.getInt(1));
+                    ssoSiteInsertStatement.setString(2, name);
+                    ssoSiteInsertStatement.setString(3, ssoSiteResultSet.getString(3));
+                    Static.setNullableShort(ssoSiteResultSet, 4, ssoSiteInsertStatement);
+                    Static.setNullableShort(ssoSiteResultSet, 5, ssoSiteInsertStatement);
+                    Static.setNullableShort(ssoSiteResultSet, 6, ssoSiteInsertStatement);
+                    Static.setNullableShort(ssoSiteResultSet, 7, ssoSiteInsertStatement);
+                    ssoSiteInsertStatement.setString(8, ssoSiteResultSet.getString(8));
+                    ssoSiteInsertStatement.setString(9, ssoSiteResultSet.getString(9));
+                    ssoSiteInsertStatement.setString(10, ssoSiteResultSet.getString(10));
+                    ssoSiteInsertStatement.setInt(11, domainId);
+                    ssoSiteInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+                domainQueryStatement.close();
+            }
+            break;
+            case JETSPEED_SCHEMA_VERSION_2_2_0:
+            case JETSPEED_SCHEMA_VERSION_2_2_1:
+            {
+                ssoSiteResultSet = ssoSiteQueryStatement.executeQuery("SELECT SITE_ID, NAME, URL, ALLOW_USER_SET, REQUIRES_CERTIFICATE, CHALLENGE_RESPONSE_AUTH, FORM_AUTH, FORM_USER_FIELD, FORM_PWD_FIELD, REALM, DOMAIN_ID FROM SSO_SITE;");
+                while (ssoSiteResultSet.next())
+                {
+                    ssoSiteInsertStatement.setInt(1, ssoSiteResultSet.getInt(1));
+                    ssoSiteInsertStatement.setString(2, ssoSiteResultSet.getString(2));
+                    ssoSiteInsertStatement.setString(3, ssoSiteResultSet.getString(3));
+                    Static.setNullableShort(ssoSiteResultSet, 4, ssoSiteInsertStatement);
+                    Static.setNullableShort(ssoSiteResultSet, 5, ssoSiteInsertStatement);
+                    Static.setNullableShort(ssoSiteResultSet, 6, ssoSiteInsertStatement);
+                    Static.setNullableShort(ssoSiteResultSet, 7, ssoSiteInsertStatement);
+                    ssoSiteInsertStatement.setString(8, ssoSiteResultSet.getString(8));
+                    ssoSiteInsertStatement.setString(9, ssoSiteResultSet.getString(9));
+                    ssoSiteInsertStatement.setString(10, ssoSiteResultSet.getString(10));
+                    ssoSiteInsertStatement.setInt(11, ssoSiteResultSet.getInt(11));
+                    ssoSiteInsertStatement.executeUpdate();
+                    rowsMigrated++;
+                }
+            }
+            break;
+        }
+        ssoSiteResultSet.close();
+        ssoSiteQueryStatement.close();
+        ssoSiteInsertStatement.close();
+        
+        // OJB_HL_SEQ
+        PreparedStatement ojbInsertStatement = targetConnection.prepareStatement("INSERT INTO OJB_HL_SEQ (TABLENAME, FIELDNAME, MAX_KEY, GRAB_SIZE, VERSION) VALUES (?, ?, ?, ?, ?);");
+        Statement ojbQueryStatement = sourceConnection.createStatement();
+        ResultSet ojbResultSet = ojbQueryStatement.executeQuery("SELECT TABLENAME, FIELDNAME, MAX_KEY, GRAB_SIZE, VERSION FROM OJB_HL_SEQ WHERE TABLENAME IN ('SEQ_SSO_SITE');");
+        while (ojbResultSet.next())
+        {
+            ojbInsertStatement.setString(1, ojbResultSet.getString(1));
+            ojbInsertStatement.setString(2, ojbResultSet.getString(2));
+            ojbInsertStatement.setInt(3, ojbResultSet.getInt(3));
+            ojbInsertStatement.setInt(4, ojbResultSet.getInt(4));
+            ojbInsertStatement.setInt(5, ojbResultSet.getInt(5));
+            ojbInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        ojbResultSet.close();
+        ojbQueryStatement.close();
+        ojbInsertStatement.close();
+        
+        return rowsMigrated;
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-statistics/src/main/java/org/apache/jetspeed/tools/migration/JetspeedStatisticsMigration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-statistics/src/main/java/org/apache/jetspeed/tools/migration/JetspeedStatisticsMigration.java?rev=942663&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-statistics/src/main/java/org/apache/jetspeed/tools/migration/JetspeedStatisticsMigration.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-statistics/src/main/java/org/apache/jetspeed/tools/migration/JetspeedStatisticsMigration.java Mon May 10 06:11:49 2010
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.migration;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Jetspeed Migration for Statistics component.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class JetspeedStatisticsMigration implements JetspeedMigration
+{
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#getName()
+     */
+    public String getName()
+    {
+        return "Statistics";
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#detectSourceVersion(java.sql.Connection, int)
+     */
+    public int detectSourceVersion(Connection sourceConnection, int sourceVersion) throws SQLException
+    {
+        // no migration required in statistics schema
+        return ((sourceVersion > JETSPEED_SCHEMA_VERSION_UNKNOWN) ? sourceVersion : JETSPEED_SCHEMA_VERSION_2_1_3);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.migration.JetspeedMigration#migrate(java.sql.Connection, int, java.sql.Connection)
+     */
+    public int migrate(Connection sourceConnection, int sourceVersion, Connection targetConnection) throws SQLException
+    {
+        int rowsMigrated = 0;
+                
+        // PORTLET_STATISTICS
+        PreparedStatement portletStatisticsInsertStatement = targetConnection.prepareStatement("INSERT INTO PORTLET_STATISTICS (IPADDRESS, USER_NAME, TIME_STAMP, PAGE, PORTLET, STATUS, ELAPSED_TIME) VALUES (?, ?, ?, ?, ?, ?, ?);");
+        Statement portletStatisticsQueryStatement = sourceConnection.createStatement();
+        ResultSet portletStatisticsResultSet = portletStatisticsQueryStatement.executeQuery("SELECT IPADDRESS, USER_NAME, TIME_STAMP, PAGE, PORTLET, STATUS, ELAPSED_TIME FROM PORTLET_STATISTICS;");
+        while (portletStatisticsResultSet.next())
+        {
+            portletStatisticsInsertStatement.setString(1, portletStatisticsResultSet.getString(1));
+            portletStatisticsInsertStatement.setString(2, portletStatisticsResultSet.getString(2));
+            portletStatisticsInsertStatement.setTimestamp(3, portletStatisticsResultSet.getTimestamp(3));
+            portletStatisticsInsertStatement.setString(4, portletStatisticsResultSet.getString(4));
+            String portlet = portletStatisticsResultSet.getString(5);
+            switch (sourceVersion)
+            {
+                case JETSPEED_SCHEMA_VERSION_2_1_3:
+                case JETSPEED_SCHEMA_VERSION_2_1_4:
+                {
+                    String migratedPortlet = PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.get(portlet);
+                    portlet = ((migratedPortlet != null) ? migratedPortlet : portlet);
+                }
+                break;
+            }
+            portletStatisticsInsertStatement.setString(5, portlet);
+            Static.setNullableInt(portletStatisticsResultSet, 6, portletStatisticsInsertStatement);
+            Static.setNullableLong(portletStatisticsResultSet, 7, portletStatisticsInsertStatement);
+            portletStatisticsInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        portletStatisticsResultSet.close();
+        portletStatisticsQueryStatement.close();
+        portletStatisticsInsertStatement.close();
+
+        // PAGE_STATISTICS
+        PreparedStatement pageStatisticsInsertStatement = targetConnection.prepareStatement("INSERT INTO PAGE_STATISTICS (IPADDRESS, USER_NAME, TIME_STAMP, PAGE, STATUS, ELAPSED_TIME) VALUES (?, ?, ?, ?, ?, ?);");
+        Statement pageStatisticsQueryStatement = sourceConnection.createStatement();
+        ResultSet pageStatisticsResultSet = pageStatisticsQueryStatement.executeQuery("SELECT IPADDRESS, USER_NAME, TIME_STAMP, PAGE, STATUS, ELAPSED_TIME FROM PAGE_STATISTICS;");
+        while (pageStatisticsResultSet.next())
+        {
+            pageStatisticsInsertStatement.setString(1, pageStatisticsResultSet.getString(1));
+            pageStatisticsInsertStatement.setString(2, pageStatisticsResultSet.getString(2));
+            pageStatisticsInsertStatement.setTimestamp(3, pageStatisticsResultSet.getTimestamp(3));
+            pageStatisticsInsertStatement.setString(4, pageStatisticsResultSet.getString(4));
+            Static.setNullableInt(pageStatisticsResultSet, 5, pageStatisticsInsertStatement);
+            Static.setNullableLong(pageStatisticsResultSet, 6, pageStatisticsInsertStatement);
+            pageStatisticsInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        pageStatisticsResultSet.close();
+        pageStatisticsQueryStatement.close();
+        pageStatisticsInsertStatement.close();
+
+        // USER_STATISTICS
+        PreparedStatement userStatisticsInsertStatement = targetConnection.prepareStatement("INSERT INTO USER_STATISTICS (IPADDRESS, USER_NAME, TIME_STAMP, STATUS, ELAPSED_TIME) VALUES (?, ?, ?, ?, ?);");
+        Statement userStatisticsQueryStatement = sourceConnection.createStatement();
+        ResultSet userStatisticsResultSet = userStatisticsQueryStatement.executeQuery("SELECT IPADDRESS, USER_NAME, TIME_STAMP, STATUS, ELAPSED_TIME FROM USER_STATISTICS;");
+        while (userStatisticsResultSet.next())
+        {
+            userStatisticsInsertStatement.setString(1, userStatisticsResultSet.getString(1));
+            userStatisticsInsertStatement.setString(2, userStatisticsResultSet.getString(2));
+            userStatisticsInsertStatement.setTimestamp(3, userStatisticsResultSet.getTimestamp(3));
+            Static.setNullableInt(userStatisticsResultSet, 4, userStatisticsInsertStatement);
+            Static.setNullableLong(userStatisticsResultSet, 5, userStatisticsInsertStatement);
+            userStatisticsInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        userStatisticsResultSet.close();
+        userStatisticsQueryStatement.close();
+        userStatisticsInsertStatement.close();
+
+        // ADMIN_ACTIVITY
+        PreparedStatement adminActivityInsertStatement = targetConnection.prepareStatement("INSERT INTO ADMIN_ACTIVITY (ACTIVITY, CATEGORY, ADMIN, USER_NAME, TIME_STAMP, IPADDRESS, ATTR_NAME, ATTR_VALUE_BEFORE, ATTR_VALUE_AFTER, DESCRIPTION) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
+        Statement adminActivityQueryStatement = sourceConnection.createStatement();
+        ResultSet adminActivityResultSet = adminActivityQueryStatement.executeQuery("SELECT ACTIVITY, CATEGORY, ADMIN, USER_NAME, TIME_STAMP, IPADDRESS, ATTR_NAME, ATTR_VALUE_BEFORE, ATTR_VALUE_AFTER, DESCRIPTION FROM ADMIN_ACTIVITY;");
+        while (adminActivityResultSet.next())
+        {
+            adminActivityInsertStatement.setString(1, adminActivityResultSet.getString(1));
+            adminActivityInsertStatement.setString(2, adminActivityResultSet.getString(2));
+            adminActivityInsertStatement.setString(3, adminActivityResultSet.getString(3));
+            adminActivityInsertStatement.setString(4, adminActivityResultSet.getString(4));
+            adminActivityInsertStatement.setTimestamp(5, adminActivityResultSet.getTimestamp(5));
+            adminActivityInsertStatement.setString(6, adminActivityResultSet.getString(6));
+            adminActivityInsertStatement.setString(7, adminActivityResultSet.getString(7));
+            adminActivityInsertStatement.setString(8, adminActivityResultSet.getString(8));
+            adminActivityInsertStatement.setString(9, adminActivityResultSet.getString(9));
+            adminActivityInsertStatement.setString(10, adminActivityResultSet.getString(10));
+            adminActivityInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        adminActivityResultSet.close();
+        adminActivityQueryStatement.close();
+        adminActivityInsertStatement.close();
+
+        // USER_ACTIVITY
+        PreparedStatement userActivityInsertStatement = targetConnection.prepareStatement("INSERT INTO USER_ACTIVITY (ACTIVITY, CATEGORY, USER_NAME, TIME_STAMP, IPADDRESS, ATTR_NAME, ATTR_VALUE_BEFORE, ATTR_VALUE_AFTER, DESCRIPTION) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
+        Statement userActivityQueryStatement = sourceConnection.createStatement();
+        ResultSet userActivityResultSet = userActivityQueryStatement.executeQuery("SELECT ACTIVITY, CATEGORY, USER_NAME, TIME_STAMP, IPADDRESS, ATTR_NAME, ATTR_VALUE_BEFORE, ATTR_VALUE_AFTER, DESCRIPTION FROM USER_ACTIVITY;");
+        while (userActivityResultSet.next())
+        {
+            userActivityInsertStatement.setString(1, userActivityResultSet.getString(1));
+            userActivityInsertStatement.setString(2, userActivityResultSet.getString(2));
+            userActivityInsertStatement.setString(3, userActivityResultSet.getString(3));
+            userActivityInsertStatement.setTimestamp(4, userActivityResultSet.getTimestamp(4));
+            userActivityInsertStatement.setString(5, userActivityResultSet.getString(5));
+            userActivityInsertStatement.setString(6, userActivityResultSet.getString(6));
+            userActivityInsertStatement.setString(7, userActivityResultSet.getString(7));
+            userActivityInsertStatement.setString(8, userActivityResultSet.getString(8));
+            userActivityInsertStatement.setString(9, userActivityResultSet.getString(9));
+            userActivityInsertStatement.executeUpdate();
+            rowsMigrated++;
+        }
+        userActivityResultSet.close();
+        userActivityQueryStatement.close();
+        userActivityInsertStatement.close();
+        
+        return rowsMigrated;
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/jetspeed-ant-tasks/src/main/java/org/apache/jetspeed/anttasks/AntInstallerCheckConnection.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-ant-tasks/src/main/java/org/apache/jetspeed/anttasks/AntInstallerCheckConnection.java?rev=942663&r1=942662&r2=942663&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-ant-tasks/src/main/java/org/apache/jetspeed/anttasks/AntInstallerCheckConnection.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-ant-tasks/src/main/java/org/apache/jetspeed/anttasks/AntInstallerCheckConnection.java Mon May 10 06:11:49 2010
@@ -25,17 +25,8 @@ import org.apache.tools.ant.taskdefs.JDB
 
 public class AntInstallerCheckConnection extends JDBCTask
 {
-    public void setDriver(String driver)
-    {
-        super.setDriver(driver);
-    }
-    
     public void execute() throws BuildException
     {
-        setDriver(getProject().getUserProperty("jdbcDriverClass"));
-        setUserid(getProject().getUserProperty("dbUser"));
-        setPassword(getProject().getUserProperty("dbPassword"));
-        setUrl(getProject().getUserProperty("jdbcUrl"));
         try
         {
             getConnection();

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/tools/migration/JetspeedMigration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/tools/migration/JetspeedMigration.java?rev=942663&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/tools/migration/JetspeedMigration.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/tools/migration/JetspeedMigration.java Mon May 10 06:11:49 2010
@@ -0,0 +1,280 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.tools.migration;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Jetspeed Migration interface.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public interface JetspeedMigration
+{
+    static final int JETSPEED_SCHEMA_VERSION_UNKNOWN = 0;
+    static final int JETSPEED_SCHEMA_VERSION_2_1_3 = 213;
+    static final int JETSPEED_SCHEMA_VERSION_2_1_4 = 214;
+    static final int JETSPEED_SCHEMA_VERSION_2_2_0 = 220;
+    static final int JETSPEED_SCHEMA_VERSION_2_2_1 = 221;
+
+    static final Map<String,String> PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP = new HashMap<String,String>();
+    static final Map<String,String> LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP = new HashMap<String,String>();
+    static final Map<String,String> PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP = new HashMap<String,String>();
+
+    /**
+     * Get migration name.
+     * 
+     * @return name
+     */
+    String getName();
+    
+    /**
+     * Detect Jetspeed schema version of source database.
+     * 
+     * @param sourceConnection connection to source database
+     * @param sourceVersion detected minimal source schema version
+     * @return new version detected
+     * @throws SQLException on SQL error or version incompatibility
+     */
+    int detectSourceVersion(Connection sourceConnection, int sourceVersion) throws SQLException;
+    
+    /**
+     * Migrate data from source to target database.
+     * 
+     * @param sourceConnection connection to source database
+     * @param sourceVersion source version
+     * @param targetConnection connection to target database
+     * @return database rows migrated
+     * @throws SQLException on SQL error or version incompatibility
+     */
+    int migrate(Connection sourceConnection, int sourceVersion, Connection targetConnection) throws SQLException;
+
+    /**
+     * Static utility functions class.
+     */
+    class Static
+    {
+        /**
+         * Initialize 2.1.X -> 2.2.X migration mappings. 
+         */
+        static
+        {
+            PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.put("jetspeed-layouts::VelocityTwoColumns2575", "jetspeed-layouts::VelocityTwoColumns");
+            PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.put("demo::ContentViewer", "j2-admin::ContentViewer");
+            PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.put("demo::IFramePortlet", "webcontent::IFramePortlet");
+            PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.put("demo::SSODemoHelp", "j2-admin::SSODemoHelp");
+            PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.put("demo::SSOIFramePortlet", "j2-admin::SSOIFramePortlet");
+            PORTLET_NAME_2_1_X_TO_2_2_X_MIGRATION_MAP.put("demo::SSOWebContentPortlet", "j2-admin::SSOWebContentPortlet");
+
+            LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("blueocean", "jetspeed");
+            LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("jscookmenu", "jetspeed");
+            LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("simple", "jetspeed");
+            LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("sunflower", "jetspeed");
+            LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("thesolution", "jetspeed");
+            LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("tigris", "jetspeed");
+            LAYOUT_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("wap", "jetspeed");
+            
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("blueocean", "jetspeed");
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("dalmation", "jetspeed");
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("greengrass", "jetspeed");
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("metal", "jetspeed");
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("minty-blue", "jetspeed");
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("pretty-single-portlet", "jetspeed");
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("simple", "jetspeed");
+            PORTLET_DECORATOR_2_1_X_TO_2_2_X_MIGRATION_MAP.put("tigris", "jetspeed");
+        }
+        
+        /**
+         * Set nullable integer column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @throws SQLException on error set
+         */
+        static void setNullableInt(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement) throws SQLException
+        {
+            int intColumn = resultSet.getInt(columnIndex);
+            if ((intColumn != 0) || !resultSet.wasNull())
+            {
+                insertStatement.setInt(columnIndex, intColumn);
+            }
+            else
+            {
+                insertStatement.setNull(columnIndex, Types.INTEGER);
+            }
+        }
+    
+        /**
+         * Set nullable integer column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @param insertColumnIndex insert column index
+         * @throws SQLException on error set
+         */
+        static void setNullableInt(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement, int insertColumnIndex) throws SQLException
+        {
+            int intColumn = resultSet.getInt(columnIndex);
+            if ((intColumn != 0) || !resultSet.wasNull())
+            {
+                insertStatement.setInt(insertColumnIndex, intColumn);
+            }
+            else
+            {
+                insertStatement.setNull(insertColumnIndex, Types.INTEGER);
+            }
+        }
+    
+        /**
+         * Set nullable short column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @throws SQLException on error set
+         */
+        static void setNullableShort(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement) throws SQLException
+        {
+            short shortColumn = resultSet.getShort(columnIndex);
+            if ((shortColumn != 0) || !resultSet.wasNull())
+            {
+                insertStatement.setShort(columnIndex, shortColumn);
+            }
+            else
+            {
+                insertStatement.setNull(columnIndex, Types.SMALLINT);
+            }
+        }
+    
+        /**
+         * Set nullable short column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @param insertColumnIndex insert column index
+         * @throws SQLException on error set
+         */
+        static void setNullableShort(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement, int insertColumnIndex) throws SQLException
+        {
+            short shortColumn = resultSet.getShort(columnIndex);
+            if ((shortColumn != 0) || !resultSet.wasNull())
+            {
+                insertStatement.setShort(insertColumnIndex, shortColumn);
+            }
+            else
+            {
+                insertStatement.setNull(insertColumnIndex, Types.SMALLINT);
+            }
+        }
+    
+        /**
+         * Set nullable long column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @throws SQLException on error set
+         */
+        static void setNullableLong(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement) throws SQLException
+        {
+            long longColumn = resultSet.getLong(columnIndex);
+            if ((longColumn != 0) || !resultSet.wasNull())
+            {
+                insertStatement.setLong(columnIndex, longColumn);
+            }
+            else
+            {
+                insertStatement.setNull(columnIndex, Types.BIGINT);
+            }
+        }
+    
+        /**
+         * Set nullable long column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @param insertColumnIndex insert column index
+         * @throws SQLException on error set
+         */
+        static void setNullableLong(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement, int insertColumnIndex) throws SQLException
+        {
+            long longColumn = resultSet.getLong(columnIndex);
+            if ((longColumn != 0) || !resultSet.wasNull())
+            {
+                insertStatement.setLong(insertColumnIndex, longColumn);
+            }
+            else
+            {
+                insertStatement.setNull(insertColumnIndex, Types.BIGINT);
+            }
+        }
+    
+        /**
+         * Set nullable float column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @throws SQLException on error set
+         */
+        static void setNullableFloat(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement) throws SQLException
+        {
+            float floatColumn = resultSet.getFloat(columnIndex);
+            if ((floatColumn != 0.0) || !resultSet.wasNull())
+            {
+                insertStatement.setFloat(columnIndex, floatColumn);
+            }
+            else
+            {
+                insertStatement.setNull(columnIndex, Types.FLOAT);
+            }
+        }
+
+        /**
+         * Set nullable float column from query result set on prepared statement.
+         * 
+         * @param resultSet query result set
+         * @param columnIndex column index
+         * @param insertStatement insert prepared statement
+         * @param insertColumnIndex insert column index
+         * @throws SQLException on error set
+         */
+        static void setNullableFloat(ResultSet resultSet, int columnIndex, PreparedStatement insertStatement, int insertColumnIndex) throws SQLException
+        {
+            float floatColumn = resultSet.getFloat(columnIndex);
+            if ((floatColumn != 0.0) || !resultSet.wasNull())
+            {
+                insertStatement.setFloat(insertColumnIndex, floatColumn);
+            }
+            else
+            {
+                insertStatement.setNull(insertColumnIndex, Types.FLOAT);
+            }
+        }
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-installer/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon May 10 06:11:49 2010
@@ -1,3 +1,4 @@
 resources
 target
 velocity.log*
+ant.install.log



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