<mm:content type="application/xml"
            language="en" expires="-1"
            xmlns:mm="http://www.mmbase.org/mmbase-taglib-2.0"
            xmlns:jsp="http://java.sun.com/JSP/Page">
  <jsp:directive.page import="java.io.*,java.util.*,org.apache.commons.fileupload.*" session="true" errorPage="error.jspx" />
  <jsp:output omit-xml-declaration="true" />

  <html>
    <head>
      <title>KUPU-receiver</title>
    </head>
    <body >
      <mm:cloud jspvar="cloud" rank="basic user">
        <mm:log jspvar="log">
          <mm:import externid="kupu_node" from="session" />
          <mm:node number="${kupu_node.number}" jspvar="node">
            <mm:import externid="fields">false</mm:import>
            <mm:compare referid="fields" value="false">
              <mm:param name="org.mmbase.xml-mode" value="kupu" />
              <jsp:scriptlet>
                log.service("Saving body of " + node.getNumber());
                StringBuffer received = new StringBuffer();
                BufferedReader r  =  new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
                String line = r.readLine();
                while (line != null) {
                  received.append(line).append("\n");
                  line = r.readLine();
                }
                node.setStringValue("body", received.toString());
                log.debug("Saved " + received.toString());
              </jsp:scriptlet>
            </mm:compare>

            <mm:compare referid="fields" value="true">
              <mm:fieldlist id="field" type="edit" >
                <mm:fieldinfo type="useinput" options="trim" />
              </mm:fieldlist>
            </mm:compare>
          </mm:node>
          <jsp:scriptlet>
            log.service("Saved body");
          </jsp:scriptlet>
        </mm:log>
      </mm:cloud>
    </body>
  </html>
</mm:content>
