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

@Extension public class ManualTriggerAction extends Object implements RootAction
RootAction for manually triggering a "Gerrit-build".
Author:
Robert Sandell <robert.sandell@sonyericsson.com>
  • Field Details

  • Constructor Details

    • ManualTriggerAction

      public ManualTriggerAction()
  • Method Details

    • getIconFileName

      public String getIconFileName()
      Specified by:
      getIconFileName in interface Action
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Action
      Specified by:
      getDisplayName in interface ModelObject
    • getUrlName

      public String getUrlName()
      Specified by:
      getUrlName in interface Action
    • hasEnabledServers

      public boolean hasEnabledServers()
      If this page/link is enabled or not, depending on whether at least one server is enabled.
      Returns:
      true if at least one server is enabled, false otherwise.
      See Also:
    • getFrontEndUrl

      public String getFrontEndUrl(String serverName)
      Return the front end url of selected server, or first enabled server if selected doesn't exists (happens when serverName is null also). First
      Parameters:
      serverName - the name of the GerritServer or null.
      Returns:
      url to the frontend
    • getEnabledServers

      public ArrayList<String> getEnabledServers()
      Returns the list of servers allowed to be queried and manually triggered.
      Returns:
      the enabled server names
    • getRequiredPermission

      public 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

      @Deprecated public ManualTriggerAction.HighLow getCodeReview(net.sf.json.JSONObject res)
      Deprecated.
      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.
    • getCodeReview

      public ManualTriggerAction.HighLow getCodeReview(net.sf.json.JSONObject res, int patchSetNumber)
      Finds the highest and lowest code review vote for the provided patch set.
      Parameters:
      res - the patch set.
      patchSetNumber - the patch set number.
      Returns:
      the highest and lowest code review vote for the patch set.
    • getVerified

      @Deprecated public ManualTriggerAction.HighLow getVerified(net.sf.json.JSONObject res)
      Deprecated.
      Finds the lowest and highest verified vote for the provided patch set.
      Parameters:
      res - the patch-set.
      Returns:
      the highest and lowest verified vote.
    • getVerified

      public ManualTriggerAction.HighLow getVerified(net.sf.json.JSONObject res, int patchSetNumber)
      Finds the lowest and highest verified vote for the provided patch set.
      Parameters:
      res - the patch-set.
      patchSetNumber - the patch set number.
      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.
      Parameters:
      subject - the string to fix if needed.
      Returns:
      the fixed string.
    • doGerritSearch

      @POST public void doGerritSearch(@QueryParameter("queryString") String queryString, @QueryParameter("selectedServer") String selectedServer, @QueryParameter("allPatchSets") boolean allPatchSets, 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.
      selectedServer - the selected Gerrit server.
      allPatchSets - if the result includes all patchsets in a change.
      response - the response.
      Throws:
      IOException - if the query fails.
    • doBuild

      @POST public void doBuild(@QueryParameter("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 query fails.
    • 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.
    • createProviderFromGerritServer

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static com.sonymobile.tools.gerrit.gerritevents.dto.attr.Provider createProviderFromGerritServer(String serverName)
      Create event Provider from GerritServer.
      Parameters:
      serverName - the name of the GerritServer
      Returns:
      the Provider with info from the GerritServer, or an empty provider if server not found
    • createProvider

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static com.sonymobile.tools.gerrit.gerritevents.dto.attr.Provider createProvider(GerritServer server)
      Create event Provider from GerritServer.
      Parameters:
      server - the GerritServer to create the provider for
      Returns:
      the Provider with info from the GerritServer, or an empty provider if server is null
    • getParametersForPatchSet

      public List<ParameterValue> getParametersForPatchSet(net.sf.json.JSONObject jsonChange, net.sf.json.JSONObject jsonPatchSet, String serverName)
      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.
      serverName - the name of the GerritServer from the current session.
      Returns:
      a list of the parameters.
    • getChangeUrlParamForPatchSet

      public ParameterValue getChangeUrlParamForPatchSet(net.sf.json.JSONObject jsonChange, net.sf.json.JSONObject jsonPatchSet, String serverName)
      Returns ParameterValue for parameter with name GerritTriggerParameters.GERRIT_CHANGE_URL or null if such parameter is not present.
      Parameters:
      jsonChange - the JSON data for the change.
      jsonPatchSet - the JSON data for the patch-set.
      serverName - the name of the GerritServer from the current session.
      Returns:
      ParameterValue or null
    • hasUrl

      public boolean hasUrl(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, String serverName)
      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.
      serverName - the name of the selected Gerrit server.
      Returns:
      the URL to the change.