org.w3c.tools.resources.upgrade
Class Upgrader

java.lang.Object
  extended by org.w3c.tools.resources.upgrade.Upgrader

public class Upgrader
extends java.lang.Object


Field Summary
static boolean debug
           
 
Constructor Summary
Upgrader(java.lang.String server, java.io.File config, java.io.File props, Serializer serializer)
          Constructor
 
Method Summary
protected  void backupStores(java.io.File storedir, java.io.FilenameFilter filter)
          backup the stores under the given store directory.
protected  void checkDir(java.io.File dir)
           
protected  void cleanStores(java.io.File storedir, java.io.FilenameFilter filter)
          clean the stores under the given store directory.
protected  boolean createSubDirs(java.io.File storedir)
          Create the subdirectories under /stores.
protected  java.io.File getNewStore(java.io.File storedir, java.io.File oldstore)
          Get the new store location.
static Attribute getOldAttribute(Attribute attr)
          Get the old attribute relative to the given new kind of attribute.
static int lookupAttribute(java.lang.String name, Attribute[] attributes)
          Get the index of the given attribute in the given attribute array
static void readIndex(java.io.DataInputStream in)
           
static Resource[] readRepository(java.io.File rep)
          Read the resource from a repository.
static Resource readResource(java.io.DataInputStream in)
          load a resoure from the given DataInputStream.
static void unpickleProlog(java.io.DataInputStream in)
           
 void updateEntriesIndex(java.io.File storedir)
          update the index file (in stores)
protected  void updateProperties(int version)
          Update the properties to add the serializer class in it.
 void upgrade(int version)
          The big stuff, upgrade the configuration in XML Upgrade the resource stores Upgrade the indexers (if any) Upgrade the realms (if any) Upgrade the properties files
protected  void upgradeDB(java.io.File storedir, java.io.FilenameFilter filter)
          Upgrade the stores (.db) under the given store directory.
protected  void upgradeStores(java.io.File storedir, java.io.FilenameFilter filter)
          Upgrade the stores (st-xxx) under the given store directory.
static void usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static final boolean debug
See Also:
Constant Field Values
Constructor Detail

Upgrader

public Upgrader(java.lang.String server,
                java.io.File config,
                java.io.File props,
                Serializer serializer)
Constructor

Parameters:
server - the server name
config - the server config directory
props - the server properties file
serializer - the XML Serializer
Method Detail

usage

public static void usage()

lookupAttribute

public static int lookupAttribute(java.lang.String name,
                                  Attribute[] attributes)
Get the index of the given attribute in the given attribute array

Parameters:
name, - the attribute name.
attributes, - the atribute array.
Returns:
an int

getOldAttribute

public static Attribute getOldAttribute(Attribute attr)
                                 throws UpgradeException
Get the old attribute relative to the given new kind of attribute.

Parameters:
attr - the new attribute
Returns:
the old attribute
Throws:
UpgradeException

unpickleProlog

public static void unpickleProlog(java.io.DataInputStream in)
                           throws java.io.IOException
Throws:
java.io.IOException

readIndex

public static void readIndex(java.io.DataInputStream in)
                      throws java.io.IOException
Throws:
java.io.IOException

readResource

public static Resource readResource(java.io.DataInputStream in)
                             throws java.io.IOException,
                                    UpgradeException
load a resoure from the given DataInputStream.

Parameters:
in - the DataInputStream
Returns:
a Resource instance
Throws:
java.io.IOException
UpgradeException

readRepository

public static Resource[] readRepository(java.io.File rep)
                                 throws java.io.FileNotFoundException,
                                        java.io.IOException,
                                        UpgradeException
Read the resource from a repository.

Parameters:
rep - the repository (a File)
Returns:
a Resource array
Throws:
java.io.FileNotFoundException
java.io.IOException
UpgradeException

updateEntriesIndex

public void updateEntriesIndex(java.io.File storedir)
                        throws java.io.IOException,
                               UpgradeException
update the index file (in stores)

Throws:
java.io.IOException - if an IO error occurs
UpgradeException

createSubDirs

protected boolean createSubDirs(java.io.File storedir)
Create the subdirectories under /stores.


getNewStore

protected java.io.File getNewStore(java.io.File storedir,
                                   java.io.File oldstore)
Get the new store location.

Parameters:
oldstore - the Old store.
Returns:
a File instance

upgradeStores

protected void upgradeStores(java.io.File storedir,
                             java.io.FilenameFilter filter)
                      throws UpgradeException
Upgrade the stores (st-xxx) under the given store directory.

Parameters:
storedir - the store directory
filter - the filter to use to list the stores
Throws:
UpgradeException

upgradeDB

protected void upgradeDB(java.io.File storedir,
                         java.io.FilenameFilter filter)
Upgrade the stores (.db) under the given store directory.

Parameters:
storedir - the store directory
filter - the filter to use to list the stores

backupStores

protected void backupStores(java.io.File storedir,
                            java.io.FilenameFilter filter)
                     throws java.io.IOException
backup the stores under the given store directory.

Parameters:
storedir - the store directory
filter - the filter to use to list the stores
Throws:
java.io.IOException

cleanStores

protected void cleanStores(java.io.File storedir,
                           java.io.FilenameFilter filter)
                    throws java.io.IOException
clean the stores under the given store directory.

Parameters:
storedir - the store directory
filter - the filter to use to list the stores
Throws:
java.io.IOException

updateProperties

protected void updateProperties(int version)
Update the properties to add the serializer class in it.


checkDir

protected void checkDir(java.io.File dir)
                 throws UpgradeException
Throws:
UpgradeException

upgrade

public void upgrade(int version)
             throws java.io.IOException,
                    UpgradeException
The big stuff, upgrade the configuration in XML
  1. Upgrade the resource stores
  2. Upgrade the indexers (if any)
  3. Upgrade the realms (if any)
  4. Upgrade the properties files

Throws:
java.io.IOException - if an IO error occurs
UpgradeException