Package hudson.plugins.jobConfigHistory
Class FileHistoryDao
java.lang.Object
hudson.plugins.jobConfigHistory.JobConfigHistoryStrategy
hudson.plugins.jobConfigHistory.FileHistoryDao
- All Implemented Interfaces:
ExtensionPoint,Describable<JobConfigHistoryStrategy>,HistoryDao,ItemListenerHistoryDao,NodeListenerHistoryDao,OverviewHistoryDao,Purgeable
Defines some helper functions needed by
JobConfigHistoryJobListener
and JobConfigHistorySaveableListener.- Author:
- Mirko Friedenhagen
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
ConstructorsConstructorDescriptionFileHistoryDao(File historyRootDir, File jenkinsHome, MimickedUser currentUser, int maxHistoryEntries, boolean saveDuplicates) -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeItemLocation(Item item, String oldFullName, String newFullName) Changes the item's history's location.voidcopyHistoryAndDelete(String oldName, String newName) Deprecated.voidcreateNewItem(Item item) Adds and saves the initial configuration of an item.voidcreateNewNode(Node node) Adds and saves the initial configuration of a node.voiddeleteItem(Item item) Deletes the history of an item.voiddeleteNode(Node node) Deletes the history of a node.voiddeleteRevision(AbstractItem abstractItem, String identifier) Permanently delete the given revision.voiddeleteRevision(Node node, String identifier) voiddeleteRevision(File historyDir, String identifier) static FilegetConfigFile(File historyDir) Returns the configuration data file stored in the specified history directory.intFile[]Returns a list of deleted jobs with a history, including all those contained in folders.File[]getDeletedJobs(String folderName) Returns a list of deleted jobs with a history.getHistoryDir(File configFile) Returns the configuration history directory for the given configuration file.getJobHistory(String jobName) Returns a sorted map of all HistoryDescr for a given job.intintgetJobRevisionAmount(String jobName) File[]getJobs()Returns a list of jobs with a history, including all those contained in folders.File[]Returns a list of jobs with a history.getOldRevision(AbstractItem item, String identifier) Returns one old configuration of item.getOldRevision(Node node, String identifier) Returns one old configuration of node.getOldRevision(XmlFile xmlFile, String identifier) Returns one old configuration of xmlFile.getOldRevision(String configFileName, String identifier) Returns one old configuration of file.intgetRevisionAmount(Node node) intgetRevisionAmount(XmlFile xmlFile) getRevisions(Node node) Returns a sorted map of all revisions for this node.getRevisions(XmlFile xmlFile) Returns a sorted map of all revisions for this xmlFile.File[]Returns a list of all system configuration files with a history.getSystemHistory(String name) Returns a sorted map of all HistoryDescr for a given system configuration.intintgetSystemRevisionAmount(String sysConfigName) intbooleanhasDuplicateHistory(Node node) Determines whether the given node has already been recorded in the history.booleanhasOldRevision(Node node, String identifier) Returns whether the revision exists.booleanhasOldRevision(XmlFile xmlFile, String identifier) Returns whether the revision exists.booleanisCreatedEntry(File historyDir) Determines whether the specified directory should be dropped or not.voidpurgeOldEntries(File itemHistoryRoot, int maxEntries) Purges entries when there are more entries than specified by max entries.voidrenameItem(Item item, String oldName, String newName) Save and renames the item.voidrenameNode(Node node, String oldName, String newName) Save and renames the node.booleanrevisionEqualsCurrent(AbstractItem project, String identifier1) booleanrevisionEqualsCurrent(Node node, String identifier1) voidSaves a copy of a xml file.voidSaves the current configuration of a node.Methods inherited from class hudson.plugins.jobConfigHistory.JobConfigHistoryStrategy
all, getDescriptor
-
Constructor Details
-
FileHistoryDao
public FileHistoryDao() -
FileHistoryDao
public FileHistoryDao(File historyRootDir, File jenkinsHome, MimickedUser currentUser, int maxHistoryEntries, boolean saveDuplicates) - Parameters:
historyRootDir- where to store historyjenkinsHome- JENKINS_HOMEcurrentUser- of operationmaxHistoryEntries- max number of history entriessaveDuplicates- should we save duplicate entries?
-
-
Method Details
-
getConfigFile
Returns the configuration data file stored in the specified history directory. It looks for a file with an 'xml' extension that is not namedJobConfigHistoryConsts.HISTORY_FILE.Relies on the assumption that random '.xml' files will not appear in the history directories.
Checks that we are in an actual 'history directory' to prevent use for getting random xml files.
- Parameters:
historyDir- The history directory to look under.- Returns:
- The configuration file or null if no file is found.
-
createNewItem
Description copied from interface:ItemListenerHistoryDaoAdds and saves the initial configuration of an item.- Specified by:
createNewItemin interfaceItemListenerHistoryDao- Parameters:
item- project
-
saveItem
Description copied from interface:HistoryDaoSaves a copy of a xml file.- Specified by:
saveItemin interfaceHistoryDao- Parameters:
file- xmlFile
-
deleteItem
Description copied from interface:ItemListenerHistoryDaoDeletes the history of an item.- Specified by:
deleteItemin interfaceItemListenerHistoryDao- Parameters:
item- project
-
changeItemLocation
Description copied from interface:ItemListenerHistoryDaoChanges the item's history's location.- Specified by:
changeItemLocationin interfaceItemListenerHistoryDao- Parameters:
item- projectoldFullName- old full namenewFullName- new full name
-
renameItem
Description copied from interface:ItemListenerHistoryDaoSave and renames the item.- Specified by:
renameItemin interfaceItemListenerHistoryDao- Parameters:
item- projectoldName- old project namenewName- new name
-
getRevisions
Description copied from interface:HistoryDaoReturns 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:
getRevisionsin interfaceHistoryDao- Parameters:
xmlFile- file- Returns:
- old revisions mapped to the identifier.
-
getRevisionAmount
- Specified by:
getRevisionAmountin interfaceHistoryDao- Parameters:
xmlFile- the config's history xml file- Returns:
- the amount of revision entries of a certain config.
-
getRevisionAmount
- Specified by:
getRevisionAmountin interfaceHistoryDao- Parameters:
node- node- Returns:
- the amount of revision entries of a certain config.
-
getSystemRevisionAmount
- Specified by:
getSystemRevisionAmountin interfaceOverviewHistoryDao- Returns:
- the number of configuration revision entries for a certain system config.
-
getSystemRevisionAmount
public int getSystemRevisionAmount()- Specified by:
getSystemRevisionAmountin interfaceOverviewHistoryDao- Returns:
- the total number of system configuration revision entries.
-
getJobRevisionAmount
public int getJobRevisionAmount()- Specified by:
getJobRevisionAmountin interfaceOverviewHistoryDao- Returns:
- the total number of job configuration revision entries.
-
getDeletedJobAmount
public int getDeletedJobAmount()- Specified by:
getDeletedJobAmountin interfaceOverviewHistoryDao- Returns:
- the total number of deleted Jobs.
-
getJobRevisionAmount
- Specified by:
getJobRevisionAmountin interfaceOverviewHistoryDao- Returns:
- the number of configuration revision entries for a certain system config.
-
getTotalRevisionAmount
public int getTotalRevisionAmount()- Specified by:
getTotalRevisionAmountin interfaceOverviewHistoryDao- Returns:
- the total number of configuration revision entries, excluding agent config entries - TODO future work.
-
getOldRevision
Description copied from interface:HistoryDaoReturns one old configuration of item.- Specified by:
getOldRevisionin interfaceHistoryDao- Parameters:
item- projectidentifier- timestamp or hash- Returns:
- old configuration.
-
getOldRevision
Description copied from interface:HistoryDaoReturns one old configuration of xmlFile.- Specified by:
getOldRevisionin interfaceHistoryDao- Parameters:
xmlFile- fileidentifier- timestamp or hash- Returns:
- old configuration.
-
getOldRevision
Description copied from interface:HistoryDaoReturns one old configuration of file.- Specified by:
getOldRevisionin interfaceHistoryDao- Parameters:
configFileName- fileidentifier- timestamp or hash- Returns:
- old configuration.
-
deleteRevision
Description copied from interface:HistoryDaoPermanently delete the given revision.- Specified by:
deleteRevisionin interfaceHistoryDao- Parameters:
abstractItem- itemidentifier- timestamp or hash
-
deleteRevision
- Specified by:
deleteRevisionin interfaceHistoryDao
-
deleteRevision
- Specified by:
deleteRevisionin interfaceHistoryDao
-
revisionEqualsCurrent
- Specified by:
revisionEqualsCurrentin interfaceHistoryDao
-
revisionEqualsCurrent
- Specified by:
revisionEqualsCurrentin interfaceHistoryDao
-
hasOldRevision
Description copied from interface:HistoryDaoReturns whether the revision exists.- Specified by:
hasOldRevisionin interfaceHistoryDao- Parameters:
xmlFile- fileidentifier- timestamp or hash- Returns:
- old configuration.
-
getHistoryDir
Returns the configuration history directory for the given configuration file.- Parameters:
configFile- The configuration file whose content we are saving.- Returns:
- The base directory where to store the history, or null if the file is not a valid Jenkins configuration file.
-
purgeOldEntries
Description copied from interface:PurgeablePurges entries when there are more entries than specified by max entries.The purge will drop old entries according to:
sort(entries, e.timestamp()); for (int i = maxEntries; i < entries.length(); i++) drop(entries[i]);
- Specified by:
purgeOldEntriesin interfacePurgeable- Parameters:
itemHistoryRoot- the history root to drop entries from.maxEntries- the maximum number of entries to retain.
-
isCreatedEntry
Description copied from interface:PurgeableDetermines whether the specified directory should be dropped or not.- Specified by:
isCreatedEntryin interfacePurgeable- Parameters:
historyDir- the directory to check against.- Returns:
- true if it can be deleted, false otherwise.
-
getDeletedJobs
Description copied from interface:OverviewHistoryDaoReturns a list of deleted jobs with a history, including all those contained in folders.- Specified by:
getDeletedJobsin interfaceOverviewHistoryDao- Returns:
- array of deleted jobs with a history, empty when no history exists.
-
getDeletedJobs
Description copied from interface:OverviewHistoryDaoReturns a list of deleted jobs with a history.- Specified by:
getDeletedJobsin interfaceOverviewHistoryDao- Parameters:
folderName- name of folder.- Returns:
- array of deleted jobs with a history, empty when no history exists.
-
getJobs
Description copied from interface:OverviewHistoryDaoReturns a list of jobs with a history, including all those contained in folders.- Specified by:
getJobsin interfaceOverviewHistoryDao- Returns:
- array of all jobs with a history, empty when no history exists.
-
getJobs
Description copied from interface:OverviewHistoryDaoReturns a list of jobs with a history.- Specified by:
getJobsin interfaceOverviewHistoryDao- Parameters:
folderName- name of folder- Returns:
- array of jobs with a history, empty when no history exists.
-
getSystemConfigs
Description copied from interface:OverviewHistoryDaoReturns a list of all system configuration files with a history.- Specified by:
getSystemConfigsin interfaceOverviewHistoryDao- Returns:
- array of all system configuration files with a history, empty when no history exists.
-
getSystemConfigsMap
- Specified by:
getSystemConfigsMapin interfaceOverviewHistoryDao- Returns:
- a map mapping timestamps to historydescrs. Contains all system config revision entries.
-
getJobHistory
Description copied from interface:OverviewHistoryDaoReturns a sorted map of all HistoryDescr for a given job.- Specified by:
getJobHistoryin interfaceOverviewHistoryDao- Parameters:
jobName- of the job- Returns:
- sorted map.
-
getSystemHistory
Description copied from interface:OverviewHistoryDaoReturns a sorted map of all HistoryDescr for a given system configuration.- Specified by:
getSystemHistoryin interfaceOverviewHistoryDao- Parameters:
name- of the configuration- Returns:
- sorted map.
-
copyHistoryAndDelete
Deprecated. -
createNewNode
Description copied from interface:NodeListenerHistoryDaoAdds and saves the initial configuration of a node.- Specified by:
createNewNodein interfaceNodeListenerHistoryDao- Parameters:
node- node
-
deleteNode
Description copied from interface:NodeListenerHistoryDaoDeletes the history of a node.- Specified by:
deleteNodein interfaceNodeListenerHistoryDao- Parameters:
node- node
-
renameNode
Description copied from interface:NodeListenerHistoryDaoSave and renames the node.- Specified by:
renameNodein interfaceNodeListenerHistoryDao- Parameters:
node- nodeoldName- old node namenewName- new name
-
getRevisions
Description copied from interface:HistoryDaoReturns 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:
getRevisionsin interfaceHistoryDao- Parameters:
node- node- Returns:
- old revisions mapped to the identifier.
-
hasDuplicateHistory
Determines whether the given node has already been recorded in the history.- Specified by:
hasDuplicateHistoryin interfaceHistoryDao- Parameters:
node- the node to check for duplicate history.- Returns:
- true if the node is a duplicate, false otherwise.
-
saveNode
Description copied from interface:HistoryDaoSaves the current configuration of a node.- Specified by:
saveNodein interfaceHistoryDao- Parameters:
node- node
-
getOldRevision
Description copied from interface:HistoryDaoReturns one old configuration of node.- Specified by:
getOldRevisionin interfaceHistoryDao- Parameters:
node- nodeidentifier- timestamp or hash- Returns:
- old configuration.
-
hasOldRevision
Description copied from interface:HistoryDaoReturns whether the revision exists.- Specified by:
hasOldRevisionin interfaceHistoryDao- Parameters:
node- nodeidentifier- timestamp or hash- Returns:
- old configuration.
-