hudson.plugins.jobConfigHistory
Class FileHistoryDao

java.lang.Object
  extended by hudson.plugins.jobConfigHistory.FileHistoryDao
All Implemented Interfaces:
HistoryDao, ItemListenerHistoryDao, NodeListenerHistoryDao, OverviewHistoryDao

public class FileHistoryDao
extends Object
implements HistoryDao, ItemListenerHistoryDao, OverviewHistoryDao, NodeListenerHistoryDao

Defines some helper functions needed by JobConfigHistoryJobListener and JobConfigHistorySaveableListener.

Author:
mfriedenhagen

Method Summary
 void copyHistoryAndDelete(String oldName, String newName)
          Copies the history files of a restored project from the old location (_deleted_) to a directory with the new name and deletes the old entries.
 void copyNodeHistoryAndDelete(String oldName, String newName)
          Copies the history files of a restored node from the old location (_deleted_) to a directory with the new name and deletes the old entries.
 void createNewItem(hudson.model.Item item)
          Adds and saves the initial configuration of an item.
 void createNewNode(hudson.model.Node node)
          Adds and saves the initial configuration of a node.
 void deleteItem(hudson.model.Item item)
          Deletes the history of an item.
 void deleteNode(hudson.model.Node node)
          Deletes the history of an node.
 File[] getDeletedJobs(String folderName)
          Returns a list of deleted jobs with a history.
 File[] getDeletedNodes(String folderName)
          Returns a list of deleted nodes with a history.
 SortedMap<String,HistoryDescr> getJobHistory(String jobName)
          Returns a sorted map of all HistoryDescr for a given job.
 File[] getJobs(String folderName)
          Returns a list of jobs with a history.
 SortedMap<String,HistoryDescr> getNodeHistory(String nodeName)
          Returns a sorted map of all HistoryDescr for a given node.
 File[] getNodes(String folderName)
          Returns a list of nodes with a history.
 hudson.XmlFile getOldRevision(hudson.model.AbstractItem item, String identifier)
          Returns one old configuration of item.
 hudson.XmlFile getOldRevision(File configFile, String identifier)
          Returns one old configuration of file.
 hudson.XmlFile getOldRevision(hudson.model.Node node, String identifier)
          Returns one old configuration of node.
 hudson.XmlFile getOldRevision(String configFileName, String identifier)
          Returns one old configuration of file.
 hudson.XmlFile getOldRevision(hudson.XmlFile xmlFile, String identifier)
          Returns one old configuration of xmlFile.
 SortedMap<String,HistoryDescr> getRevisions(File configFile)
          Returns a sorted map of all revisions for this configFile.
 SortedMap<String,HistoryDescr> getRevisions(hudson.model.Node node)
          Returns a sorted map of all revisions for this node.
 SortedMap<String,HistoryDescr> getRevisions(hudson.XmlFile xmlFile)
          Returns a sorted map of all revisions for this xmlFile.
 File[] getSystemConfigs()
          Returns a list of all system configuration files with a history.
 SortedMap<String,HistoryDescr> getSystemHistory(String name)
          Returns a sorted map of all HistoryDescr for a given system configuration.
 boolean hasOldRevision(hudson.model.AbstractItem item, String identifier)
          Returns whether the revision exists.
 boolean hasOldRevision(File configFile, String identifier)
          Returns whether the revision exists.
 boolean hasOldRevision(hudson.model.Node node, String identifier)
          Returns whether the revision exists.
 boolean hasOldRevision(hudson.XmlFile xmlFile, String identifier)
          Returns whether the revision exists.
 boolean isCreatedEntry(File historyDir)
          Checks whether the respective history entry is a 'Created' entry.
 void purgeOldEntries(File itemHistoryRoot, int maxEntries)
          Purges old entries for the given history root to maxEntries.
 void renameItem(hudson.model.Item item, String oldName, String newName)
          Save and renames the item.
 void renameNode(hudson.model.Node node, String oldName, String newName)
          Save and renames the node.
 void saveItem(hudson.model.AbstractItem item)
          Saves the current configuration of an item.
 void saveItem(hudson.XmlFile file)
          Saves a copy of an xml file.
 void saveNode(hudson.model.Node node)
          Saves the current configuration of an node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createNewItem

public void createNewItem(hudson.model.Item item)
Description copied from interface: ItemListenerHistoryDao
Adds and saves the initial configuration of an item.

Specified by:
createNewItem in interface ItemListenerHistoryDao
Parameters:
item - project

saveItem

public void saveItem(hudson.model.AbstractItem item)
Description copied from interface: HistoryDao
Saves the current configuration of an item.

Specified by:
saveItem in interface HistoryDao
Parameters:
item - project

saveItem

public void saveItem(hudson.XmlFile file)
Description copied from interface: HistoryDao
Saves a copy of an xml file.

Specified by:
saveItem in interface HistoryDao
Parameters:
file - xmlFile

deleteItem

public void deleteItem(hudson.model.Item item)
Description copied from interface: ItemListenerHistoryDao
Deletes the history of an item.

Specified by:
deleteItem in interface ItemListenerHistoryDao
Parameters:
item - project

renameItem

public void renameItem(hudson.model.Item item,
                       String oldName,
                       String newName)
Description copied from interface: ItemListenerHistoryDao
Save and renames the item.

Specified by:
renameItem in interface ItemListenerHistoryDao
Parameters:
item - project
oldName - old project name
newName - new name

getRevisions

public SortedMap<String,HistoryDescr> getRevisions(hudson.XmlFile xmlFile)
Description copied from interface: HistoryDao
Returns a sorted map of all revisions for this xmlFile. The key is an identifier which may be used in HistoryDao.getOldRevision(hudson.model.AbstractItem, java.lang.String)

Specified by:
getRevisions in interface HistoryDao
Parameters:
xmlFile - file
Returns:
old revisions mapped to the identifier.

getRevisions

public SortedMap<String,HistoryDescr> getRevisions(File configFile)
Description copied from interface: HistoryDao
Returns a sorted map of all revisions for this configFile. The key is an identifier which may be used in HistoryDao.getOldRevision(hudson.model.AbstractItem, java.lang.String)

Specified by:
getRevisions in interface HistoryDao
Parameters:
configFile - file
Returns:
old revisions mapped to the identifier.

getOldRevision

public hudson.XmlFile getOldRevision(hudson.model.AbstractItem item,
                                     String identifier)
Description copied from interface: HistoryDao
Returns one old configuration of item.

Specified by:
getOldRevision in interface HistoryDao
Parameters:
item - project
identifier - timestamp or hash
Returns:
old configuration.

getOldRevision

public hudson.XmlFile getOldRevision(hudson.XmlFile xmlFile,
                                     String identifier)
Description copied from interface: HistoryDao
Returns one old configuration of xmlFile.

Specified by:
getOldRevision in interface HistoryDao
Parameters:
xmlFile - file
identifier - timestamp or hash
Returns:
old configuration.

getOldRevision

public hudson.XmlFile getOldRevision(File configFile,
                                     String identifier)
Description copied from interface: HistoryDao
Returns one old configuration of file.

Specified by:
getOldRevision in interface HistoryDao
Parameters:
configFile - file
identifier - timestamp or hash
Returns:
old configuration.

getOldRevision

public hudson.XmlFile getOldRevision(String configFileName,
                                     String identifier)
Description copied from interface: HistoryDao
Returns one old configuration of file.

Specified by:
getOldRevision in interface HistoryDao
Parameters:
configFileName - file
identifier - timestamp or hash
Returns:
old configuration.

hasOldRevision

public boolean hasOldRevision(hudson.model.AbstractItem item,
                              String identifier)
Description copied from interface: HistoryDao
Returns whether the revision exists.

Specified by:
hasOldRevision in interface HistoryDao
Parameters:
item - project
identifier - timestamp or hash
Returns:
old configuration.

hasOldRevision

public boolean hasOldRevision(hudson.XmlFile xmlFile,
                              String identifier)
Description copied from interface: HistoryDao
Returns whether the revision exists.

Specified by:
hasOldRevision in interface HistoryDao
Parameters:
xmlFile - file
identifier - timestamp or hash
Returns:
old configuration.

hasOldRevision

public boolean hasOldRevision(File configFile,
                              String identifier)
Description copied from interface: HistoryDao
Returns whether the revision exists.

Specified by:
hasOldRevision in interface HistoryDao
Parameters:
configFile - file
identifier - timestamp or hash
Returns:
old configuration.

purgeOldEntries

public void purgeOldEntries(File itemHistoryRoot,
                            int maxEntries)
Description copied from interface: HistoryDao
Purges old entries for the given history root to maxEntries.

Specified by:
purgeOldEntries in interface HistoryDao
Parameters:
itemHistoryRoot - directory to inspect.
maxEntries - maximum number of entries.

isCreatedEntry

public boolean isCreatedEntry(File historyDir)
Description copied from interface: HistoryDao
Checks whether the respective history entry is a 'Created' entry.

Specified by:
isCreatedEntry in interface HistoryDao
Parameters:
historyDir - The directory, e.g. 2013-01-18_17-33-51
Returns:
True if the directory contains a 'Created' entry.

getDeletedJobs

public File[] getDeletedJobs(String folderName)
Description copied from interface: OverviewHistoryDao
Returns a list of deleted jobs with a history.

Specified by:
getDeletedJobs in interface OverviewHistoryDao
Parameters:
folderName - name of folder.
Returns:
list of deleted jobs with a history, emtpy when no history exists.

getJobs

public File[] getJobs(String folderName)
Description copied from interface: OverviewHistoryDao
Returns a list of jobs with a history.

Specified by:
getJobs in interface OverviewHistoryDao
Parameters:
folderName - name of folder
Returns:
list of jobs with a history, emtpy when no history exists.

getSystemConfigs

public File[] getSystemConfigs()
Description copied from interface: OverviewHistoryDao
Returns a list of all system configuration files with a history.

Specified by:
getSystemConfigs in interface OverviewHistoryDao
Returns:
list of all system configuration files with a history, emtpy when no history exists.

getJobHistory

public SortedMap<String,HistoryDescr> getJobHistory(String jobName)
Description copied from interface: OverviewHistoryDao
Returns a sorted map of all HistoryDescr for a given job.

Specified by:
getJobHistory in interface OverviewHistoryDao
Parameters:
jobName - of the job
Returns:
sorted map.

getSystemHistory

public SortedMap<String,HistoryDescr> getSystemHistory(String name)
Description copied from interface: OverviewHistoryDao
Returns a sorted map of all HistoryDescr for a given system configuration.

Specified by:
getSystemHistory in interface OverviewHistoryDao
Parameters:
name - of the configuration
Returns:
sorted map.

copyHistoryAndDelete

public void copyHistoryAndDelete(String oldName,
                                 String newName)
Description copied from interface: HistoryDao
Copies the history files of a restored project from the old location (_deleted_) to a directory with the new name and deletes the old entries.

Specified by:
copyHistoryAndDelete in interface HistoryDao
Parameters:
oldName - The old name of the project (containing "_deleted_")
newName - The new name of the project

createNewNode

public void createNewNode(hudson.model.Node node)
Description copied from interface: NodeListenerHistoryDao
Adds and saves the initial configuration of a node.

Specified by:
createNewNode in interface NodeListenerHistoryDao
Parameters:
node - node

deleteNode

public void deleteNode(hudson.model.Node node)
Description copied from interface: NodeListenerHistoryDao
Deletes the history of an node.

Specified by:
deleteNode in interface NodeListenerHistoryDao
Parameters:
node - node

renameNode

public void renameNode(hudson.model.Node node,
                       String oldName,
                       String newName)
Description copied from interface: NodeListenerHistoryDao
Save and renames the node.

Specified by:
renameNode in interface NodeListenerHistoryDao
Parameters:
node - node
oldName - old node name
newName - new name

getRevisions

public SortedMap<String,HistoryDescr> getRevisions(hudson.model.Node node)
Description copied from interface: HistoryDao
Returns a sorted map of all revisions for this node. The key is an identifier which may be used in HistoryDao.getOldRevision(hudson.model.Node, java.lang.String)

Specified by:
getRevisions in interface HistoryDao
Parameters:
node - node
Returns:
old revisions mapped to the identifier.

copyNodeHistoryAndDelete

public void copyNodeHistoryAndDelete(String oldName,
                                     String newName)
Description copied from interface: HistoryDao
Copies the history files of a restored node from the old location (_deleted_) to a directory with the new name and deletes the old entries.

Specified by:
copyNodeHistoryAndDelete in interface HistoryDao
Parameters:
oldName - The old name of the node (containing "_deleted_")
newName - The new name of the node

saveNode

public void saveNode(hudson.model.Node node)
Description copied from interface: HistoryDao
Saves the current configuration of an node.

Specified by:
saveNode in interface HistoryDao
Parameters:
node - node

getOldRevision

public hudson.XmlFile getOldRevision(hudson.model.Node node,
                                     String identifier)
Description copied from interface: HistoryDao
Returns one old configuration of node.

Specified by:
getOldRevision in interface HistoryDao
Parameters:
node - node
identifier - timestamp or hash
Returns:
old configuration.

hasOldRevision

public boolean hasOldRevision(hudson.model.Node node,
                              String identifier)
Description copied from interface: HistoryDao
Returns whether the revision exists.

Specified by:
hasOldRevision in interface HistoryDao
Parameters:
node - node
identifier - timestamp or hash
Returns:
old configuration.

getDeletedNodes

public File[] getDeletedNodes(String folderName)
Description copied from interface: OverviewHistoryDao
Returns a list of deleted nodes with a history.

Specified by:
getDeletedNodes in interface OverviewHistoryDao
Parameters:
folderName - name of folder.
Returns:
list of deleted nodes with a history, emtpy when no history exists.

getNodes

public File[] getNodes(String folderName)
Description copied from interface: OverviewHistoryDao
Returns a list of nodes with a history.

Specified by:
getNodes in interface OverviewHistoryDao
Parameters:
folderName - name of folder
Returns:
list of nodes with a history, emtpy when no history exists.

getNodeHistory

public SortedMap<String,HistoryDescr> getNodeHistory(String nodeName)
Description copied from interface: OverviewHistoryDao
Returns a sorted map of all HistoryDescr for a given node.

Specified by:
getNodeHistory in interface OverviewHistoryDao
Parameters:
nodeName - of the node
Returns:
sorted map.


Copyright © 2004–2014. All rights reserved.