org.apache.jetspeed.serializer
Class JetspeedSerializerBase

java.lang.Object
  extended by org.apache.jetspeed.serializer.JetspeedSerializerBase
Direct Known Subclasses:
JetspeedSerializerImpl, JetspeedSerializerSecondaryImpl

public abstract class JetspeedSerializerBase
extends Object


Field Summary
private  org.apache.jetspeed.components.ComponentManager cm
           
private  String currentIndent
          current indent for XML files - defaults to tab
private static String ENCODING_STRING
           
private  boolean initialized
           
private static String JETSPEED
           
protected static org.apache.commons.logging.Log log
          Logger
private  HashMap processSettings
          export/import instructions
(package private)  int refCouter
           
private  Object sem
           
private  JSSnapshot snapshot
          the main wrapper class for an XML file
 
Constructor Summary
JetspeedSerializerBase()
           
JetspeedSerializerBase(org.apache.jetspeed.components.ComponentManager cm)
          hand over existing component manager
JetspeedSerializerBase(String appRoot, String[] bootConfig, String[] appConfig)
          This constructor takes the application root, the search path for the boot component configuration files and the search path for the application component configuration files.
 
Method Summary
protected  void checkSettings(Map settings)
          set instruction flags to new settings
 void closeUp()
           
protected  String createUniqueBackupFilename(String name)
          Helper routine to create a unique filename for a backup of an existing filename....not intended to be rocket science...
protected  void doBackupOfCurrent(String importFileName, Map currentSettings)
          create a backup of the current environment in case the import fails
 void exportData(String name, String exportFileName, Map settings)
           
protected  org.apache.jetspeed.components.ComponentManager getCM()
           
 String getDefaultIndent()
           
protected  Object getObjectBehindPath(Map map, String _fullPath)
          simple lookup for object from a map
protected abstract  Class getSerializerDataClass()
          return the class for the serializer data , for example JSSeedData.class)
protected abstract  String getSerializerDataTag()
          return the XML tag for the serializer data , for example "JSSnapShot")
 boolean getSetting(String key)
          returns the key for a particular process setting.
 JSSnapshot getSnapshot()
           
protected  void getSnapshotData()
          On import, get the basic SnapShot data
protected  ArrayList getTokens(String _line)
          convert a list of elements in a string, seperated by ',' into an arraylist of strings
 void importData(String importFileName, Map settings)
           
 void initializeComponentManager(String appRoot, String[] bootConfig, String[] appConfig)
           
protected  void logMe(String text)
          just a Simple helper to make code more readable
protected  javolution.xml.XMLObjectWriter openWriter(String filename)
          create or open a given file for writing
protected abstract  void processExport(String name, javolution.xml.XMLBinding binding)
          The workhorse for exporting data
protected abstract  void processImport()
          The workhorse for importing data
protected  JSSnapshot readFile(String importFileName, javolution.xml.XMLBinding binding)
          read a snapshot and return the reconstructed class tree
protected  String recreatePassword(char[] savedPassword)
           
protected  String removeFromString(String base, String excess)
          remove a given sequence from the beginning of a string
protected abstract  void resetSettings()
          reset instruction flags to default settings (all true)
 void setComponentManager(org.apache.jetspeed.components.ComponentManager cm)
           
 void setDefaultIndent(String indent)
           
protected  void setSetting(String key, boolean value)
          set a process setting for a given key
 void setSnapshot(JSSnapshot snapshot)
           
protected  void setSnapshotData()
          On export, set the basic SnapShot data
protected abstract  void setupAliases(javolution.xml.XMLBinding binding)
          Setup the binding for the different classes, mapping each extracted class to a unique tag name in the XML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Logger


cm

private org.apache.jetspeed.components.ComponentManager cm

sem

private Object sem

refCouter

int refCouter

snapshot

private JSSnapshot snapshot
the main wrapper class for an XML file


processSettings

private HashMap processSettings
export/import instructions


initialized

private boolean initialized

currentIndent

private String currentIndent
current indent for XML files - defaults to tab


ENCODING_STRING

private static String ENCODING_STRING

JETSPEED

private static String JETSPEED
Constructor Detail

JetspeedSerializerBase

public JetspeedSerializerBase()

JetspeedSerializerBase

public JetspeedSerializerBase(org.apache.jetspeed.components.ComponentManager cm)
hand over existing component manager

Parameters:
cm -

JetspeedSerializerBase

public JetspeedSerializerBase(String appRoot,
                              String[] bootConfig,
                              String[] appConfig)
                       throws org.apache.jetspeed.serializer.SerializerException
This constructor takes the application root, the search path for the boot component configuration files and the search path for the application component configuration files.

For example: new JetspeedSerializerSecondaryImpl("./", "assembly/boot/*.xml", "assembly/*.xml") will establish the current directory as the root, process all xml files in the assembly/boot directory before processing all xml files in the assembly directory itself.

Parameters:
appRoot - working directory
bootConfig - boot (primary) file or files (wildcards are allowed)
appConfig - application (secondary) file or files (wildcards are allowed)
Throws:
org.apache.jetspeed.serializer.SerializerException
Method Detail

getCM

protected final org.apache.jetspeed.components.ComponentManager getCM()

initializeComponentManager

public final void initializeComponentManager(String appRoot,
                                             String[] bootConfig,
                                             String[] appConfig)
                                      throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

setComponentManager

public final void setComponentManager(org.apache.jetspeed.components.ComponentManager cm)

closeUp

public final void closeUp()

setDefaultIndent

public final void setDefaultIndent(String indent)

getDefaultIndent

public final String getDefaultIndent()

importData

public final void importData(String importFileName,
                             Map settings)
                      throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

exportData

public final void exportData(String name,
                             String exportFileName,
                             Map settings)
                      throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

doBackupOfCurrent

protected final void doBackupOfCurrent(String importFileName,
                                       Map currentSettings)
create a backup of the current environment in case the import fails


readFile

protected final JSSnapshot readFile(String importFileName,
                                    javolution.xml.XMLBinding binding)
                             throws org.apache.jetspeed.serializer.SerializerException
read a snapshot and return the reconstructed class tree

Parameters:
importFileName -
Throws:
SerializerException

openWriter

protected final javolution.xml.XMLObjectWriter openWriter(String filename)
                                                   throws org.apache.jetspeed.serializer.SerializerException
create or open a given file for writing

Throws:
org.apache.jetspeed.serializer.SerializerException

getSetting

public final boolean getSetting(String key)
returns the key for a particular process setting. False if the key doesn't exist.

Parameters:
key -
Returns:

setSetting

protected final void setSetting(String key,
                                boolean value)
set a process setting for a given key

Parameters:
key - instruction to set
value - true or false

checkSettings

protected final void checkSettings(Map settings)
set instruction flags to new settings

Parameters:
settings -

getSnapshotData

protected void getSnapshotData()
On import, get the basic SnapShot data


setSnapshotData

protected void setSnapshotData()
On export, set the basic SnapShot data


getObjectBehindPath

protected final Object getObjectBehindPath(Map map,
                                           String _fullPath)
simple lookup for object from a map

Parameters:
map -
_fullPath -
Returns:

removeFromString

protected final String removeFromString(String base,
                                        String excess)
remove a given sequence from the beginning of a string


logMe

protected final void logMe(String text)
just a Simple helper to make code more readable

Parameters:
text -

createUniqueBackupFilename

protected final String createUniqueBackupFilename(String name)
Helper routine to create a unique filename for a backup of an existing filename....not intended to be rocket science...

Parameters:
name -
Returns:

getTokens

protected final ArrayList getTokens(String _line)
convert a list of elements in a string, seperated by ',' into an arraylist of strings

Parameters:
_line - Strinbg containing one or more elements seperated by ','
Returns:
list of elements of null

recreatePassword

protected final String recreatePassword(char[] savedPassword)

resetSettings

protected abstract void resetSettings()
reset instruction flags to default settings (all true)


processExport

protected abstract void processExport(String name,
                                      javolution.xml.XMLBinding binding)
                               throws org.apache.jetspeed.serializer.SerializerException
The workhorse for exporting data

Parameters:
binding - established XML binding
Throws:
SerializerException

processImport

protected abstract void processImport()
                               throws org.apache.jetspeed.serializer.SerializerException
The workhorse for importing data

Parameters:
binding - established XML binding
Throws:
SerializerException

setupAliases

protected abstract void setupAliases(javolution.xml.XMLBinding binding)
Setup the binding for the different classes, mapping each extracted class to a unique tag name in the XML

Parameters:
binding -

getSerializerDataClass

protected abstract Class getSerializerDataClass()
return the class for the serializer data , for example JSSeedData.class)

Returns:

getSerializerDataTag

protected abstract String getSerializerDataTag()
return the XML tag for the serializer data , for example "JSSnapShot")

Returns:

getSnapshot

public JSSnapshot getSnapshot()

setSnapshot

public void setSnapshot(JSSnapshot snapshot)


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.