jetbrains.buildServer.controllers
Class XmlResponseUtil

java.lang.Object
  extended by jetbrains.buildServer.controllers.XmlResponseUtil

public class XmlResponseUtil
extends java.lang.Object

Utility class containing a set of useful methods for controllers producing XML responses (in particular for controllers processing AJAX requests).


Method Summary
static org.jdom.Element newXmlResponse()
          Creates new document with <response/> tag as its root element.
static void writeErrors(org.jdom.Element xmlResponse, ActionErrors errors)
          Writes the specified errors into the XML response
static void writeFormModifiedIfNeeded(org.jdom.Element xmlResponse, StatefulObject state)
          Adds <modified/> tag to XML response if method StatefulObject.isStateModified() returns true.
static void writeRedirect(org.jdom.Element xmlResponse, java.lang.String url)
          Adds <redirect/> tag to XML response which will contain the specified url inside.
static void writeTestResult(org.jdom.Element xmlResponse, java.lang.String additionalInfo)
          Adds <testConnectionResult/> tag into the XML response which contains specified additionalInfo parameter inside.
static void writeXmlResponse(org.jdom.Element xmlResponse, javax.servlet.http.HttpServletResponse response)
          Serializes the specified xml response to output stream of the HTTP servlet response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newXmlResponse

public static org.jdom.Element newXmlResponse()
Creates new document with <response/> tag as its root element.

Returns:
new document

writeXmlResponse

public static void writeXmlResponse(org.jdom.Element xmlResponse,
                                    javax.servlet.http.HttpServletResponse response)
                             throws java.io.IOException
Serializes the specified xml response to output stream of the HTTP servlet response.

Parameters:
xmlResponse - XML document to serialize
response - HTTP response
Throws:
java.io.IOException - if an IO error occures

writeFormModifiedIfNeeded

public static void writeFormModifiedIfNeeded(org.jdom.Element xmlResponse,
                                             StatefulObject state)
Adds <modified/> tag to XML response if method StatefulObject.isStateModified() returns true.

Parameters:
xmlResponse - XML response
state - object which state to check

writeRedirect

public static void writeRedirect(org.jdom.Element xmlResponse,
                                 java.lang.String url)
Adds <redirect/> tag to XML response which will contain the specified url inside.

Parameters:
xmlResponse - XML response
url - an URL

writeErrors

public static void writeErrors(org.jdom.Element xmlResponse,
                               ActionErrors errors)
Writes the specified errors into the XML response

Parameters:
xmlResponse - XML response
errors - errors

writeTestResult

public static void writeTestResult(org.jdom.Element xmlResponse,
                                   java.lang.String additionalInfo)
Adds <testConnectionResult/> tag into the XML response which contains specified additionalInfo parameter inside. TODO: move this method out of web-openapi

Parameters:
xmlResponse - XML response
additionalInfo - parameter