com.atlassian.bamboo.legacy
Class LegacyXStreamPersisterBuild110

java.lang.Object
  extended by com.atlassian.bamboo.legacy.LegacyXStreamPersisterBuild110
All Implemented Interfaces:
Startable, BuildPersisterDecorator

public class LegacyXStreamPersisterBuild110
extends Object
implements BuildPersisterDecorator, Startable

This persister is only used in upgrade code. It reads build results from the old file locations & uses the legacy objects instead How dated! :) This then became redundant as of build 110 (0.7)


Nested Class Summary
static class LegacyXStreamPersisterBuild110.AntBuilderMap
           
static class LegacyXStreamPersisterBuild110.MavenBuilderMap
           
static class LegacyXStreamPersisterBuild110.ScriptBuilderMap
           
 
Field Summary
static String BUILD_MAP_XML_FILE
           
static String BUILD_XML_FILE
           
protected  BuilderManager builderManager
           
protected  XStream myXstream
           
 
Constructor Summary
LegacyXStreamPersisterBuild110(File buildDirectory, BuilderManager builderManager)
          Initialised XStream to use aliases for classes to tidy up the resulting XML.
 
Method Summary
 File createBuildDirectory(File buildDir, Date buildDate)
          Create a build subdirectory based on the build date.
 void deleteBuild(Build build)
          Remove the given build's persisted files
 void deleteBuildResults(Build build, long buildNumber)
          Remove the build files for the given build buildNumber.
 Object fromXML(String xml)
          Convert the xml into a java Object instance
 FastBuildDefinitionDirectoryMapper getBuildDirectoryMapper()
          Used in testing
 String getBuildFileName(long buildNumber)
          Create the build number xml file name.
 Iterator getBuildNames()
          Obtain an iterator of the names of the currently persisted builds
 File getBuildResultsFile(Build build, long buildNumber)
           
protected  void init()
           
 BuildResults loadBuildResults(Build build, long buildNumber)
          Load the build buildresults for the given build number
 Collection loadBuilds()
          Get all the persisted builds
 Build loadBuilds(String buildName)
          Load the given build from an xml file.
 void registerClassAlias(String xmlTag, Class tagClass)
          Register an the given xmlTag as an alias for persisting the given tagClass.
 void saveBuild(Build build)
          Save the supplied build
 void saveBuildResults(Build build, BuildResults buildResults)
          Save the build results
 void start()
          Load the build data file map.
 void stop()
          Do nothing!
 String toXML(Object object)
          Convert the java object into its XML form
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myXstream

protected XStream myXstream

builderManager

protected final BuilderManager builderManager

BUILD_MAP_XML_FILE

public static final String BUILD_MAP_XML_FILE
See Also:
Constant Field Values

BUILD_XML_FILE

public static final String BUILD_XML_FILE
See Also:
Constant Field Values
Constructor Detail

LegacyXStreamPersisterBuild110

public LegacyXStreamPersisterBuild110(File buildDirectory,
                                      BuilderManager builderManager)
Initialised XStream to use aliases for classes to tidy up the resulting XML.

Parameters:
buildDirectory -
Method Detail

init

protected void init()

registerClassAlias

public void registerClassAlias(String xmlTag,
                               Class tagClass)
Register an the given xmlTag as an alias for persisting the given tagClass.

Parameters:
xmlTag - The xml tag name
tagClass - The class represented by the tag

fromXML

public Object fromXML(String xml)
Convert the xml into a java Object instance

Parameters:
xml - The xml representation of the object
Returns:
The object

toXML

public String toXML(Object object)
Convert the java object into its XML form

Parameters:
object - The object
Returns:
XML representation of the object

start

public void start()
           throws Exception
Load the build data file map.

Specified by:
start in interface Startable
Throws:
Exception - A generic error

stop

public void stop()
          throws Exception
Do nothing!

Specified by:
stop in interface Startable
Throws:
Exception - A generic error.

saveBuild

public void saveBuild(Build build)
               throws PersisterException
Save the supplied build

Specified by:
saveBuild in interface BuildPersisterDecorator
Parameters:
build - The build to persist as XML
Throws:
PersisterException - Failed to persist

loadBuilds

public Build loadBuilds(String buildName)
                 throws PersisterException
Load the given build from an xml file.

Specified by:
loadBuilds in interface BuildPersisterDecorator
Parameters:
buildName - The build to load
Returns:
The build
Throws:
PersisterException - An error.

saveBuildResults

public void saveBuildResults(Build build,
                             BuildResults buildResults)
                      throws PersisterException
Save the build results

Specified by:
saveBuildResults in interface BuildPersisterDecorator
Parameters:
build - Associate the build with this build
buildResults - The results to save
Throws:
PersisterException - An error

loadBuildResults

public BuildResults loadBuildResults(Build build,
                                     long buildNumber)
                              throws PersisterException
Load the build buildresults for the given build number

Specified by:
loadBuildResults in interface BuildPersisterDecorator
Parameters:
build - The build
buildNumber - The build top load
Returns:
The build results
Throws:
PersisterException - An error

getBuildResultsFile

public File getBuildResultsFile(Build build,
                                long buildNumber)
                         throws PersisterException
Throws:
PersisterException

getBuildNames

public Iterator getBuildNames()
Obtain an iterator of the names of the currently persisted builds

Specified by:
getBuildNames in interface BuildPersisterDecorator
Returns:
The iterator of build names

deleteBuild

public void deleteBuild(Build build)
                 throws PersisterException
Remove the given build's persisted files

Specified by:
deleteBuild in interface BuildPersisterDecorator
Parameters:
build - The build to zap
Throws:
PersisterException - Failed to persist

deleteBuildResults

public void deleteBuildResults(Build build,
                               long buildNumber)
                        throws PersisterException
Remove the build files for the given build buildNumber.

Specified by:
deleteBuildResults in interface BuildPersisterDecorator
Parameters:
build - The build the build belongs to
buildNumber - The number of the build to delete
Throws:
PersisterException - A generic failure

getBuildFileName

public String getBuildFileName(long buildNumber)
Create the build number xml file name.

Parameters:
buildNumber - The number of the build
Returns:
The file name.

createBuildDirectory

public File createBuildDirectory(File buildDir,
                                 Date buildDate)
Create a build subdirectory based on the build date.


loadBuilds

public Collection loadBuilds()
                      throws PersisterException
Description copied from interface: BuildPersisterDecorator
Get all the persisted builds

Specified by:
loadBuilds in interface BuildPersisterDecorator
Returns:
The builds
Throws:
PersisterException - Failed to load

getBuildDirectoryMapper

public FastBuildDefinitionDirectoryMapper getBuildDirectoryMapper()
Used in testing



Copyright © 2006 Atlassian Software Systems. All Rights Reserved.