hudson.plugins.reviewboard
Class ReviewboardDescriptorImpl

java.lang.Object
  extended by hudson.model.Descriptor<T>
      extended by hudson.tasks.BuildStepDescriptor<hudson.tasks.Publisher>
          extended by hudson.plugins.reviewboard.ReviewboardDescriptorImpl
All Implemented Interfaces:
hudson.model.Saveable

@Extension
public final class ReviewboardDescriptorImpl
extends hudson.tasks.BuildStepDescriptor<hudson.tasks.Publisher>

Descriptor for ReviewboardPublisher. Used as a singleton. The class is marked as public so that it can be accessed from views.

Version:
1.0
Author:
Ryan Shelley

Nested Class Summary
 
Nested classes/interfaces inherited from class hudson.model.Descriptor
hudson.model.Descriptor.FormException, hudson.model.Descriptor.PropertyType
 
Field Summary
 
Fields inherited from class hudson.model.Descriptor
clazz
 
Fields inherited from interface hudson.model.Saveable
NOOP
 
Constructor Summary
ReviewboardDescriptorImpl()
           
 
Method Summary
 boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject o)
          Configures the Reviewboard plugin with parameters supplied on the Global configuration page of Hudson.
 hudson.util.FormValidation doCheckCmdPath(String cmdPath)
          Validates that the command supplied exists and can be executed.
 hudson.util.FormValidation doCheckDaysBeforeStaleReview(Integer daysBeforeStaleReview)
          Validates that the number of days before a review is considered stale is greater than or equal to -1.
 hudson.util.FormValidation doCheckDefaultReviewers(String defaultReviewers)
          Validates that the reviewers entered match existing Reviewboard users.
 hudson.util.FormValidation doCheckDefaultReviewGroups(String defaultReviewGroups)
          Validates that the review groups entered match existing Reviewboard groups.
 hudson.util.FormValidation doCheckForceUpdateOverride(boolean forceUpdateOverride, boolean skipUnflaggedChanges)
           
 hudson.util.FormValidation doCheckKeyRegEx(String keyRegEx)
          Validates the regular expression supplied is a valid pattern for the external ID as set on the Build's configuration page.
 hudson.util.FormValidation doCheckSkipUnflaggedChanges(boolean forceUpdateOverride, boolean skipUnflaggedChanges)
           
 hudson.util.FormValidation doCheckUrl(String url)
          Validates that the Reviewboard URL supplied is available.
 String getCmdPath()
          Returns the reviewboard command path
 String getDisplayName()
          This human readable name is used in the configuration screen.
 String getPassword()
          Returns the reviewboard password
protected  ReviewboardHttpAPI getReviewboardAPI()
          Returns a configured Reviewboard API
 Set<String> getReviewboardGroups()
           
 Set<String> getReviewboardUsers()
           
 String getUrl()
          Returns the reviewboard URL
 String getUsername()
          Returns the reviewboard username
 boolean isApplicable(Class<? extends hudson.model.AbstractProject> aClass)
           
protected  boolean isPluginConfigured()
          Validates that the plugin is properly configured and reviewboard is available.
protected  boolean isSavedCommandPathValid()
          Validates that the command path to post-review is available and executable.
protected  boolean isSavedURLValid()
          Validates that the saved URL is available.
protected  boolean isValidURL(String url)
          Validates a URL is available and responds with a 200 error code.
 
Methods inherited from class hudson.tasks.BuildStepDescriptor
filter
 
Methods inherited from class hudson.model.Descriptor
calcAutoCompleteSettings, calcFillSettings, configure, doHelp, find, find, getCheckUrl, getConfigFile, getConfigPage, getDescriptorUrl, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getPropertyType, getPropertyType, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, toArray, toList, toMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReviewboardDescriptorImpl

public ReviewboardDescriptorImpl()
Method Detail

doCheckKeyRegEx

public hudson.util.FormValidation doCheckKeyRegEx(@QueryParameter
                                                  String keyRegEx)
                                           throws IOException,
                                                  javax.servlet.ServletException
Validates the regular expression supplied is a valid pattern for the external ID as set on the Build's configuration page. Example description: FMYHUD-123 fixes issues with build Example expression : FMYHUD-[0-9]+ The result will be "FMYHUD-123" is extracted and used as an external key to map future changes to existing review requests (so if someone submits several change requests with the same external ID, the original review request is updated instead of new review requests being created).

Parameters:
keyRegEx - regular expression matching the external ID to extract from the change description
Returns:
FormValidation.ok if the regular expression is valid, FormValidation.error if not
Throws:
IOException
javax.servlet.ServletException

doCheckCmdPath

public hudson.util.FormValidation doCheckCmdPath(@QueryParameter
                                                 String cmdPath)
                                          throws IOException,
                                                 javax.servlet.ServletException
Validates that the command supplied exists and can be executed. Searches the path environment for the executable. Complete path is not necessary.

Parameters:
cmdPath - command to execute post-review, and is often just "post-review.exe"
Returns:
FormValidation.ok if the command is found, FormValidation.error if not
Throws:
IOException
javax.servlet.ServletException

doCheckDaysBeforeStaleReview

public hudson.util.FormValidation doCheckDaysBeforeStaleReview(@QueryParameter
                                                               Integer daysBeforeStaleReview)
                                                        throws IOException,
                                                               javax.servlet.ServletException
Validates that the number of days before a review is considered stale is greater than or equal to -1. -1 = never

Parameters:
cmdPath - command to execute post-review, and is often just "post-review.exe"
Returns:
FormValidation.ok if the command is found, FormValidation.error if not
Throws:
IOException
javax.servlet.ServletException

doCheckUrl

public hudson.util.FormValidation doCheckUrl(@QueryParameter
                                             String url)
                                      throws IOException,
                                             javax.servlet.ServletException
Validates that the Reviewboard URL supplied is available.

Parameters:
url - URL to reviewboard instance
Returns:
FormValidation.ok if the URL was available, FormValidation.error if not
Throws:
IOException
javax.servlet.ServletException

doCheckDefaultReviewers

public hudson.util.FormValidation doCheckDefaultReviewers(@QueryParameter
                                                          String defaultReviewers)
                                                   throws IOException,
                                                          javax.servlet.ServletException
Validates that the reviewers entered match existing Reviewboard users.

Parameters:
defaultReviewers - Comma-delimited list of reviewers to check
Returns:
FormValidation.ok if field is empty or users all exist, otherwise FormValidation.error
Throws:
IOException
javax.servlet.ServletException

doCheckDefaultReviewGroups

public hudson.util.FormValidation doCheckDefaultReviewGroups(@QueryParameter
                                                             String defaultReviewGroups)
                                                      throws IOException,
                                                             javax.servlet.ServletException
Validates that the review groups entered match existing Reviewboard groups.

Parameters:
defaultReviewGroups - Comma-delimited list of groups to check
Returns:
FormValidation.ok if field is empty or groups all exist, otherwise FormValidation.error
Throws:
IOException
javax.servlet.ServletException

doCheckForceUpdateOverride

public hudson.util.FormValidation doCheckForceUpdateOverride(@QueryParameter
                                                             boolean forceUpdateOverride,
                                                             @QueryParameter
                                                             boolean skipUnflaggedChanges)

doCheckSkipUnflaggedChanges

public hudson.util.FormValidation doCheckSkipUnflaggedChanges(@QueryParameter
                                                              boolean forceUpdateOverride,
                                                              @QueryParameter
                                                              boolean skipUnflaggedChanges)

isApplicable

public boolean isApplicable(Class<? extends hudson.model.AbstractProject> aClass)
Specified by:
isApplicable in class hudson.tasks.BuildStepDescriptor<hudson.tasks.Publisher>

getDisplayName

public String getDisplayName()
This human readable name is used in the configuration screen.

Specified by:
getDisplayName in class hudson.model.Descriptor<hudson.tasks.Publisher>
Returns:
name of plugin

configure

public boolean configure(org.kohsuke.stapler.StaplerRequest req,
                         net.sf.json.JSONObject o)
                  throws hudson.model.Descriptor.FormException
Configures the Reviewboard plugin with parameters supplied on the Global configuration page of Hudson.

Overrides:
configure in class hudson.model.Descriptor<hudson.tasks.Publisher>
Parameters:
req - Form submission request
o - JSON object containing values from global configuration
Throws:
hudson.model.Descriptor.FormException

getUrl

public String getUrl()
Returns the reviewboard URL

Returns:
reviewboard URL

getUsername

public String getUsername()
Returns the reviewboard username

Returns:
reviewboard username

getPassword

public String getPassword()
Returns the reviewboard password

Returns:
reviewboard password

getCmdPath

public String getCmdPath()
Returns the reviewboard command path

Returns:
reviewboard command path

getReviewboardGroups

public Set<String> getReviewboardGroups()

getReviewboardUsers

public Set<String> getReviewboardUsers()

getReviewboardAPI

protected ReviewboardHttpAPI getReviewboardAPI()
                                        throws org.apache.commons.httpclient.URIException,
                                               NullPointerException
Returns a configured Reviewboard API

Returns:
Configured and ready-to-use Reviewboard API, or null if an error occurred creating it
Throws:
org.apache.commons.httpclient.URIException
NullPointerException

isValidURL

protected boolean isValidURL(String url)
                      throws URISyntaxException,
                             IOException
Validates a URL is available and responds with a 200 error code.

Parameters:
url - to check
Returns:
true if response code is >= 200 and < 300, otherwise false
Throws:
URISyntaxException
MalformedURLException
IOException

isSavedURLValid

protected boolean isSavedURLValid()
Validates that the saved URL is available. This is executed before the build tries to create a reviewboard request to ensure reviewboard is available.

Returns:
true if the URL is available, false otherwise

isSavedCommandPathValid

protected boolean isSavedCommandPathValid()
Validates that the command path to post-review is available and executable.

Returns:
true if available, false otherwise

isPluginConfigured

protected boolean isPluginConfigured()
Validates that the plugin is properly configured and reviewboard is available. This is called before the plugin is executed after a build to ensure that it can be executed properly.

Returns:
true if the plugin is properly configured and reviewboard is available, false otherwise


Copyright © 2004-2012 Hudson. All Rights Reserved.