jetbrains.buildServer.controllers
Class BaseFormXmlController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by jetbrains.buildServer.controllers.BaseController
                      extended by jetbrains.buildServer.controllers.BaseFormXmlController
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.mvc.Controller
Direct Known Subclasses:
FileUploadController, MultipartFormController

public abstract class BaseFormXmlController
extends BaseController

Controller which output is xml in case of POST request and usual response in case of GET.


Field Summary
 
Fields inherited from class jetbrains.buildServer.controllers.BaseController
myServer
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
protected BaseFormXmlController()
          Constructor
  BaseFormXmlController(SBuildServer server)
          Constructor
 
Method Summary
protected  void addMessage(javax.servlet.http.HttpServletRequest request, java.lang.String key, java.lang.String text, java.lang.String... parameters)
          Adds a messages to the messages storage associated with specified request.
protected  org.springframework.validation.BindingResult bindFromRequest(javax.servlet.http.HttpServletRequest request, java.lang.Object bean)
          Binds the specified bean properties from the HTTP request.
protected abstract  org.springframework.web.servlet.ModelAndView doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Implement this method to process GET requests.
protected  org.springframework.web.servlet.ModelAndView doHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Performs actual request processing
protected abstract  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.jdom.Element xmlResponse)
          Implement this method to process POST requests.
protected  void forgetFormBean(javax.servlet.http.HttpServletRequest request, java.lang.Class clazz)
          Removes a form bean of the specified class from the session.
protected  void forgetFormBean(javax.servlet.http.HttpServletRequest request, java.lang.Class clazz, java.lang.String customKey)
          Removes a form bean of the specified class from the session.
protected
<T> T
getOrCreateFormBean(javax.servlet.http.HttpServletRequest request, java.lang.Class<T> clazz, FormUtil.FormCreator<T> formBeanCreator)
          Retrieves or creates (using the specified form bean creator) a form bean of the specified class.
protected
<T> T
getOrCreateFormBean(javax.servlet.http.HttpServletRequest request, java.lang.Class<T> clazz, java.lang.String customKey, FormUtil.FormCreator<T> formBeanCreator)
          Retrieves or creates (using the specified form bean creator) a form bean of the specified class.
protected  boolean isInitPageRequest(javax.servlet.http.HttpServletRequest request)
          Returns true if request contains parameter: init.
protected  org.springframework.web.servlet.ModelAndView selfRedirectOnInit(javax.servlet.http.HttpServletRequest request)
           
protected  void writeErrors(org.jdom.Element xmlResponse, ActionErrors errors)
          Writes errors to the XML response.
protected  void writeRedirect(org.jdom.Element xmlResponse, java.lang.String url)
          Writes redirect to the XML response.
 
Methods inherited from class jetbrains.buildServer.controllers.BaseController
getOrCreateMessages, handleRequestInternal, isGet, isPost, simpleView
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseFormXmlController

public BaseFormXmlController(@NotNull
                             SBuildServer server)
Constructor

Parameters:
server - SBuildServer instance

BaseFormXmlController

protected BaseFormXmlController()
Constructor

Method Detail

doHandle

@Nullable
protected org.springframework.web.servlet.ModelAndView doHandle(@NotNull
                                                                         javax.servlet.http.HttpServletRequest request,
                                                                         @NotNull
                                                                         javax.servlet.http.HttpServletResponse response)
                                                         throws java.lang.Exception
Description copied from class: BaseController
Performs actual request processing

Specified by:
doHandle in class BaseController
Parameters:
request - HTTP request
response - HTTP response
Returns:
model and view components
Throws:
java.lang.Exception - exception

doGet

protected abstract org.springframework.web.servlet.ModelAndView doGet(@NotNull
                                                                      javax.servlet.http.HttpServletRequest request,
                                                                      @NotNull
                                                                      javax.servlet.http.HttpServletResponse response)
Implement this method to process GET requests. Usually on GET request a form bean is created and a page is shown.

Parameters:
request - HTTP request
response - HTTP response
Returns:
model and view components

doPost

protected abstract void doPost(@NotNull
                               javax.servlet.http.HttpServletRequest request,
                               @NotNull
                               javax.servlet.http.HttpServletResponse response,
                               @NotNull
                               org.jdom.Element xmlResponse)
Implement this method to process POST requests. Usually POST requests are changing state of the form bean and underlying model. To output errors (if request validation failed) ActionErrors can be used. To add messages (if request processing was successful) use addMessage(javax.servlet.http.HttpServletRequest, String, String, String...) method.

Parameters:
request - HTTP request
response - HTTP response
xmlResponse - XML response for AJAX requests

writeRedirect

protected void writeRedirect(@NotNull
                             org.jdom.Element xmlResponse,
                             @NotNull
                             java.lang.String url)
Writes redirect to the XML response. This redirect command is then can be processed by JavaScript on the client side.

Parameters:
xmlResponse - XML response
url - URL

writeErrors

protected void writeErrors(@NotNull
                           org.jdom.Element xmlResponse,
                           @NotNull
                           ActionErrors errors)
Writes errors to the XML response. These errors can be then processed by JavaScript.

Parameters:
xmlResponse - XML response
errors - errors

bindFromRequest

protected org.springframework.validation.BindingResult bindFromRequest(@NotNull
                                                                       javax.servlet.http.HttpServletRequest request,
                                                                       @NotNull
                                                                       java.lang.Object bean)
Binds the specified bean properties from the HTTP request.

Parameters:
request - HTTP request
bean - bean
Returns:
binding result

getOrCreateFormBean

protected <T> T getOrCreateFormBean(javax.servlet.http.HttpServletRequest request,
                                    java.lang.Class<T> clazz,
                                    FormUtil.FormCreator<T> formBeanCreator)
Retrieves or creates (using the specified form bean creator) a form bean of the specified class.

Parameters:
request - HTTP request
clazz - class
formBeanCreator - form bean creator
Returns:
Retrieves or creates form bean of the specified class

getOrCreateFormBean

protected <T> T getOrCreateFormBean(javax.servlet.http.HttpServletRequest request,
                                    java.lang.Class<T> clazz,
                                    java.lang.String customKey,
                                    FormUtil.FormCreator<T> formBeanCreator)
Retrieves or creates (using the specified form bean creator) a form bean of the specified class.

Parameters:
request - HTTP request
clazz - class
customKey - additional key identifying the form bean in the session
formBeanCreator - form bean creator
Returns:
Retrieves or creates form bean of the specified class

forgetFormBean

protected void forgetFormBean(javax.servlet.http.HttpServletRequest request,
                              java.lang.Class clazz)
Removes a form bean of the specified class from the session.

Parameters:
request - HTTP request
clazz - class

forgetFormBean

protected void forgetFormBean(javax.servlet.http.HttpServletRequest request,
                              java.lang.Class clazz,
                              java.lang.String customKey)
Removes a form bean of the specified class from the session.

Parameters:
request - HTTP request
clazz - class
customKey - additional key

isInitPageRequest

protected boolean isInitPageRequest(javax.servlet.http.HttpServletRequest request)
Returns true if request contains parameter: init.

Parameters:
request - HTTP request
Returns:
true if init parameter presents

addMessage

protected void addMessage(@NotNull
                          javax.servlet.http.HttpServletRequest request,
                          @NotNull
                          java.lang.String key,
                          java.lang.String text,
                          java.lang.String... parameters)
Adds a messages to the messages storage associated with specified request.

The caller cannot pass raw HTML message using this constructor, as the message and parameters will be escaped.

Parameters:
request - HTTP request
key - message key
text - message
parameters - if specified then substrings like {0}, {1}, {2} and so on will be replaced with parameter with corresponding index.
See Also:
ActionMessages.addMessage(String, String, String...)

selfRedirectOnInit

protected org.springframework.web.servlet.ModelAndView selfRedirectOnInit(@NotNull
                                                                          javax.servlet.http.HttpServletRequest request)