hudson.plugins.jobConfigHistory
Class JobConfigHistoryRootAction

java.lang.Object
  extended by hudson.plugins.jobConfigHistory.JobConfigHistoryBaseAction
      extended by hudson.plugins.jobConfigHistory.JobConfigHistoryRootAction
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Action, hudson.model.ModelObject, hudson.model.RootAction

@Extension
public class JobConfigHistoryRootAction
extends JobConfigHistoryBaseAction
implements hudson.model.RootAction

Author:
Stefan Brausch, mfriedenhagen

Nested Class Summary
 
Nested classes/interfaces inherited from class hudson.plugins.jobConfigHistory.JobConfigHistoryBaseAction
JobConfigHistoryBaseAction.SideBySideView
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
JobConfigHistoryRootAction()
          Constructor necessary for testing.
 
Method Summary
protected  void checkConfigurePermission()
          See whether the current user may read configurations in the object returned by JobConfigHistoryBaseAction.getAccessControlledObject().
 String createLinkToJobFiles(ConfigInfo config, String type)
          Creates links to the correct configOutput.jellys for job history vs. system history and for xml vs. plain text.
 void doDiffFiles(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Parses the incoming POST request and redirects as GET showDiffFiles.
protected  hudson.security.AccessControlled getAccessControlledObject()
          Returns the object for which we want to provide access control.
 List<ConfigInfo> getConfigs()
          Returns the configuration history entries for either AbstractItems or system changes or deleted jobs or all of the above.
 String getFile()
          Returns JobConfigHistoryBaseAction#getConfigXml(String) as String.
 String getIconFileName()
           Make method final, as we always want the same icon file.
protected  List<ConfigInfo> getJobConfigs(String type)
          Returns the configuration history entries for all jobs or deleted jobs in this Hudson instance.
 List<JobConfigHistoryBaseAction.SideBySideView.Line> getLines()
          Returns the diff between two config files as a list of single lines.
protected  hudson.XmlFile getOldConfigXml(String name, String timestamp)
          Gets the version of the config.xml that was saved at a certain time.
 List<ConfigInfo> getSingleConfigs(org.kohsuke.stapler.StaplerRequest req)
          Returns the configuration history entries for one group of system files.
protected  List<ConfigInfo> getSystemConfigs()
          Returns the configuration history entries for all system files in this Hudson instance.
 String getUrlName()
           Do not make this method final as JobConfigHistoryRootAction overrides this method.
 boolean hasConfigurePermission()
          Returns whether the current user may read configurations in the object returned by JobConfigHistoryBaseAction.getAccessControlledObject().
 boolean hasJobConfigurePermission()
          Returns whether the current user may configure jobs.
 
Methods inherited from class hudson.plugins.jobConfigHistory.JobConfigHistoryBaseAction
checkTimestamp, getDiffAsString, getDiffLines, getDisplayName, getHudson, getOutputType, getPlugin, getRequestParameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hudson.model.Action
getDisplayName
 

Constructor Detail

JobConfigHistoryRootAction

public JobConfigHistoryRootAction()
Constructor necessary for testing.

Method Detail

getUrlName

public final String getUrlName()
Do not make this method final as JobConfigHistoryRootAction overrides this method. This actions always starts from the context directly, so prefix JobConfigHistoryConsts.URLNAME with a slash.

Specified by:
getUrlName in interface hudson.model.Action
Overrides:
getUrlName in class JobConfigHistoryBaseAction

getIconFileName

public final String getIconFileName()
Make method final, as we always want the same icon file. Returns null to hide the icon if the user is not allowed to configure jobs.

Specified by:
getIconFileName in interface hudson.model.Action

getConfigs

public final List<ConfigInfo> getConfigs()
                                  throws IOException
Returns the configuration history entries for either AbstractItems or system changes or deleted jobs or all of the above.

Returns:
list of configuration histories (as ConfigInfo)
Throws:
IOException - if one of the history entries might not be read.

getSystemConfigs

protected List<ConfigInfo> getSystemConfigs()
                                     throws IOException
Returns the configuration history entries for all system files in this Hudson instance.

Returns:
List of config infos.
Throws:
IOException - if one of the history entries might not be read.

getJobConfigs

protected List<ConfigInfo> getJobConfigs(String type)
                                  throws IOException
Returns the configuration history entries for all jobs or deleted jobs in this Hudson instance.

Parameters:
type - Whether we want to see all jobs or just the deleted jobs.
Returns:
List of config infos.
Throws:
IOException - if one of the history entries might not be read.

getSingleConfigs

public final List<ConfigInfo> getSingleConfigs(org.kohsuke.stapler.StaplerRequest req)
                                        throws IOException
Returns the configuration history entries for one group of system files.

Parameters:
req - The incoming StaplerRequest
Returns:
Configs list for one group of system configuration files.
Throws:
IOException - if one of the history entries might not be read.

getFile

public final String getFile()
                     throws IOException
Returns JobConfigHistoryBaseAction#getConfigXml(String) as String.

Returns:
content of the config.xml found in directory given by the request parameter file.
Throws:
IOException - if the config file could not be read or converted to an xml string.

createLinkToJobFiles

public final String createLinkToJobFiles(ConfigInfo config,
                                         String type)
Creates links to the correct configOutput.jellys for job history vs. system history and for xml vs. plain text.

Parameters:
config - ConfigInfo.
type - Output type ('xml' or 'plain').
Returns:
The link as String.

getAccessControlledObject

protected hudson.security.AccessControlled getAccessControlledObject()
Returns the object for which we want to provide access control. Returns the hudson instance.

Specified by:
getAccessControlledObject in class JobConfigHistoryBaseAction
Returns:
the access controlled object.

checkConfigurePermission

protected void checkConfigurePermission()
Description copied from class: JobConfigHistoryBaseAction
See whether the current user may read configurations in the object returned by JobConfigHistoryBaseAction.getAccessControlledObject().

Specified by:
checkConfigurePermission in class JobConfigHistoryBaseAction

hasConfigurePermission

public boolean hasConfigurePermission()
Description copied from class: JobConfigHistoryBaseAction
Returns whether the current user may read configurations in the object returned by JobConfigHistoryBaseAction.getAccessControlledObject().

Specified by:
hasConfigurePermission in class JobConfigHistoryBaseAction
Returns:
true if the current user may read configurations.

hasJobConfigurePermission

public boolean hasJobConfigurePermission()
Returns whether the current user may configure jobs.

Returns:
true if the current user may configure jobs.

doDiffFiles

public final void doDiffFiles(org.kohsuke.stapler.StaplerRequest req,
                              org.kohsuke.stapler.StaplerResponse rsp)
                       throws javax.servlet.ServletException,
                              IOException
Parses the incoming POST request and redirects as GET showDiffFiles.

Parameters:
req - incoming request
rsp - outgoing response
Throws:
javax.servlet.ServletException - when parsing the request as MultipartFormDataParser does not succeed.
IOException - when the redirection does not succeed.

getLines

public final List<JobConfigHistoryBaseAction.SideBySideView.Line> getLines()
                                                                    throws IOException
Returns the diff between two config files as a list of single lines. Takes the two timestamps and the name of the system property or the deleted job from the url parameters.

Returns:
Differences between two config versions as list of lines.
Throws:
IOException - If diff doesn't work or xml files can't be read.

getOldConfigXml

protected hudson.XmlFile getOldConfigXml(String name,
                                         String timestamp)
Gets the version of the config.xml that was saved at a certain time.

Parameters:
name - The name of the system property or deleted job.
timestamp - The timestamp as String.
Returns:
The config file as XmlFile.


Copyright © 2004-2013. All Rights Reserved.