com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.actions.manual
Class ManualTriggerAction

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.actions.manual.ManualTriggerAction
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Action, hudson.model.ModelObject, hudson.model.RootAction

@Extension
public class ManualTriggerAction
extends Object
implements hudson.model.RootAction

RootAction for manually triggering a "Gerrit-build".

Author:
Robert Sandell <robert.sandell@sonyericsson.com>

Nested Class Summary
static class ManualTriggerAction.Approval
          Represents a "vote"-type or Approval of a change in the JSON structure.
static class ManualTriggerAction.HighLow
          A tuple of a high and a low number.
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
static int EXPECTED_NR_OF_PARTS_IN_A_GENERATED_ID
          The expected number of parts separated by _ in a generated id.
static String ID_SEPARATOR
          The char that separates the different id components in a search-result-row.
 
Constructor Summary
ManualTriggerAction()
           
 
Method Summary
 void doBuild(String selectedIds, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Builds the selected patch-set(s).
 void doGerritSearch(String queryString, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Does a search.
 String generateTheId(net.sf.json.JSONObject change, net.sf.json.JSONObject patch)
          Generates a "unique" id for the change and/or patch.
 ManualTriggerAction.HighLow getCodeReview(net.sf.json.JSONObject res)
          Finds the highest and lowest code review vote for the provided patch set.
 String getDisplayName()
           
 String getGerritUrl(net.sf.json.JSONObject change)
          Generates the URL to the provided change in Gerrit.
 String getGerritUrl(PatchsetCreated event)
          Generates the URL to the provided change in Gerrit.
 String getIconFileName()
           
 String getJsUrl(String jsName)
          Gets the full path to the provided javascript file.
 List<hudson.model.ParameterValue> getParametersForPatchSet(net.sf.json.JSONObject jsonChange, net.sf.json.JSONObject jsonPatchSet)
          Creates a list of the parameters as they would be in a scheduled build.
 hudson.security.Permission getRequiredPermission()
          Serves the permission required to perform this action.
 String getUrlName()
           
 ManualTriggerAction.HighLow getVerified(net.sf.json.JSONObject res)
          Finds the lowest and highest verified vote for the provided patch set.
 boolean hasUrl(hudson.model.ParameterValue parameterValue)
          Tells if the given parameter should have a URL or not.
 boolean isEnabled()
          If this page/link is enabled or not.
 String toReadableHtml(String subject)
          Cuts the string to a max length of MAX_SUBJECT_STR_LENGTH and escapes unsafe HTML characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPECTED_NR_OF_PARTS_IN_A_GENERATED_ID

public static final int EXPECTED_NR_OF_PARTS_IN_A_GENERATED_ID
The expected number of parts separated by _ in a generated id. Each part is actually another id.

See Also:
generateTheId(net.sf.json.JSONObject, net.sf.json.JSONObject), Constant Field Values

ID_SEPARATOR

public static final String ID_SEPARATOR
The char that separates the different id components in a search-result-row.

See Also:
Constant Field Values
Constructor Detail

ManualTriggerAction

public ManualTriggerAction()
Method Detail

getIconFileName

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

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

isEnabled

public boolean isEnabled()
If this page/link is enabled or not.

Returns:
true if so.
See Also:
IGerritHudsonTriggerConfig.isEnableManualTrigger()

getRequiredPermission

public hudson.security.Permission getRequiredPermission()
Serves the permission required to perform this action. Used by index.jelly

Returns:
the permission.

getJsUrl

public String getJsUrl(String jsName)
Gets the full path to the provided javascript file. For use by jelly files to give to the client browser.

Parameters:
jsName - the javascript filename.
Returns:
the full path from the web-context root.

getCodeReview

public ManualTriggerAction.HighLow getCodeReview(net.sf.json.JSONObject res)
Finds the highest and lowest code review vote for the provided patch set.

Parameters:
res - the patch set.
Returns:
the highest and lowest code review vote for the patch set.

getVerified

public ManualTriggerAction.HighLow getVerified(net.sf.json.JSONObject res)
Finds the lowest and highest verified vote for the provided patch set.

Parameters:
res - the patch-set.
Returns:
the highest and lowest verified vote.

toReadableHtml

public String toReadableHtml(String subject)
Cuts the string to a max length of MAX_SUBJECT_STR_LENGTH and escapes unsafe HTML characters.

Parameters:
subject - the string to fix if needed.
Returns:
the fixed string.
See Also:
Util.escape(String)

doGerritSearch

public void doGerritSearch(@QueryParameter(value="queryString")
                           String queryString,
                           org.kohsuke.stapler.StaplerRequest request,
                           org.kohsuke.stapler.StaplerResponse response)
                    throws IOException
Does a search.

Parameters:
queryString - the query to send to Gerrit.
request - the request.
response - the response.
Throws:
IOException - if the unfortunate happens.

doBuild

public void doBuild(@QueryParameter(value="selectedIds")
                    String selectedIds,
                    org.kohsuke.stapler.StaplerRequest request,
                    org.kohsuke.stapler.StaplerResponse response)
             throws IOException
Builds the selected patch-set(s).

Parameters:
selectedIds - the selected rows in the form's search-result separated by "[]".
request - the request.
response - the response.
Throws:
IOException - if the unfortunate happens.

generateTheId

public String generateTheId(net.sf.json.JSONObject change,
                            net.sf.json.JSONObject patch)
Generates a "unique" id for the change and/or patch. So it can be identified as a single row in the search result.

Parameters:
change - the change.
patch - the patch-set in the change.
Returns:
the generated id.

getGerritUrl

public String getGerritUrl(PatchsetCreated event)
Generates the URL to the provided change in Gerrit. If the change already has a URL provided, that URL will be used.

Parameters:
event - the event who's change to link to.
Returns:
the URL to the event's change.

getParametersForPatchSet

public List<hudson.model.ParameterValue> getParametersForPatchSet(net.sf.json.JSONObject jsonChange,
                                                                  net.sf.json.JSONObject jsonPatchSet)
Creates a list of the parameters as they would be in a scheduled build. Without escaped quotes.

Parameters:
jsonChange - the JSON data for the change.
jsonPatchSet - the JSON data for the patch-set.
Returns:
a list of the parameters.

hasUrl

public boolean hasUrl(hudson.model.ParameterValue parameterValue)
Tells if the given parameter should have a URL or not. i.e. if the parameter represents GerritTriggerParameters.GERRIT_CHANGE_URL.

Parameters:
parameterValue - the parameter.
Returns:
true if so.

getGerritUrl

public String getGerritUrl(net.sf.json.JSONObject change)
Generates the URL to the provided change in Gerrit. If the change already has a URL provided, that URL will be used.

Parameters:
change - the change to link to.
Returns:
the URL to the change.


Copyright © 2004-2011. All Rights Reserved.