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

@ExportedBean(defaultVisibility=-1)
@Extension
public class JobConfigHistoryRootAction
extends JobConfigHistoryBaseAction
implements hudson.model.RootAction

Author:
Stefan Brausch, mfriedenhagen

Nested Class Summary
 
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 createLinkToFiles(ConfigInfo config, String type)
          Creates links to the correct configOutput.jellys for job history vs.
 void doDiffFiles(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Parses the incoming POST request and redirects as GET showDiffFiles.
 void doForwardToRestoreQuestion(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Action when 'restore' button in history.jelly is pressed.
 void doRestore(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Action when 'restore' button is pressed: Restore deleted project.
protected  hudson.security.AccessControlled getAccessControlledObject()
          Returns the object for which we want to provide access control.
 hudson.model.Api getApi()
           
 List<ConfigInfo> getConfigs()
          Returns the configuration history entries for either AbstractItem s 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.
 hudson.XmlFile getLastAvailableConfigXml(String name)
          Retrieves the last or second to last config.xml.
 List<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(String name)
          Returns the configuration history entries for one group of system files or deleted jobs.
 String getUrlName()
           This actions always starts from the context directly, so prefix JobConfigHistoryConsts.URLNAME with a slash.
 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, doDiffFilesPrevNext, getDiffAsString, getDiffLines, getDisplayName, getHudson, getOutputType, 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()
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

@Exported(visibility=1)
public final List<ConfigInfo> getConfigs()
                                  throws IOException
Returns the configuration history entries for either AbstractItem s 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.

getSingleConfigs

public final List<ConfigInfo> getSingleConfigs(String name)
                                        throws IOException
Returns the configuration history entries for one group of system files or deleted jobs.

Parameters:
name - of the item.
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.

createLinkToFiles

public final String createLinkToFiles(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()
Description copied from class: JobConfigHistoryBaseAction
Returns the object for which we want to provide access control.

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.

Overrides:
doDiffFiles in class JobConfigHistoryBaseAction
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<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.

doRestore

public final void doRestore(org.kohsuke.stapler.StaplerRequest req,
                            org.kohsuke.stapler.StaplerResponse rsp)
                     throws IOException
Action when 'restore' button is pressed: Restore deleted project.

Parameters:
req - Incoming StaplerRequest
rsp - Outgoing StaplerResponse
Throws:
IOException - If something goes wrong

getLastAvailableConfigXml

public hudson.XmlFile getLastAvailableConfigXml(String name)
Retrieves the last or second to last config.xml. The latter is necessary when the last config.xml is missing although the history entry exists, which happens when a project is deleted while being disabled.

Parameters:
name - The name of the deleted project.
Returns:
The last or second to last config as XmlFile or null.

doForwardToRestoreQuestion

public final void doForwardToRestoreQuestion(org.kohsuke.stapler.StaplerRequest req,
                                             org.kohsuke.stapler.StaplerResponse rsp)
                                      throws IOException
Action when 'restore' button in history.jelly is pressed. Gets required parameter and forwards to restoreQuestion.jelly.

Parameters:
req - StaplerRequest created by pressing the button
rsp - Outgoing StaplerResponse
Throws:
IOException - If redirect goes wrong

getApi

public hudson.model.Api getApi()


Copyright © 2004–2014. All rights reserved.