Dekoh platform API

dekoh.portal.install
Class PortalAppsUpdateHelper

java.lang.Object
  extended by com.pramati.bfly.vm.update.UpdateAdapter
      extended by dekoh.portal.install.PortalAppsUpdateHelper
All Implemented Interfaces:
UpdateHandler

public class PortalAppsUpdateHelper
extends UpdateAdapter

PortalAppsUpdateHelper helps in achieving backwards compatability for content applications deployed on Dekoh platform. To use this class applications are expected to do the following.

  1. Quote class name dekoh.portal.install.PortalAppsUpdateHelper in callback-class element of component.xml.
  2. Include file with name sql/create_tables.sql in callback.jar containing SQL statements to create the database tables required by the application.
  3. Each application when it is upgraded is expected to provide the sql files with following naming convention :
     <oldSchemaVersion>_<newSchemaVersion>_migration.sql
     E.g:
     11_12_migration.sql
     12_13_migration.sql
     

    In above example to upgrade a Database schema from version 11 to 13, this class will execute 11_12_migration.sql followed by 12_13_migration.sql.

By overriding method PortalAppsUpdateHelper.getMigrationSQLFileNames(String,String) getMigrationSQLFileNames} application can override the above naming convetion. When the application is installed for the first time the database version will be 1. This value can also be overridden.

Since:
30-Jan-2007

Field Summary
protected  String currentDBVersion
           
 
Fields inherited from interface com.pramati.bfly.vm.api.UpdateHandler
CALLBACK_JAR_NAME
 
Constructor Summary
PortalAppsUpdateHelper()
           
PortalAppsUpdateHelper(PortalDataSource portalDataSource)
           
 
Method Summary
protected  Connection getConnection()
           
protected  String getCurrentDatabaseSchemaVersion()
           
protected  String[] getMigrationSQLFileNames(String oldVersion, String newVersion)
          Return list of SQL file names that will need to be executed to migrate the database between two given versions.
 boolean handleApplicationDBChanges(String applicationId, Version oldVersion, Version newVersion)
           
protected  void handleApplicationDBUpgrade(String applicationId, Version oldVersion, Version newVersion, InstallationDetails installationDetails, Connection connection)
          An version of Application is already installed, will need to migrate the database to preserve backwards compatibility.
protected  void handleFirstTimeApplicationDBInstallation(String applicationName, Version applicationVersion, Connection connection)
          Installing the application for the first time.
 void init(Map initParams)
          This method is currently not used.
 void preInstall(InstallEnv env)
          Invoked before the component is actually installed or updated.
 
Methods inherited from class com.pramati.bfly.vm.update.UpdateAdapter
postInstall, postUninstall, preUninstall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentDBVersion

protected String currentDBVersion
Constructor Detail

PortalAppsUpdateHelper

public PortalAppsUpdateHelper()

PortalAppsUpdateHelper

public PortalAppsUpdateHelper(PortalDataSource portalDataSource)
Method Detail

init

public void init(Map initParams)
Description copied from interface: UpdateHandler
This method is currently not used.

Specified by:
init in interface UpdateHandler
Overrides:
init in class UpdateAdapter

preInstall

public void preInstall(InstallEnv env)
                throws InstallationException
Description copied from interface: UpdateHandler
Invoked before the component is actually installed or updated. This callback can be used to perform migration during update operations, or perform other pre installation tasks.

Specified by:
preInstall in interface UpdateHandler
Overrides:
preInstall in class UpdateAdapter
Parameters:
env -
Throws:
InstallationException

handleApplicationDBChanges

public boolean handleApplicationDBChanges(String applicationId,
                                          Version oldVersion,
                                          Version newVersion)
                                   throws InstallationException
Parameters:
applicationId -
oldVersion -
newVersion -
Returns:
true if schema sussessfully changed, false if no schem change was required
Throws:
InstallationException

handleFirstTimeApplicationDBInstallation

protected void handleFirstTimeApplicationDBInstallation(String applicationName,
                                                        Version applicationVersion,
                                                        Connection connection)
                                                 throws InstallationException
Installing the application for the first time. Create necessary tabels, add a record to the DB and update Installtion Details

Parameters:
applicationName -
applicationVersion -
connection -
Throws:
InstallationException

getCurrentDatabaseSchemaVersion

protected String getCurrentDatabaseSchemaVersion()

handleApplicationDBUpgrade

protected void handleApplicationDBUpgrade(String applicationId,
                                          Version oldVersion,
                                          Version newVersion,
                                          InstallationDetails installationDetails,
                                          Connection connection)
                                   throws RequiredSQLFilesNotFoundException,
                                          InstallationException
An version of Application is already installed, will need to migrate the database to preserve backwards compatibility.

Parameters:
applicationId -
oldVersion -
newVersion -
installationDetails -
connection -
Throws:
InstallationException - Execution of one of the SQL statements in the migration sql file fails
RequiredSQLFilesNotFoundException - when the migration SQL files are not found packaged with callback.jar of given application

getMigrationSQLFileNames

protected String[] getMigrationSQLFileNames(String oldVersion,
                                            String newVersion)
Return list of SQL file names that will need to be executed to migrate the database between two given versions.

Parameters:
oldVersion -
newVersion -
Returns:

getConnection

protected Connection getConnection()

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers