hudson.plugins.jobConfigHistory
Class ComputerConfigHistoryAction

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

@ExportedBean(defaultVisibility=-1)
public class ComputerConfigHistoryAction
extends JobConfigHistoryBaseAction

Author:
Lucie Votypkova

Constructor Summary
ComputerConfigHistoryAction(hudson.model.Slave slave)
          Standard constructor using instance
 
Method Summary
protected  void checkConfigurePermission()
          See whether the current user may read configurations in the object returned by JobConfigHistoryBaseAction.getAccessControlledObject().
 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.
 hudson.model.Api getApi()
           
 String getDisplayName()
           
 String getFile()
          Returns JobConfigHistoryBaseAction#getConfigXml(String) as String.
 String getIconFileName()
           
 List<SideBySideView.Line> getLines()
          Takes the two timestamp request parameters and returns the diff between the corresponding config files of this slave as a list of single lines.
 String getNextTimestamp(int timestampNumber)
          Used in the Difference jelly only.
 String getOperation(int timestampNumber)
          Used in the Difference jelly only.
 String getPrevTimestamp(int timestampNumber)
          Used in the Difference jelly only.
 hudson.model.Slave getSlave()
          Returns the slave.
 List<ConfigInfo> getSlaveConfigs()
          Returns the configuration history entries for one Slave.
 List<ConfigInfo> getSlaveConfigsREST()
          Returns the configuration history entries for one Slave for the REST API.
 String getTimestamp(int timestampNumber)
          Used in the Difference jelly only.
 String getUrlName()
           
 String getUser(int timestampNumber)
          Used in the Difference jelly only.
 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, doDiffFiles, doDiffFilesPrevNext, getDiffAsString, getDiffLines, getHudson, getOutputType, getRequestParameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComputerConfigHistoryAction

public ComputerConfigHistoryAction(hudson.model.Slave slave)
Standard constructor using instance. * @param slave Slave.

Method Detail

getDisplayName

public final String getDisplayName()
Specified by:
getDisplayName in interface hudson.model.Action
Specified by:
getDisplayName in interface hudson.model.ModelObject
Overrides:
getDisplayName in class JobConfigHistoryBaseAction

getUrlName

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

getSlave

public hudson.model.Slave getSlave()
Returns the slave.

Returns:
the slave.

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.

getIconFileName

public final String getIconFileName()

getSlaveConfigs

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

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

getSlaveConfigsREST

@Exported(name="jobConfigHistory",
          visibility=1)
public final List<ConfigInfo> getSlaveConfigsREST()
                                           throws IOException
Returns the configuration history entries for one Slave for the REST API.

Returns:
history list for one Slave, or an empty list if not authorized.
Throws:
IOException - if JobConfigHistoryConsts.HISTORY_FILE might not be read or the path might not be urlencoded.

getTimestamp

public final String getTimestamp(int timestampNumber)
Used in the Difference jelly only. Returns one of the two timestamps that have been passed to the Difference page as parameter. timestampNumber must be 1 or 2.

Parameters:
timestampNumber - 1 for timestamp1 and 2 for timestamp2
Returns:
the timestamp as String.

getUser

public final String getUser(int timestampNumber)
Used in the Difference jelly only. Returns the user that made the change in one of the Files shown in the Difference view(A or B). timestampNumber decides between File A and File B.

Parameters:
timestampNumber - 1 for File A and 2 for File B
Returns:
the user as String.

getOperation

public final String getOperation(int timestampNumber)
Used in the Difference jelly only. Returns the operation made on one of the two Files A and B. timestampNumber decides which file exactly.

Parameters:
timestampNumber - 1 for File A, 2 for File B
Returns:
the operation as String.

getNextTimestamp

public final String getNextTimestamp(int timestampNumber)
Used in the Difference jelly only. Returns the next timestamp of the next entry of the two Files A and B. timestampNumber decides which file exactly.

Parameters:
timestampNumber - 1 for File A, 2 for File B
Returns:
the timestamp of the next entry as String.

getPrevTimestamp

public final String getPrevTimestamp(int timestampNumber)
Used in the Difference jelly only. Returns the previous timestamp of the next entry of the two Files A and B. timestampNumber decides which file exactly.

Parameters:
timestampNumber - 1 for File A, 2 for File B
Returns:
the timestamp of the preious entry as String.

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.

getLines

public final List<SideBySideView.Line> getLines()
                                         throws IOException
Takes the two timestamp request parameters and returns the diff between the corresponding config files of this slave 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

getApi

public hudson.model.Api getApi()


Copyright © 2004–2014. All rights reserved.