Class ManualTriggerAction

    • Constructor Detail

      • ManualTriggerAction

        public ManualTriggerAction()
    • Method Detail

      • 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:
        IGerritHudsonTriggerConfig.isEnableManualTrigger()
      • 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
      • 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.