hudson.plugins.jobConfigHistory
Class JobConfigHistoryBaseAction

java.lang.Object
  extended by hudson.plugins.jobConfigHistory.JobConfigHistoryBaseAction
All Implemented Interfaces:
hudson.model.Action, hudson.model.ModelObject
Direct Known Subclasses:
ComputerConfigHistoryAction, JobConfigHistoryProjectAction, JobConfigHistoryRootAction

public abstract class JobConfigHistoryBaseAction
extends Object
implements hudson.model.Action

Implements some basic methods needed by the JobConfigHistoryRootAction and JobConfigHistoryProjectAction.

Author:
mfriedenhagen

Constructor Summary
JobConfigHistoryBaseAction()
          Set the Hudson instance.
 
Method Summary
protected abstract  void checkConfigurePermission()
          See whether the current user may read configurations in the object returned by getAccessControlledObject().
protected  boolean checkTimestamp(String timestamp)
          Checks the url parameter 'timestamp' and returns true if it is parseable as a date.
 void doDiffFiles(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Parses the incoming POST request and redirects as GET showDiffFiles.
 void doDiffFilesPrevNext(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Action when 'Prev' or 'Next' button in showDiffFiles.jelly is pressed.
protected abstract  hudson.security.AccessControlled getAccessControlledObject()
          Returns the object for which we want to provide access control.
protected  String getDiffAsString(File file1, File file2, String[] file1Lines, String[] file2Lines)
          Returns a unified diff between two string arrays.
 List<SideBySideView.Line> getDiffLines(List<String> diffLines)
          Returns side-by-side (i.e. human-readable) diff view lines.
 String getDisplayName()
           
protected  hudson.model.Hudson getHudson()
          Returns the hudson instance.
 String getOutputType()
          Returns how the config file should be formatted in configOutput.jelly: as plain text or xml.
protected  String getRequestParameter(String parameterName)
          Returns the parameter named parameterName from current request.
 String getUrlName()
           
protected abstract  boolean hasConfigurePermission()
          Returns whether the current user may read configurations in the object returned by getAccessControlledObject().
 
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
getIconFileName
 

Constructor Detail

JobConfigHistoryBaseAction

public JobConfigHistoryBaseAction()
Set the Hudson instance.

Method Detail

getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface hudson.model.Action
Specified by:
getDisplayName in interface hudson.model.ModelObject

getUrlName

public String getUrlName()
Specified by:
getUrlName in interface hudson.model.Action

getOutputType

public final String getOutputType()
Returns how the config file should be formatted in configOutput.jelly: as plain text or xml.

Returns:
"plain" or "xml"

checkTimestamp

protected boolean checkTimestamp(String timestamp)
Checks the url parameter 'timestamp' and returns true if it is parseable as a date.

Parameters:
timestamp - Timestamp of config change.
Returns:
True if timestamp is okay.

getRequestParameter

protected String getRequestParameter(String parameterName)
Returns the parameter named parameterName from current request.

Parameters:
parameterName - name of the parameter.
Returns:
value of the request parameter or null if it does not exist.

checkConfigurePermission

protected abstract void checkConfigurePermission()
See whether the current user may read configurations in the object returned by getAccessControlledObject().


hasConfigurePermission

protected abstract boolean hasConfigurePermission()
Returns whether the current user may read configurations in the object returned by getAccessControlledObject().

Returns:
true if the current user may read configurations.

getHudson

protected hudson.model.Hudson getHudson()
Returns the hudson instance.

Returns:
the hudson

getAccessControlledObject

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

Returns:
the access controlled object.

getDiffLines

public final List<SideBySideView.Line> getDiffLines(List<String> diffLines)
                                             throws IOException
Returns side-by-side (i.e. human-readable) diff view lines.

Parameters:
diffLines - Unified diff as list of Strings.
Returns:
Nice and clean diff as list of single Lines.
Throws:
IOException - if reading one of the config files does not succeed.

getDiffAsString

protected final String getDiffAsString(File file1,
                                       File file2,
                                       String[] file1Lines,
                                       String[] file2Lines)
Returns a unified diff between two string arrays.

Parameters:
file1 - first config file.
file2 - second config file.
file1Lines - the lines of the first file.
file2Lines - the lines of the second file.
Returns:
unified diff

doDiffFiles

public 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.

doDiffFilesPrevNext

public final void doDiffFilesPrevNext(org.kohsuke.stapler.StaplerRequest req,
                                      org.kohsuke.stapler.StaplerResponse rsp)
                               throws IOException
Action when 'Prev' or 'Next' button in showDiffFiles.jelly is pressed. Forwards to the previous or next diff.

Parameters:
req - StaplerRequest created by pressing the button
rsp - Outgoing StaplerResponse
Throws:
IOException - If XML file can't be read


Copyright © 2004–2014. All rights reserved.