hudson.plugins.jobConfigHistory
Class JobConfigHistoryProjectAction

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

public class JobConfigHistoryProjectAction
extends JobConfigHistoryBaseAction

Author:
Stefan Brausch

Nested Class Summary
 
Nested classes/interfaces inherited from class hudson.plugins.jobConfigHistory.JobConfigHistoryBaseAction
JobConfigHistoryBaseAction.SideBySideView
 
Constructor Summary
JobConfigHistoryProjectAction(hudson.model.AbstractItem project)
           
 
Method Summary
protected  void checkConfigurePermission()
          See whether the current user may read configurations in the object returned by JobConfigHistoryBaseAction.getAccessControlledObject().
 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 showDiffFiles.jelly is pressed.
 void doRestore(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Action when 'restore' button is pressed: Replace current config file by older version.
protected  hudson.security.AccessControlled getAccessControlledObject()
          Returns the object for which we want to provide access control.
 String getFile()
          Returns JobConfigHistoryBaseAction#getConfigXml(String) as String.
 String getIconFileName()
           Make method final, as we always want the same icon file.
 List<ConfigInfo> getJobConfigs()
          Returns the configuration history entries for one AbstractItem.
 List<JobConfigHistoryBaseAction.SideBySideView.Line> getLines()
          Takes the two timestamp request parameters and returns the diff between the corresponding config files of this project as a list of single lines.
 hudson.model.AbstractItem getProject()
          Returns the project for which we want to see the config history, the config files or the diff.
 boolean hasConfigurePermission()
          Returns whether the current user may read configurations in the object returned by JobConfigHistoryBaseAction.getAccessControlledObject().
 
Methods inherited from class hudson.plugins.jobConfigHistory.JobConfigHistoryBaseAction
checkTimestamp, getDiffAsString, getDiffLines, getDisplayName, getHudson, getOutputType, getPlugin, getRequestParameter, getUrlName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobConfigHistoryProjectAction

public JobConfigHistoryProjectAction(hudson.model.AbstractItem project)
Parameters:
project - for which configurations should be returned.
Method Detail

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.


getJobConfigs

public final List<ConfigInfo> getJobConfigs()
                                     throws IOException
Returns the configuration history entries for one AbstractItem.

Returns:
history list for one AbstractItem.
Throws:
IOException - if JobConfigHistoryConsts.HISTORY_FILE might not be read or the path might not be urlencoded.

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.

getProject

public final hudson.model.AbstractItem getProject()
Returns the project for which we want to see the config history, the config files or the diff.

Returns:
project

getAccessControlledObject

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

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.

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
Takes the two timestamp request parameters and returns the diff between the corresponding config files of this project as a list of single lines.

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

doRestore

public final void doRestore(org.kohsuke.stapler.StaplerRequest req,
                            org.kohsuke.stapler.StaplerResponse rsp)
                     throws IOException
Action when 'restore' button is pressed: Replace current config file by older version.

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

doForwardToRestoreQuestion

public final void doForwardToRestoreQuestion(org.kohsuke.stapler.StaplerRequest req,
                                             org.kohsuke.stapler.StaplerResponse rsp)
                                      throws IOException
Action when 'restore' button in showDiffFiles.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 XML file can't be read


Copyright © 2004-2013. All Rights Reserved.