Class XmlResponseUtil


  • public class XmlResponseUtil
    extends Object
    Utility class containing a set of useful methods for controllers producing XML responses (in particular for controllers processing AJAX requests).
    • Method Detail

      • newXmlResponse

        @NotNull
        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 IOException
        Serializes the specified xml response to output stream of the HTTP servlet response.
        Parameters:
        xmlResponse - XML document to serialize
        response - HTTP response
        Throws:
        IOException - if an IO error occurs
      • 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​(@NotNull
                                         org.jdom.Element xmlResponse,
                                         @NotNull
                                         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,
                                           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