Class ManualTriggerAction
- 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>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description ManualTriggerAction()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static com.sonymobile.tools.gerrit.gerritevents.dto.attr.Provider
createProvider(GerritServer server)
Create event Provider from GerritServer.static com.sonymobile.tools.gerrit.gerritevents.dto.attr.Provider
createProviderFromGerritServer(String serverName)
Create event Provider from GerritServer.void
doBuild(String selectedIds, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
Builds the selected patch-set(s).void
doGerritSearch(String queryString, String selectedServer, boolean allPatchSets, 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.ParameterValue
getChangeUrlParamForPatchSet(net.sf.json.JSONObject jsonChange, net.sf.json.JSONObject jsonPatchSet, String serverName)
ReturnsParameterValue
for parameter with nameGerritTriggerParameters.GERRIT_CHANGE_URL
ornull
if such parameter is not present.ManualTriggerAction.HighLow
getCodeReview(net.sf.json.JSONObject res)
Deprecated.ManualTriggerAction.HighLow
getCodeReview(net.sf.json.JSONObject res, int patchSetNumber)
Finds the highest and lowest code review vote for the provided patch set.String
getDisplayName()
ArrayList<String>
getEnabledServers()
Returns the list of servers allowed to be queried and manually triggered.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).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.String
getIconFileName()
String
getJsUrl(String jsName)
Gets the full path to the provided javascript file.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.Permission
getRequiredPermission()
Serves the permission required to perform this action.String
getUrlName()
ManualTriggerAction.HighLow
getVerified(net.sf.json.JSONObject res)
Deprecated.ManualTriggerAction.HighLow
getVerified(net.sf.json.JSONObject res, int patchSetNumber)
Finds the lowest and highest verified vote for the provided patch set.boolean
hasEnabledServers()
If this page/link is enabled or not, depending on whether at least one server is enabled.boolean
hasUrl(ParameterValue parameterValue)
Tells if the given parameter should have a URL or not.String
toReadableHtml(String subject)
Cuts the string to a max length ofMAX_SUBJECT_STR_LENGTH
.
-
-
-
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.
-
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
-
-
Method Detail
-
getIconFileName
public String getIconFileName()
- Specified by:
getIconFileName
in interfaceAction
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrlName
public String getUrlName()
- Specified by:
getUrlName
in 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:
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 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
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)
ReturnsParameterValue
for parameter with nameGerritTriggerParameters.GERRIT_CHANGE_URL
ornull
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 representsGerritTriggerParameters.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.
-
-