Class ManualTriggerAction
java.lang.Object
com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.actions.manual.ManualTriggerAction
- All Implemented Interfaces:
ExtensionPoint,Action,ModelObject,RootAction
RootAction for manually triggering a "Gerrit-build".
- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents a "vote"-type or Approval of a change in the JSON structure.static classA tuple of a high and a low number.Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe expected number of parts separated by _ in a generated id.static final StringThe char that separates the different id components in a search-result-row. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.sonymobile.tools.gerrit.gerritevents.dto.attr.ProvidercreateProvider(GerritServer server) Create event Provider from GerritServer.static com.sonymobile.tools.gerrit.gerritevents.dto.attr.ProvidercreateProviderFromGerritServer(String serverName) Create event Provider from GerritServer.voiddoBuild(String selectedIds, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) Builds the selected patch-set(s).voiddoGerritSearch(String queryString, String selectedServer, boolean allPatchSets, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) Does a search.generateTheId(net.sf.json.JSONObject change, net.sf.json.JSONObject patch) Generates a "unique" id for the change and/or patch.getChangeUrlParamForPatchSet(net.sf.json.JSONObject jsonChange, net.sf.json.JSONObject jsonPatchSet, String serverName) ReturnsParameterValuefor parameter with nameGerritTriggerParameters.GERRIT_CHANGE_URLornullif such parameter is not present.getCodeReview(net.sf.json.JSONObject res) Deprecated.getCodeReview(net.sf.json.JSONObject res, int patchSetNumber) Finds the highest and lowest code review vote for the provided patch set.Returns the list of servers allowed to be queried and manually triggered.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).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.Gets the full path to the provided javascript file.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.Serves the permission required to perform this action.getVerified(net.sf.json.JSONObject res) Deprecated.getVerified(net.sf.json.JSONObject res, int patchSetNumber) Finds the lowest and highest verified vote for the provided patch set.booleanIf this page/link is enabled or not, depending on whether at least one server is enabled.booleanhasUrl(ParameterValue parameterValue) Tells if the given parameter should have a URL or not.toReadableHtml(String subject) Cuts the string to a max length ofMAX_SUBJECT_STR_LENGTH.
-
Field Details
-
EXPECTED_NR_OF_PARTS_IN_A_GENERATED_ID
public static final int EXPECTED_NR_OF_PARTS_IN_A_GENERATED_IDThe expected number of parts separated by _ in a generated id. Each part is actually another id. -
ID_SEPARATOR
The char that separates the different id components in a search-result-row.- See Also:
-
-
Constructor Details
-
ManualTriggerAction
public ManualTriggerAction()
-
-
Method Details
-
getIconFileName
- Specified by:
getIconFileNamein interfaceAction
-
getDisplayName
- Specified by:
getDisplayNamein interfaceAction- Specified by:
getDisplayNamein interfaceModelObject
-
getUrlName
- Specified by:
getUrlNamein interfaceAction
-
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
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
Returns the list of servers allowed to be queried and manually triggered.- Returns:
- the enabled server names
-
getRequiredPermission
Serves the permission required to perform this action. Used by index.jelly- Returns:
- the permission.
-
getJsUrl
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.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
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.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
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
Cuts the string to a max length ofMAX_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
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) ReturnsParameterValuefor parameter with nameGerritTriggerParameters.GERRIT_CHANGE_URLornullif 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
Tells if the given parameter should have a URL or not. i.e. if the parameter representsGerritTriggerParameters.GERRIT_CHANGE_URL.- Parameters:
parameterValue- the parameter.- Returns:
- true if so.
-
getGerritUrl
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.
-