Class ParameterControlProviderAdapter
- java.lang.Object
-
- jetbrains.buildServer.controllers.parameters.api.ParameterControlProviderAdapter
-
- All Implemented Interfaces:
ParameterControlEditPresenter
,ParameterControlProvider
,ParameterControlViewPresenter
,ServerExtension
,TeamCityExtension
- Direct Known Subclasses:
CheckboxFieldParameterType
,IntegerFieldParameterType
,PasswordFieldParameterType
,RemoteParameterType
,SelectParameterTypeBase
,TextFieldParameterType
public abstract class ParameterControlProviderAdapter extends Object implements ParameterControlProvider, ParameterControlEditPresenter, ParameterControlViewPresenter
Genetic abstract class for custom controls- Since:
- 7.0
- Author:
- Eugene Petrenko (eugene.petrenko@gmail.com) Date: 22.09.11 16:39
-
-
Constructor Summary
Constructors Constructor Description ParameterControlProviderAdapter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
convertParameterValue(javax.servlet.http.HttpServletRequest request, ParameterRenderContext context, String value)
The method is called from framework to convert submitted value to value that would be save in the server settings
Use#validateParameterValue(javax.servlet.http.HttpServletRequest, ParameterContext, String)
do report detailed errorMap<String,String>
convertSpecEditorParameters(Map<String,String> parameters)
If validation of parametersParameterControlEditPresenter.validateSpecEditorParameters(java.util.Map)
succeeded, framework calls this method to convert editor properties into control description parameters type argumentsControlDescription.getParameterTypeArguments()
ParameterControlEditPresenter
getControlSpecEditPresenter()
ParameterControlViewPresenter
getControlViewPresenter()
abstract String
getParameterDescription()
Parameter description that will be shown on control spec editorabstract String
getParameterType()
Parameter type that is used to match provider instance to control instance byControlDescription.getParameterType()
String
presentParameterValue(ParameterContext context, String value)
The method is called to translate parameter value to another textual representation that could be show to the userabstract org.springframework.web.servlet.ModelAndView
renderControl(javax.servlet.http.HttpServletRequest request, ParameterRenderContext context)
Called from framework to obtain parameter presentation for given request and context.org.springframework.web.servlet.ModelAndView
renderSpecEditor(javax.servlet.http.HttpServletRequest request, ParameterEditContext context)
Called from framework to get parameter specification editing.protected static void
throwIfNotEmpty(String text)
void
validateDefaultParameterValue(ParameterContext context, String value)
Called to validate server-provided default value.void
validateParameterDescription(ParameterContext context)
Validated parameter specification.Collection<InvalidProperty>
validateParameterValue(javax.servlet.http.HttpServletRequest request, ParameterRenderContext context, String value)
The method is called from framework to validate current control value.Collection<InvalidProperty>
validateSpecEditorParameters(Map<String,String> properties)
AfterParameterControlEditPresenter.renderSpecEditor(javax.servlet.http.HttpServletRequest, ParameterEditContext)
form is submitted framework uses this properies provider to validate recieved properties.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.controllers.parameters.api.ParameterControlEditPresenter
isValueRequired
-
-
-
-
Method Detail
-
getParameterType
@NotNull public abstract String getParameterType()
Description copied from interface:ParameterControlProvider
Parameter type that is used to match provider instance to control instance byControlDescription.getParameterType()
- Specified by:
getParameterType
in interfaceParameterControlProvider
- Returns:
- control type Id
- See Also:
ControlDescription.getParameterType()
-
getParameterDescription
@NotNull public abstract String getParameterDescription()
Description copied from interface:ParameterControlProvider
Parameter description that will be shown on control spec editor- Specified by:
getParameterDescription
in interfaceParameterControlProvider
- Returns:
- human readable parameter description
-
getControlViewPresenter
@NotNull public ParameterControlViewPresenter getControlViewPresenter()
- Specified by:
getControlViewPresenter
in interfaceParameterControlProvider
- Returns:
- parameter control view manager
-
getControlSpecEditPresenter
@Nullable public ParameterControlEditPresenter getControlSpecEditPresenter()
- Specified by:
getControlSpecEditPresenter
in interfaceParameterControlProvider
- Returns:
- parameter control specification edit manager
-
renderControl
@NotNull public abstract org.springframework.web.servlet.ModelAndView renderControl(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull ParameterRenderContext context) throws InvalidParametersException
Description copied from interface:ParameterControlViewPresenter
Called from framework to obtain parameter presentation for given request and context.
Control must fit it's width to parent contaner size
Framework will add to returned model parameter named 'context' with context parameter value Use <ext:registerTypedParameterScript> custom tag to subscribe control to javascript events. See customControl.js for interface declaration.- Specified by:
renderControl
in interfaceParameterControlViewPresenter
- Parameters:
request
- http requestcontext
- parameter context- Returns:
- ModelAndView pointing to .jsp file to render
- Throws:
InvalidParametersException
-
renderSpecEditor
@NotNull public org.springframework.web.servlet.ModelAndView renderSpecEditor(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull ParameterEditContext context) throws InvalidParametersException
Description copied from interface:ParameterControlEditPresenter
Called from framework to get parameter specification editing. To validated parameters framework uses#getSpecEditorPropertiesProcessor()
and than#validateParameterDescription(jetbrains.buildServer.controllers.parameters.ParameterContext)
.
Request contains attribute 'propertiesBean' of typeBasePropertiesBean
with properties if needed. Implementation may convert properties to necessary view.
ParameterContext.getDescription()
method of context parameter returns same parameters as 'propertiesBean'- Specified by:
renderSpecEditor
in interfaceParameterControlEditPresenter
- Parameters:
request
- http requestcontext
- parameter context- Returns:
- ModelAndView to render
- Throws:
InvalidParametersException
- if parameter editing could not be shown
-
validateSpecEditorParameters
@NotNull public Collection<InvalidProperty> validateSpecEditorParameters(@NotNull Map<String,String> properties)
Description copied from interface:ParameterControlEditPresenter
AfterParameterControlEditPresenter.renderSpecEditor(javax.servlet.http.HttpServletRequest, ParameterEditContext)
form is submitted framework uses this properies provider to validate recieved properties. If validation succeeded, parameters will be converted to control description parameters type arguments viaParameterControlEditPresenter.convertSpecEditorParameters(java.util.Map)
and than it calls#validateParameterDescription(jetbrains.buildServer.controllers.parameters.ParameterContext)
to complete validation.- Specified by:
validateSpecEditorParameters
in interfaceParameterControlEditPresenter
- Returns:
- collection of invalid properties, if this collection is not empty properties will not be saved into the configuration file.
-
validateParameterDescription
public void validateParameterDescription(@NotNull ParameterContext context) throws InvalidParametersException
Description copied from interface:ParameterControlProvider
Validated parameter specification. For some options it's required to allow to have invalid default parameter value, while it's necessary to validate parameter description without relation to value.- Specified by:
validateParameterDescription
in interfaceParameterControlProvider
- Parameters:
context
- context- Throws:
InvalidParametersException
- exception in validation error
-
convertSpecEditorParameters
@NotNull public Map<String,String> convertSpecEditorParameters(@NotNull Map<String,String> parameters) throws InvalidParametersException
Description copied from interface:ParameterControlEditPresenter
If validation of parametersParameterControlEditPresenter.validateSpecEditorParameters(java.util.Map)
succeeded, framework calls this method to convert editor properties into control description parameters type argumentsControlDescription.getParameterTypeArguments()
- Specified by:
convertSpecEditorParameters
in interfaceParameterControlEditPresenter
- Parameters:
parameters
- submitted parameters fromParameterControlEditPresenter.renderSpecEditor(javax.servlet.http.HttpServletRequest, ParameterEditContext)
form- Returns:
- converted parameters for
ControlDescription
- Throws:
InvalidParametersException
- if conversion is impossible and generic error must be shown
-
validateDefaultParameterValue
public void validateDefaultParameterValue(@NotNull ParameterContext context, @Nullable String value) throws InvalidParametersException
Description copied from interface:ParameterControlViewPresenter
Called to validate server-provided default value.
This method is called from parameter spec editor and for default parameters on custom run dialog build start.- Specified by:
validateDefaultParameterValue
in interfaceParameterControlViewPresenter
- Parameters:
context
- parameter definitionvalue
- value to validate- Throws:
InvalidParametersException
- exception if value is invalid
-
validateParameterValue
@NotNull public Collection<InvalidProperty> validateParameterValue(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull ParameterRenderContext context, @Nullable String value) throws InvalidParametersException
Description copied from interface:ParameterControlViewPresenter
The method is called from framework to validate current control value.- Specified by:
validateParameterValue
in interfaceParameterControlViewPresenter
context
- parameter contextvalue
- control value- Returns:
- collection of invalid properties to be shown for control
- Throws:
InvalidParametersException
- on generic validation error
-
convertParameterValue
public String convertParameterValue(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull ParameterRenderContext context, @Nullable String value) throws InvalidParametersException
Description copied from interface:ParameterControlViewPresenter
The method is called from framework to convert submitted value to value that would be save in the server settings
Use#validateParameterValue(javax.servlet.http.HttpServletRequest, ParameterContext, String)
do report detailed error- Specified by:
convertParameterValue
in interfaceParameterControlViewPresenter
- Parameters:
request
- current requestcontext
- parameter contextvalue
- value to convert- Returns:
- value to put to contenxt
- Throws:
InvalidParametersException
- exception on generic validation error
-
presentParameterValue
@NotNull public String presentParameterValue(@NotNull ParameterContext context, @Nullable String value)
Description copied from interface:ParameterControlViewPresenter
The method is called to translate parameter value to another textual representation that could be show to the user- Specified by:
presentParameterValue
in interfaceParameterControlViewPresenter
- Parameters:
context
- parameter contextvalue
- parameter value- Returns:
- value to shot to the user
-
throwIfNotEmpty
protected static void throwIfNotEmpty(@Nullable String text) throws InvalidParametersException
- Throws:
InvalidParametersException
-
-