You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2005/02/08 19:15:31 UTC

svn commit: r152682 [5/17] - in lenya/trunk/src: java/org/apache/lenya/ac/ java/org/apache/lenya/ac/cache/ java/org/apache/lenya/ac/file/ java/org/apache/lenya/ac/impl/ java/org/apache/lenya/ac/ldap/ java/org/apache/lenya/cms/ac/ java/org/apache/lenya/cms/ac/cocoon/ java/org/apache/lenya/cms/ac/usecase/ java/org/apache/lenya/cms/ac/usecases/ java/org/apache/lenya/cms/ac/workflow/ java/org/apache/lenya/cms/ant/ java/org/apache/lenya/cms/authoring/ java/org/apache/lenya/cms/cocoon/acting/ java/org/apache/lenya/cms/cocoon/bean/ java/org/apache/lenya/cms/cocoon/components/modules/input/ java/org/apache/lenya/cms/cocoon/flow/ java/org/apache/lenya/cms/cocoon/generation/ java/org/apache/lenya/cms/cocoon/matching/ java/org/apache/lenya/cms/cocoon/scheduler/ java/org/apache/lenya/cms/cocoon/source/ java/org/apache/lenya/cms/cocoon/task/ java/org/apache/lenya/cms/cocoon/transformation/ java/org/apache/lenya/cms/cocoon/uriparameterizer/ java/org/apache/lenya/cms/metadata/dublincore/ java/org/apache/lenya/cms/metadata/usecases/ java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/publication/file/ java/org/apache/lenya/cms/publication/task/ java/org/apache/lenya/cms/publication/templating/ java/org/apache/lenya/cms/publication/util/ java/org/apache/lenya/cms/publishing/ java/org/apache/lenya/cms/rc/ java/org/apache/lenya/cms/scheduler/ java/org/apache/lenya/cms/scheduler/xml/ java/org/apache/lenya/cms/search/usecases/ java/org/apache/lenya/cms/site/ java/org/apache/lenya/cms/site/tree/ java/org/apache/lenya/cms/site/usecases/ java/org/apache/lenya/cms/task/ java/org/apache/lenya/cms/usecase/ java/org/apache/lenya/cms/workflow/ java/org/apache/lenya/lucene/ java/org/apache/lenya/lucene/html/ java/org/apache/lenya/lucene/index/ java/org/apache/lenya/lucene/parser/ java/org/apache/lenya/net/ java/org/apache/lenya/search/ java/org/apache/lenya/search/crawler/ java/org/apache/lenya/util/ java/org/apache/lenya/workflow/ java/org/apache/lenya/workflow/impl/ java/org/apache/lenya/xml/ test/org/apache/lenya/ac/file/ test/org/apache/lenya/ac/impl/ test/org/apache/lenya/cms/ test/org/apache/lenya/cms/authoring/ test/org/apache/lenya/cms/cocoon/generation/ test/org/apache/lenya/cms/publication/ test/org/apache/lenya/cms/publication/file/ test/org/apache/lenya/cms/rc/ test/org/apache/lenya/cms/site/tree/ test/org/apache/lenya/cms/task/ test/org/apache/lenya/cms/workflow/ test/org/apache/lenya/net/

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/HTMLFormSaveAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/HTMLFormSaveAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/HTMLFormSaveAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/HTMLFormSaveAction.java Tue Feb  8 10:13:39 2005
@@ -23,16 +23,20 @@
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.net.MalformedURLException;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.stream.StreamResult;
@@ -50,6 +54,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.excalibur.source.ModifiableSource;
 import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.RelaxNG;
 import org.apache.lenya.xml.XPath;
@@ -59,8 +64,10 @@
 import org.w3c.dom.NodeList;
 
 import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 import org.xmldb.common.xml.queries.XObject;
 import org.xmldb.common.xml.queries.XPathQuery;
+import org.xmldb.common.xml.queries.XPathQueryConfigurationException;
 import org.xmldb.common.xml.queries.XPathQueryFactory;
 import org.xmldb.common.xml.queries.XUpdateQuery;
 import org.xmldb.xupdate.lexus.XUpdateQueryImpl;
@@ -71,35 +78,41 @@
  * moving the namespaces to the elements which use them! One hack might be to parse the tree for
  * namespaces (Node.getNamespaceURI), collect them and add them to the document root element, before
  * sending it through the org.apache.xpath.compiler.XPathParser (called by XPathAPI)
- * 
  * FIXME: There seems to be another problem with default namespaces
- * 
  * WARNING: Internet Explorer sends X and Y coordinates for image buttons. These have to be treated
  * differently. Mozilla does not send these coordinates.
  */
 public class HTMLFormSaveAction extends AbstractConfigurableAction implements ThreadSafe {
 
     class XUpdateAttributes {
+        /**
+         * <code>xupdateAttrExpr</code> The Xupdate expression
+         */
         public String xupdateAttrExpr = "";
+        /**
+         * <code>tagID</code> The tag ID
+         */
         public String tagID = "";
 
-        public XUpdateAttributes(String xupdateAttrExpr, String tagID) {
-            this.xupdateAttrExpr = xupdateAttrExpr;
-            this.tagID = tagID;
+        /**
+         * Set Xupdate attributes
+         * @param _xupdateAttrExpr The xupdate expression
+         * @param _tagID The tag id
+         */
+        public XUpdateAttributes(String _xupdateAttrExpr, String _tagID) {
+            this.xupdateAttrExpr = _xupdateAttrExpr;
+            this.tagID = _tagID;
         }
     }
 
     /**
      * Save data to temporary file
-     * 
      * @param redirector a <code>Redirector</code> value
      * @param resolver a <code>SourceResolver</code> value
      * @param objectModel a <code>Map</code> value
      * @param source a <code>String</code> value
      * @param parameters a <code>Parameters</code> value
-     * 
      * @return a <code>Map</code> value
-     * 
      * @exception Exception if an error occurs
      */
     public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source,
@@ -117,268 +130,333 @@
         Source unnumberTagsXslSource = null;
         Source numberTagsXslSource = null;
 
-        try {
+        xmlSource = resolver.resolveURI(xmlUri);
+        schemaSource = resolver.resolveURI(schemaUri);
+        unnumberTagsXslSource = resolver.resolveURI(unnumberTagsXslUri);
+        numberTagsXslSource = resolver.resolveURI(numberTagsXslUri);
 
-            xmlSource = resolver.resolveURI(xmlUri);
-            schemaSource = resolver.resolveURI(schemaUri);
-            unnumberTagsXslSource = resolver.resolveURI(unnumberTagsXslUri);
-            numberTagsXslSource = resolver.resolveURI(numberTagsXslUri);
+        if (!(xmlSource instanceof ModifiableSource)) {
+            throw new ProcessingException("Source [" + xmlSource + "] is not writeable.");
+        }
 
-            if (!(xmlSource instanceof ModifiableSource)) {
-                throw new ProcessingException("Source [" + xmlSource + "] is not writeable.");
-            }
+        ModifiableSource modifiableXmlSource = (ModifiableSource) xmlSource;
 
-            ModifiableSource modifiableXmlSource = (ModifiableSource) xmlSource;
+        if (request.getParameter("cancel") != null) {
+            getLogger().warn(".act(): Editing has been canceled");
+            modifiableXmlSource.delete();
+            return null;
+        }
 
-            if (request.getParameter("cancel") != null) {
-                getLogger().warn(".act(): Editing has been canceled");
-                modifiableXmlSource.delete();
-                return null;
+        try {
+            return save(resolver, request, xmlSource, schemaSource, unnumberTagsXslSource, 
+                    numberTagsXslSource, modifiableXmlSource);
+        } catch (final ProcessingException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (MalformedURLException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (TransformerConfigurationException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (FactoryConfigurationError e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (ParserConfigurationException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (IOException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (SAXException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (XPathQueryConfigurationException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (TransformerException e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } catch (Exception e) {
+            getLogger().error("Exception", e);
+            HashMap hmap = new HashMap();
+            hmap.put("message", "Exception");
+            return hmap;
+        } finally {
+            if (xmlSource != null) {
+                resolver.release(xmlSource);
+            }
+            if (schemaSource != null) {
+                resolver.release(schemaSource);
+            }
+            if (unnumberTagsXslSource != null) {
+                resolver.release(unnumberTagsXslSource);
+            }
+            if (numberTagsXslSource != null) {
+                resolver.release(numberTagsXslSource);
+            }
             }
 
-            else {
-                if (!xmlSource.exists()) {
-                    throw new ProcessingException("The source [" + xmlSource.getURI()
-                            + "] does not exist.");
-                }
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("Save modifications to [" + xmlSource.getURI() + "]");
-                }
+    }
 
-                try {
-                    Document document = null;
-                    DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
-                    parserFactory.setValidating(false);
-                    parserFactory.setNamespaceAware(true);
-                    parserFactory.setIgnoringElementContentWhitespace(true);
-                    DocumentBuilder builder = parserFactory.newDocumentBuilder();
-
-                    InputSource xmlInputSource = SourceUtil.getInputSource(xmlSource);
-                    document = builder.parse(xmlInputSource);
-                    System.setProperty("org.xmldb.common.xml.queries.XPathQueryFactory",
-                            "org.xmldb.common.xml.queries.xalan2.XPathQueryFactoryImpl");
-
-                    XPathQuery xpath = XPathQueryFactory.newInstance().newXPathQuery();
-                    XUpdateQuery xq = new XUpdateQueryImpl();
-
-                    String editSelect = null;
-                    Enumeration params = request.getParameterNames();
-                    while (params.hasMoreElements()) {
-                        String pname = (String) params.nextElement();
-                        getLogger().debug(
-                                "Parameter: " + pname + " (" + request.getParameter(pname) + ")");
-
-                        // Extract the xpath to edit
-                        if (editSelect == null && pname.indexOf("edit[") >= 0
-                                && pname.endsWith("].x")) {
-                            editSelect = pname.substring(5, pname.length() - 3);
-                            getLogger().debug("Edit: " + editSelect);
-                        }
+    /**
+     * Save the Form
+     * @param resolver
+     * @param request
+     * @param xmlSource
+     * @param schemaSource
+     * @param unnumberTagsXslSource
+     * @param numberTagsXslSource
+     * @param modifiableXmlSource
+     * @return
+     * @throws ProcessingException
+     * @throws FactoryConfigurationError
+     * @throws ParserConfigurationException
+     * @throws IOException
+     * @throws SAXException
+     * @throws XPathQueryConfigurationException
+     * @throws Exception
+     * @throws MalformedURLException
+     * @throws TransformerConfigurationException
+     * @throws TransformerException
+     */
+    private Map save(SourceResolver resolver, Request request, Source xmlSource, Source schemaSource, 
+            Source unnumberTagsXslSource, Source numberTagsXslSource, ModifiableSource modifiableXmlSource) 
+    		throws ProcessingException, FactoryConfigurationError, ParserConfigurationException, 
+    		IOException, SAXException, XPathQueryConfigurationException, Exception, 
+    		MalformedURLException, TransformerConfigurationException, TransformerException {
+        if (!xmlSource.exists()) {
+            throw new ProcessingException("The source [" + xmlSource.getURI()
+                    + "] does not exist.");
+        }
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Save modifications to [" + xmlSource.getURI() + "]");
+        }
 
-                        // Make sure we are dealing with an xupdate statement,
-                        // else skip
-                        if (pname.indexOf("<xupdate:") == 0) {
-                            String select = pname.substring(pname.indexOf("select") + 8);
-                            select = select.substring(0, select.indexOf("\""));
-                            getLogger().debug(".act() Select Node: " + select);
-
-                            // Check if node exists
-                            xpath.setQString(select);
-                            XObject result = xpath.execute(document);
-                            NodeList selectionNodeList = result.nodeset();
-                            if (selectionNodeList.getLength() == 0) {
-                                getLogger().debug(
-                                        ".act(): Node does not exist (might have been deleted during update): "
-                                                + select);
-                            } else {
-                                String xupdateModifications = null;
-                                // now check for the different xupdate
-                                // statements, and handle appropriately
-                                if (pname.indexOf("xupdate:update-parent") > 0) {
-                                    getLogger().debug("UPDATE PARENT Node: " + pname);
-                                    // CDATA updates need to be handled
-                                    // seperately
-                                    if (pname.indexOf("<![CDATA[") > 0) {
-                                        xupdateModifications = updateCDATA(request, pname, true);
-                                    } else {
-                                        xupdateModifications = update(request, pname, select,
-                                                selectionNodeList, true);
-                                    }
-                                } else if (pname.indexOf("xupdate:update") > 0) {
-                                    getLogger().debug("UPDATE Node: " + pname);
-                                    // CDATA updates need to be handled
-                                    // seperately
-                                    if (pname.indexOf("<![CDATA[") > 0) {
-                                        xupdateModifications = updateCDATA(request, pname, false);
-                                    } else {
-                                        xupdateModifications = update(request, pname, select,
-                                                selectionNodeList, false);
-                                    }
-                                } else if (pname.indexOf("xupdate:append") > 0
-                                        && pname.endsWith(">.x")) {
-                                    xupdateModifications = append(pname.substring(0,
-                                            pname.length() - 2));
-                                    // insert-before: in case of select/option
-                                } else if (pname.indexOf("xupdate:insert-before") > 0
-                                        && pname.endsWith("/>")) {
-                                    if (!request.getParameter(pname).equals("null")) {
-                                        xupdateModifications = insertBefore(request
-                                                .getParameter(pname));
-                                    }
-                                    // insert-before: in case of image
-                                } else if (pname.indexOf("xupdate:insert-before") > 0
-                                        && pname.endsWith(">.x")) {
-                                    xupdateModifications = insertBefore(pname.substring(0, pname
-                                            .length() - 2));
-                                    // insert-after: in case of select/option
-                                } else if (pname.indexOf("xupdate:insert-after") > 0
-                                        && pname.endsWith("/>")) {
-                                    if (!request.getParameter(pname).equals("null")) {
-                                        xupdateModifications = insertAfter(request
-                                                .getParameter(pname));
-                                    }
-                                    // insert-after: in case of image
-                                } else if (pname.indexOf("xupdate:insert-after") > 0
-                                        && pname.endsWith(">.x")) {
-                                    xupdateModifications = insertAfter(pname.substring(0, pname
-                                            .length() - 2));
-                                } else if (pname.indexOf("xupdate:remove") > 0
-                                        && pname.endsWith("/>.x")) {
-                                    xupdateModifications = remove(pname.substring(0,
-                                            pname.length() - 2));
-                                } else if (pname.endsWith(">.y")) {
-                                    getLogger().debug("Don't handle this: " + pname);
-                                } else {
-                                    getLogger().debug("Don't handle this either: " + pname);
-                                }
-
-                                // Get hidden namespaces
-                                String namespaces = request.getParameter("namespaces");
-
-                                // Add XML declaration
-                                // NOTE: select/option is generating parameter
-                                // which should be considered as null
-                                if (xupdateModifications != null) {
-                                    xupdateModifications = "<?xml version=\"1.0\"?>"
-                                            + addHiddenNamespaces(namespaces, xupdateModifications);
-                                }
-
-                                // now run the assembled xupdate query
-                                if (xupdateModifications != null) {
-                                    getLogger().info(
-                                            "Execute XUpdate Modifications: "
-                                                    + xupdateModifications);
-                                    xq.setQString(xupdateModifications);
-                                    xq.execute(document);
-                                } else {
-                                    getLogger()
-                                            .debug(
-                                                    "Parameter did not match any xupdate command: "
-                                                            + pname);
-                                }
-                            }
-                        }
-                    }
+        Document document = null;
+        DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
+        parserFactory.setValidating(false);
+        parserFactory.setNamespaceAware(true);
+        parserFactory.setIgnoringElementContentWhitespace(true);
+        DocumentBuilder builder = parserFactory.newDocumentBuilder();
+
+        InputSource xmlInputSource = SourceUtil.getInputSource(xmlSource);
+        document = builder.parse(xmlInputSource);
+        System.setProperty("org.xmldb.common.xml.queries.XPathQueryFactory",
+                "org.xmldb.common.xml.queries.xalan2.XPathQueryFactoryImpl");
+
+        XPathQuery xpath = XPathQueryFactory.newInstance().newXPathQuery();
+        XUpdateQuery xq = new XUpdateQueryImpl();
+
+        String editSelect = null;
+        Enumeration params = request.getParameterNames();
+        editSelect = processElements(request, document, xpath, xq, editSelect, params);
+
+        // validate against relax ng after the updates
+        if (!schemaSource.exists()) {
+            throw new ProcessingException("Schema [" + schemaSource.getURI()
+                    + "] does not exist.");
+        }
 
-                    //  Uncomment this for debugging
-                    /*
-                     * java.io.StringWriter writer = new java.io.StringWriter();
-                     * org.apache.xml.serialize.OutputFormat OutFormat = new
-                     * org.apache.xml.serialize.OutputFormat("xml", "UTF-8", true);
-                     * org.apache.xml.serialize.XMLSerializer serializer = new
-                     * org.apache.xml.serialize.XMLSerializer(writer, OutFormat);
-                     * serializer.asDOMSerializer().serialize((Document) document);
-                     * log.error(".act(): XUpdate Result: \n"+writer.toString());
-                     */
-
-                    // validate against relax ng after the updates
-                    if (!schemaSource.exists()) {
-                        throw new ProcessingException("Schema [" + schemaSource.getURI()
-                                + "] does not exist.");
-                    }
+        Source validationSource = null;
+        Source unnumberTagsSource = null;
 
-                    Source validationSource = null;
-                    Source unnumberTagsSource = null;
+        try {
+            String validationUri = modifiableXmlSource.getURI() + ".validate";
+            validationSource = resolver.resolveURI(validationUri);
+            checkModifiability(validationSource);
+
+            String unnumberTagsUri = modifiableXmlSource.getURI() + ".validate.unnumber";
+            unnumberTagsSource = resolver.resolveURI(unnumberTagsUri);
+            checkModifiability(unnumberTagsSource);
+
+            writeDocument(document, (ModifiableSource) validationSource);
+
+            String message = validateDocument(schemaSource, validationSource,
+                    (ModifiableSource) unnumberTagsSource, unnumberTagsXslSource);
+
+            if (message != null) {
+                getLogger().error("RELAX NG Validation failed: " + message);
+                HashMap hmap = new HashMap();
+                hmap.put("message", "RELAX NG Validation failed: " + message);
+                return hmap;
+            }
+        } finally {
+            if (validationSource != null) {
+                resolver.release(validationSource);
+            }
+            if (unnumberTagsSource != null) {
+                resolver.release(unnumberTagsSource);
+            }
+        }
 
-                    try {
-                        String validationUri = modifiableXmlSource.getURI() + ".validate";
-                        validationSource = resolver.resolveURI(validationUri);
-                        checkModifiability(validationSource);
-
-                        String unnumberTagsUri = modifiableXmlSource.getURI() + ".validate.unnumber";
-                        unnumberTagsSource = resolver.resolveURI(unnumberTagsUri);
-                        checkModifiability(unnumberTagsSource);
-
-                        writeDocument(document, (ModifiableSource) validationSource);
-
-                        String message = validateDocument(schemaSource, validationSource,
-                                (ModifiableSource) unnumberTagsSource, unnumberTagsXslSource);
-
-                        if (message != null) {
-                            getLogger().error("RELAX NG Validation failed: " + message);
-                            HashMap hmap = new HashMap();
-                            hmap.put("message", "RELAX NG Validation failed: " + message);
-                            return hmap;
+        Document renumberedDocument = renumberDocument(document, unnumberTagsXslSource,
+                numberTagsXslSource);
+        writeDocument(document, modifiableXmlSource);
+
+        // check to see if we save and exit
+        if (request.getParameter("save") != null) {
+            getLogger().info(".act(): Save");
+            return null;
+        }
+        /*
+         * We don't exit
+         */
+        HashMap hmap = new HashMap();
+        if (editSelect != null) {
+            hmap.put("editSelect", editSelect);
+        }
+        return hmap;
+    }
+
+    /**
+     * Process elements
+     * @param request
+     * @param document
+     * @param xpath
+     * @param xq
+     * @param editSelect
+     * @param params
+     * @return
+     * @throws Exception
+     */
+    private String processElements(Request request, Document document, XPathQuery xpath, XUpdateQuery xq, 
+            String editSelect, Enumeration params) throws Exception {
+        while (params.hasMoreElements()) {
+            String pname = (String) params.nextElement();
+            getLogger().debug(
+                    "Parameter: " + pname + " (" + request.getParameter(pname) + ")");
+
+            // Extract the xpath to edit
+            if (editSelect == null && pname.indexOf("edit[") >= 0
+                    && pname.endsWith("].x")) {
+                editSelect = pname.substring(5, pname.length() - 3);
+                getLogger().debug("Edit: " + editSelect);
+            }
+
+            // Make sure we are dealing with an xupdate statement,
+            // else skip
+            if (pname.indexOf("<xupdate:") == 0) {
+                String select = pname.substring(pname.indexOf("select") + 8);
+                select = select.substring(0, select.indexOf("\""));
+                getLogger().debug(".act() Select Node: " + select);
+
+                // Check if node exists
+                xpath.setQString(select);
+                XObject result = xpath.execute(document);
+                NodeList selectionNodeList = result.nodeset();
+                if (selectionNodeList.getLength() == 0) {
+                    getLogger().debug(
+                            ".act(): Node does not exist (might have been deleted during update): "
+                                    + select);
+                } else {
+                    String xupdateModifications = null;
+                    // now check for the different xupdate
+                    // statements, and handle appropriately
+                    if (pname.indexOf("xupdate:update-parent") > 0) {
+                        getLogger().debug("UPDATE PARENT Node: " + pname);
+                        // CDATA updates need to be handled
+                        // seperately
+                        if (pname.indexOf("<![CDATA[") > 0) {
+                            xupdateModifications = updateCDATA(request, pname, true);
+                        } else {
+                            xupdateModifications = update(request, pname, select,
+                                    selectionNodeList, true);
+                        }
+                    } else if (pname.indexOf("xupdate:update") > 0) {
+                        getLogger().debug("UPDATE Node: " + pname);
+                        // CDATA updates need to be handled
+                        // seperately
+                        if (pname.indexOf("<![CDATA[") > 0) {
+                            xupdateModifications = updateCDATA(request, pname, false);
+                        } else {
+                            xupdateModifications = update(request, pname, select,
+                                    selectionNodeList, false);
                         }
-                    } finally {
-                        if (validationSource != null) {
-                            resolver.release(validationSource);
+                    } else if (pname.indexOf("xupdate:append") > 0
+                            && pname.endsWith(">.x")) {
+                        xupdateModifications = append(pname.substring(0,
+                                pname.length() - 2));
+                        // insert-before: in case of select/option
+                    } else if (pname.indexOf("xupdate:insert-before") > 0
+                            && pname.endsWith("/>")) {
+                        if (!request.getParameter(pname).equals("null")) {
+                            xupdateModifications = insertBefore(request
+                                    .getParameter(pname));
                         }
-                        if (unnumberTagsSource != null) {
-                            resolver.release(unnumberTagsSource);
+                        // insert-before: in case of image
+                    } else if (pname.indexOf("xupdate:insert-before") > 0
+                            && pname.endsWith(">.x")) {
+                        xupdateModifications = insertBefore(pname.substring(0, pname
+                                .length() - 2));
+                        // insert-after: in case of select/option
+                    } else if (pname.indexOf("xupdate:insert-after") > 0
+                            && pname.endsWith("/>")) {
+                        if (!request.getParameter(pname).equals("null")) {
+                            xupdateModifications = insertAfter(request
+                                    .getParameter(pname));
                         }
+                        // insert-after: in case of image
+                    } else if (pname.indexOf("xupdate:insert-after") > 0
+                            && pname.endsWith(">.x")) {
+                        xupdateModifications = insertAfter(pname.substring(0, pname
+                                .length() - 2));
+                    } else if (pname.indexOf("xupdate:remove") > 0
+                            && pname.endsWith("/>.x")) {
+                        xupdateModifications = remove(pname.substring(0,
+                                pname.length() - 2));
+                    } else if (pname.endsWith(">.y")) {
+                        getLogger().debug("Don't handle this: " + pname);
+                    } else {
+                        getLogger().debug("Don't handle this either: " + pname);
                     }
 
-                    Document renumberedDocument = renumberDocument(document, unnumberTagsXslSource,
-                            numberTagsXslSource);
-                    writeDocument(document, modifiableXmlSource);
-
-                    // check to see if we save and exit
-                    if (request.getParameter("save") != null) {
-                        getLogger().info(".act(): Save");
-                        return null;
-                    } else {
-                        /*
-                         * We don't exit
-                         */
-                        HashMap hmap = new HashMap();
-                        if (editSelect != null) {
-                            hmap.put("editSelect", editSelect);
-                        }
-                        return hmap;
+                    // Get hidden namespaces
+                    String namespaces = request.getParameter("namespaces");
+
+                    // Add XML declaration
+                    // NOTE: select/option is generating parameter
+                    // which should be considered as null
+                    if (xupdateModifications != null) {
+                        xupdateModifications = "<?xml version=\"1.0\"?>"
+                                + addHiddenNamespaces(namespaces, xupdateModifications);
                     }
-                } catch (NullPointerException e) {
-                    getLogger().error("NullPointerException", e);
-                    HashMap hmap = new HashMap();
-                    hmap.put("message", "NullPointerException");
-                    return hmap;
-                } catch (Exception e) {
-                    getLogger().error("Exception: " + e.getMessage(), e);
-                    HashMap hmap = new HashMap();
-                    if (e.getMessage() != null) {
-                        hmap.put("message", e.getMessage());
+
+                    // now run the assembled xupdate query
+                    if (xupdateModifications != null) {
+                        getLogger().info(
+                                "Execute XUpdate Modifications: "
+                                        + xupdateModifications);
+                        xq.setQString(xupdateModifications);
+                        xq.execute(document);
                     } else {
-                        hmap.put("message", "No message (" + e.getClass().getName() + ")");
+                        getLogger()
+                                .debug(
+                                        "Parameter did not match any xupdate command: "
+                                                + pname);
                     }
-                    return hmap;
                 }
             }
-
-        } finally {
-            if (xmlSource != null) {
-                resolver.release(xmlSource);
-            }
-            if (schemaSource != null) {
-                resolver.release(schemaSource);
-            }
-            if (unnumberTagsXslSource != null) {
-                resolver.release(unnumberTagsXslSource);
-            }
-            if (numberTagsXslSource != null) {
-                resolver.release(numberTagsXslSource);
-            }
         }
-
+        return editSelect;
     }
 
     /**
@@ -413,7 +491,7 @@
 
     /**
      * Checks if a source is modifiable.
-     * @param validationSource The source.
+     * @param source The source.
      * @throws ProcessingException if the source is not modifiable.
      */
     protected void checkModifiability(Source source) throws ProcessingException {
@@ -424,8 +502,8 @@
 
     /**
      * Get attributes from original node
-     * 
      * @param node Original node
+     * @return An XupdateAttributes class holding the attributes
      */
     private XUpdateAttributes getAttributes(Node node) {
 
@@ -463,8 +541,9 @@
 
     /**
      * Get attributes from actual update
-     * 
      * @param update The actual update
+     * @param tagID The tag id to get the updates for
+     * @return An XupdateAttributes class holding the attributes
      */
     private XUpdateAttributes getAttributes(String update, String tagID) {
         getLogger().debug(update);
@@ -492,9 +571,13 @@
 
     /**
      * xupdate:update
-     * 
+     * @param request The request
+     * @param pname Name of the parent element
+     * @param select The attribute to update
+     * @param selectionNodeList The nodes to update
      * @param parent If true then parent element is part of update and attributes need to be updated
      *            resp. added or deleted
+     * @return the Xupdate statement
      */
     private String update(Request request, String pname, String select, NodeList selectionNodeList,
             boolean parent) {
@@ -513,53 +596,55 @@
              * Workaround we insert-after the new node, remove the original node and replace the
              * temporary tagID by the original tagID.
              */
-        } else {
-            getLogger().debug("Update element: " + select);
+        } 
 
-            String namespace = nodeToCopy.getNamespaceURI();
-            String namespaceAttribute = "";
-            if (namespace != null) {
-                namespaceAttribute = " namespace=\"" + namespace + "\"";
-            }
-            // NOTE: getAttributes adds the attribute tagID with value "temp",
-            // which will be replaced further down
-            XUpdateAttributes xa = getAttributes(nodeToCopy);
-            String xupdateInsertAfter = null;
-            if (parent) {
-                xa = getAttributes(request.getParameter(pname), xa.tagID);
-                xupdateInsertAfter = "<xupdate:insert-after select=\"" + select
-                        + " \"><xupdate:element name=\""
-                        + new XPath(select).getNameWithoutPredicates() + "\"" + namespaceAttribute
-                        + ">" + xa.xupdateAttrExpr + removeParent(request.getParameter(pname))
-                        + "</xupdate:element></xupdate:insert-after>";
-            } else {
-                xupdateInsertAfter = "<xupdate:insert-after select=\"" + select
-                        + " \"><xupdate:element name=\""
-                        + new XPath(select).getNameWithoutPredicates() + "\"" + namespaceAttribute
-                        + ">" + xa.xupdateAttrExpr + request.getParameter(pname)
-                        + "</xupdate:element></xupdate:insert-after>";
-            }
-            getLogger().debug(".update(): Update Node (insert-after): " + xupdateInsertAfter);
-
-            String xupdateRemove = "<xupdate:remove select=\"" + select + " \"/>";
-            getLogger().debug(".update(): Update Node (remove): " + xupdateRemove);
-
-            String xupdateUpdateAttribute = "<xupdate:update select=\""
-                    + new XPath(select).removePredicates(select) + "[@tagID='temp']/@tagID"
-                    + " \">" + xa.tagID + "</xupdate:update>";
-            getLogger().debug(
-                    ".update(): Update Node (update tagID attribute): " + xupdateUpdateAttribute);
+        getLogger().debug("Update element: " + select);
 
-            return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"
-                    + xupdateInsertAfter + xupdateRemove + xupdateUpdateAttribute
-                    + "</xupdate:modifications>";
+        String namespace = nodeToCopy.getNamespaceURI();
+        String namespaceAttribute = "";
+        if (namespace != null) {
+            namespaceAttribute = " namespace=\"" + namespace + "\"";
+        }
+        // NOTE: getAttributes adds the attribute tagID with value "temp",
+        // which will be replaced further down
+        XUpdateAttributes xa = getAttributes(nodeToCopy);
+        String xupdateInsertAfter = null;
+        if (parent) {
+            xa = getAttributes(request.getParameter(pname), xa.tagID);
+            xupdateInsertAfter = "<xupdate:insert-after select=\"" + select
+                    + " \"><xupdate:element name=\""
+                    + new XPath(select).getNameWithoutPredicates() + "\"" + namespaceAttribute
+                    + ">" + xa.xupdateAttrExpr + removeParent(request.getParameter(pname))
+                    + "</xupdate:element></xupdate:insert-after>";
+        } else {
+            xupdateInsertAfter = "<xupdate:insert-after select=\"" + select
+                    + " \"><xupdate:element name=\""
+                    + new XPath(select).getNameWithoutPredicates() + "\"" + namespaceAttribute
+                    + ">" + xa.xupdateAttrExpr + request.getParameter(pname)
+                    + "</xupdate:element></xupdate:insert-after>";
         }
+        getLogger().debug(".update(): Update Node (insert-after): " + xupdateInsertAfter);
+
+        String xupdateRemove = "<xupdate:remove select=\"" + select + " \"/>";
+        getLogger().debug(".update(): Update Node (remove): " + xupdateRemove);
+
+        String xupdateUpdateAttribute = "<xupdate:update select=\""
+                + new XPath(select).removePredicates(select) + "[@tagID='temp']/@tagID"
+                + " \">" + xa.tagID + "</xupdate:update>";
+        getLogger().debug(
+                ".update(): Update Node (update tagID attribute): " + xupdateUpdateAttribute);
+
+        return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"
+                + xupdateInsertAfter + xupdateRemove + xupdateUpdateAttribute
+                + "</xupdate:modifications>";
     }
 
     /**
      * xupdate:update CDATA
-     * 
+     * @param request The request
+     * @param pname The name of the parent element
      * @param parent if true then attributes of parent will also be updated
+     * @return The Xupdate expression
      */
     private String updateCDATA(Request request, String pname, boolean parent) {
         String xupdateUpdate = pname + request.getParameter(pname) + "]]></xupdate:update>";
@@ -569,6 +654,8 @@
 
     /**
      * xupdate:append
+     * @param pname The node to append to
+     * @return The Xupdate statement
      */
     private String append(String pname) {
         getLogger().debug(".append() APPEND Node: " + pname);
@@ -578,6 +665,8 @@
 
     /**
      * xupdate:insert-before
+     * @param pname The node to insert before
+     * @return The Xupdate statement
      */
     private String insertBefore(String pname) {
         getLogger().debug(".insertBefore() INSERT-BEFORE Node: " + pname);
@@ -587,6 +676,8 @@
 
     /**
      * xupdate:insert-after
+     * @param pname The node to insert after
+     * @return The Xupdate statement
      */
     private String insertAfter(String pname) {
         getLogger().debug(".insertAfter() INSERT-AFTER Node: " + pname);
@@ -596,6 +687,8 @@
 
     /**
      * xupdate:remove
+     * @param pname The node to remove
+     * @return The Xupdate statement
      */
     private String remove(String pname) {
         getLogger().debug(".remove() REMOVE Node: " + pname);
@@ -613,8 +706,8 @@
      */
     private String validateDocument(Source schema, Source xml, ModifiableSource unnumberXml,
             Source unnumberTagsXsl) {
-        try {
 
+        try {
             StreamSource xmlSource = new StreamSource(xml.getInputStream());
             StreamSource unnumberTagsXslSource = new StreamSource(unnumberTagsXsl.getInputStream());
             
@@ -641,14 +734,34 @@
             InputSource unnumberXmlInputSource = SourceUtil.getInputSource(unnumberXml);
 
             return RelaxNG.validate(schemaInputSource, unnumberXmlInputSource);
-        } catch (Exception e) {
+        } catch (final SourceNotFoundException e) {
+            getLogger().error("Validating failed:", e);
+            return e.getMessage();
+        } catch (final TransformerConfigurationException e) {
+            getLogger().error("Validating failed:", e);
+            return e.getMessage();
+        } catch (final ProcessingException e) {
+            getLogger().error("Validating failed:", e);
+            return e.getMessage();
+        } catch (final IOException e) {
+            getLogger().error("Validating failed:", e);
+            return e.getMessage();
+        } catch (final TransformerFactoryConfigurationError e) {
+            getLogger().error("Validating failed:", e);
+            return e.getMessage();
+        } catch (final TransformerException e) {
             getLogger().error("Validating failed:", e);
             return e.getMessage();
         }
+
     }
 
     /**
-     * Renumber document
+     * Renumber the tags within a document. Each tag gets a unique number used in Xupdate expressions.
+     * @param doc The document to renumber
+     * @param unnumberTagsXSL The XSL stylesheet to remove the tagID attribute
+     * @param numberTagsXSL The XSL stylesheet to add the tagID attribute
+     * @return The renumbered document
      */
     private Document renumberDocument(Document doc, Source unnumberTagsXSL, Source numberTagsXSL) {
 
@@ -672,7 +785,19 @@
             nt.transform(new DOMSource(unnumberedDocument), new DOMResult(renumberedDocument));
 
             return renumberedDocument;
-        } catch (Exception e) {
+        } catch (final SourceNotFoundException e) {
+            getLogger().error("" + e);
+        } catch (final TransformerConfigurationException e) {
+            getLogger().error("" + e);
+        } catch (final FactoryConfigurationError e) {
+            getLogger().error("" + e);
+        } catch (final ParserConfigurationException e) {
+            getLogger().error("" + e);
+        } catch (final TransformerFactoryConfigurationError e) {
+            getLogger().error("" + e);
+        } catch (final IOException e) {
+            getLogger().error("" + e);
+        } catch (final TransformerException e) {
             getLogger().error("" + e);
         }
 
@@ -681,6 +806,8 @@
 
     /**
      * Remove parent element
+     * @param xmlSnippet The XML snippet to remove the parent from
+     * @return The XML snippet with the parent removed
      */
     private String removeParent(String xmlSnippet) {
         String xmlSnippetWithoutParent = xmlSnippet;
@@ -694,7 +821,10 @@
     }
 
     /**
-     * Add namespaces to xupdate
+     * Add namespaces to xupdate statement
+     * @param namespaces The namespaces to add
+     * @param xupdateModifications The Xupdate statement to add namespaces to
+     * @return The Xupdate statement with the added namespaces
      */
     private String addHiddenNamespaces(String namespaces, String xupdateModifications) {
         getLogger().debug("Namespaces: " + namespaces);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/LanguageExistsAction.java Tue Feb  8 10:13:39 2005
@@ -57,6 +57,7 @@
      * 
      * @return an empty <code>Map</code> if there is a version of this document for the current
      *         language, null otherwiese
+     * @throws Exception if an error occurs
      * 
      * @exception DocumentDoesNotExistException if there is no document with the specified
      *                document-id.

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/OneFormEditorSaveAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/OneFormEditorSaveAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/OneFormEditorSaveAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/OneFormEditorSaveAction.java Tue Feb  8 10:13:39 2005
@@ -122,29 +122,48 @@
     }
 
     /**
-     * @param encoding
-     * @param content
-     * @param xmlSource
-     * @throws FileNotFoundException
-     * @throws UnsupportedEncodingException
-     * @throws IOException
+     * Save the XML file
+     * @param encoding The encoding
+     * @param content The content
+     * @param xmlSource The source
+     * @throws FileNotFoundException if the file was not found
+     * @throws UnsupportedEncodingException if the encoding is not supported
+     * @throws IOException if an IO error occurs
      */
     private void saveXMLFile(String encoding, String content, Source xmlSource)
             throws FileNotFoundException, UnsupportedEncodingException, IOException {
-        File xmlFile = org.apache.excalibur.source.SourceUtil.getFile(xmlSource);
-        File parentFile = new File(xmlFile.getParent());
-        if (!parentFile.exists()) {
-            parentFile.mkdirs();
-        }
+        FileOutputStream fileoutstream = null;
+        Writer writer = null;
+        
+        try {
+            File xmlFile = org.apache.excalibur.source.SourceUtil.getFile(xmlSource);
+            File parentFile = new File(xmlFile.getParent());
+            if (!parentFile.exists()) {
+                parentFile.mkdirs();
+            }
 
-        FileOutputStream fileoutstream = new FileOutputStream(xmlFile);
-        Writer writer = new OutputStreamWriter(fileoutstream, encoding);
-        writer.write(content, 0, content.length());
-        writer.close();
+            fileoutstream = new FileOutputStream(xmlFile);
+            writer = new OutputStreamWriter(fileoutstream, encoding);
+            writer.write(content, 0, content.length());
+        } catch (FileNotFoundException e) {
+            getLogger().error("File not found " +e.toString());
+        } catch (UnsupportedEncodingException e) {
+            getLogger().error("Encoding not supported " +e.toString());
+        } catch (IOException e) {
+            getLogger().error("IO error " +e.toString());
+        } finally {
+            // close all streams
+            if (writer != null)
+                writer.close();
+            if (fileoutstream != null)
+                fileoutstream.close();
+        }
     }
 
     /**
      * Remove redundant namespaces
+     * @param namespaces The namespaces to remove
+     * @return The namespace string without the removed namespaces
      */
     private String removeRedundantNamespaces(String namespaces) {
         String[] namespace = namespaces.split(" ");
@@ -164,6 +183,9 @@
 
     /**
      * Add namespaces
+     * @param namespaces The namespaces to add
+     * @param content The content to add them to
+     * @return The content with the added namespaces
      */
     private String addNamespaces(String namespaces, String content) {
         int i = content.indexOf(">");

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckinAction.java Tue Feb  8 10:13:39 2005
@@ -34,7 +34,6 @@
     /**
      * Checkin document
      * @return HashMap with checkin parameters
-     * 
      * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
      *      org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String,
      *      org.apache.avalon.framework.parameters.Parameters)

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutAction.java Tue Feb  8 10:13:39 2005
@@ -33,17 +33,7 @@
 public class ReservedCheckoutAction extends RevisionControllerAction {
 
     /**
-     * DOCUMENT ME!
-     * 
-     * @param redirector DOCUMENT ME!
-     * @param resolver DOCUMENT ME!
-     * @param objectModel DOCUMENT ME!
-     * @param src DOCUMENT ME!
-     * @param parameters DOCUMENT ME!
-     * 
-     * @return DOCUMENT ME!
-     * 
-     * @throws Exception DOCUMENT ME!
+     * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
      */
     public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
             Parameters parameters) throws Exception {

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutTestAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutTestAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutTestAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ReservedCheckoutTestAction.java Tue Feb  8 10:13:39 2005
@@ -37,7 +37,7 @@
 
 public class ReservedCheckoutTestAction extends RevisionControllerAction {
 
-    /** (non-Javadoc)
+    /**
 	 * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
 	 */
 	public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ResourceExistsAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ResourceExistsAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ResourceExistsAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/ResourceExistsAction.java Tue Feb  8 10:13:39 2005
@@ -47,7 +47,7 @@
  */
 public class ResourceExistsAction extends ServiceableAction implements ThreadSafe {
     /**
-     *
+     * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
      */
     public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source,
         Parameters parameters) throws Exception {

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java Tue Feb  8 10:13:39 2005
@@ -86,14 +86,14 @@
         String publicationPath = publication.getDirectory().getCanonicalPath();
         RCEnvironment rcEnvironment = RCEnvironment.getInstance(publication.getServletContext()
                 .getCanonicalPath());
-        rcmlDirectory = rcEnvironment.getRCMLDirectory();
-        rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
-        backupDirectory = rcEnvironment.getBackupDirectory();
-        backupDirectory = publicationPath + File.separator + backupDirectory;
+        this.rcmlDirectory = rcEnvironment.getRCMLDirectory();
+        this.rcmlDirectory = publicationPath + File.separator + this.rcmlDirectory;
+        this.backupDirectory = rcEnvironment.getBackupDirectory();
+        this.backupDirectory = publicationPath + File.separator + this.backupDirectory;
 
         // Initialize Revision Controller
-        rc = new RevisionController(rcmlDirectory, backupDirectory, publicationPath);
-        getLogger().debug("revision controller" + rc);
+        this.rc = new RevisionController(this.rcmlDirectory, this.backupDirectory, publicationPath);
+        getLogger().debug("revision controller" + this.rc);
 
         // /Initialize Revision Controller
         // Get session
@@ -134,55 +134,52 @@
 
             Document srcDoc = map.getFactory().get(document.getArea(), documentid, language);
             File newFile = srcDoc.getFile();
-            filename = newFile.getCanonicalPath();
+            this.filename = newFile.getCanonicalPath();
 
         } else {
-            filename = document.getFile().getCanonicalPath();
+            this.filename = document.getFile().getCanonicalPath();
         }
 
-        filename = filename.substring(publicationPath.length());
+        this.filename = this.filename.substring(publicationPath.length());
 
-        username = null;
+        this.username = null;
 
         if (identity != null) {
             User user = identity.getUser();
             if (user != null) {
-                username = user.getId();
+                this.username = user.getId();
             }
         } else {
             getLogger().error(".act(): No identity yet");
         }
 
-        getLogger().debug(".act(): Username: " + username);
+        getLogger().debug(".act(): Username: " + this.username);
 
         return null;
     }
 
     /**
      * Get the filename.
-     * 
      * @return the filename
      */
     protected String getFilename() {
-        return filename;
+        return this.filename;
     }
 
     /**
      * Get the revision controller.
-     * 
      * @return the revision controller
      */
     protected RevisionController getRc() {
-        return rc;
+        return this.rc;
     }
 
     /**
      * Get the user name.
-     * 
      * @return the user name
      */
     protected String getUsername() {
-        return username;
+        return this.username;
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RollbackAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RollbackAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RollbackAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/RollbackAction.java Tue Feb  8 10:13:39 2005
@@ -30,19 +30,22 @@
 import org.apache.cocoon.environment.SourceResolver;
 
 
+/**
+ * Action to roll back a document to a prior version
+ */
 public class RollbackAction extends RevisionControllerAction {
     /**
-     * DOCUMENT ME!
+     * This action rolls back a document to a prior version
      *
-     * @param redirector DOCUMENT ME!
-     * @param resolver DOCUMENT ME!
-     * @param objectModel DOCUMENT ME!
-     * @param src DOCUMENT ME!
-     * @param parameters DOCUMENT ME!
+     * @param redirector The redirector
+     * @param resolver The resolver
+     * @param objectModel The object model
+     * @param src The source
+     * @param parameters The parameters
      *
-     * @return DOCUMENT ME!
+     * @return null on failure, the location of the redirect on success
      *
-     * @throws Exception DOCUMENT ME!
+     * @throws Exception if an error occurs
      */
     public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
         Parameters parameters) throws Exception {
@@ -55,7 +58,6 @@
 
         if (request == null) {
             getLogger().error("No request object");
-
             return null;
         }
 
@@ -69,11 +71,9 @@
             newtime = getRc().rollback(getFilename(), getUsername(), true, new Long(rollbackTime).longValue());
         } catch (FileNotFoundException e) {
             getLogger().error("Unable to roll back!" + e);
-
             return null;
         } catch (Exception e) {
             getLogger().error("Unable to roll back!" + e);
-
             return null;
         }
 

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/TaskAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/TaskAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/TaskAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/TaskAction.java Tue Feb  8 10:13:39 2005
@@ -38,17 +38,7 @@
 public class TaskAction extends AbstractAction {
     
     /**
-     * DOCUMENT ME!
-     *
-     * @param redirector DOCUMENT ME!
-     * @param sourceResolver DOCUMENT ME!
-     * @param objectModel DOCUMENT ME!
-     * @param str DOCUMENT ME!
-     * @param parameters DOCUMENT ME!
-     *
-     * @return DOCUMENT ME!
-     *
-     * @throws java.lang.Exception DOCUMENT ME!
+     * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
      */
     public java.util.Map act(
         Redirector redirector,

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/URIParametrizerAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/URIParametrizerAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/URIParametrizerAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/URIParametrizerAction.java Tue Feb  8 10:13:39 2005
@@ -54,11 +54,11 @@
         URIParameterizer parameterizer = null;
         Map map = null;
         try {
-            parameterizer = (URIParameterizer) manager.lookup(URIParameterizer.ROLE);
+            parameterizer = (URIParameterizer) this.manager.lookup(URIParameterizer.ROLE);
             map = parameterizer.parameterize(uri, src, parameters);
         } finally {
             if (parameterizer != null) {
-                manager.release(parameterizer);
+                this.manager.release(parameterizer);
             }
         }
 

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java Tue Feb  8 10:13:39 2005
@@ -58,24 +58,40 @@
  * upload. An upload consists of a file upload plus optionally a file creation for the meta data of
  * the asset.
  * 
- * Also see org.apache.lenya.cms.authoring.UploadHelper
+ * Also @see org.apache.lenya.cms.authoring.UploadHelper
  */
 public class UploadAction extends AbstractConfigurableAction {
 
     private Document document;
     private PageEnvelope pageEnvelope;
 
+    /**
+     * <code>UPLOADASSET_PARAM_NAME</code> Asset data parameter
+     */
     public static final String UPLOADASSET_PARAM_NAME = "properties.asset.data";
+    /**
+     * <code>UPLOADASSET_PARAM_PREFIX</code> Prefix for all parameters
+     */
     public static final String UPLOADASSET_PARAM_PREFIX = "properties.asset.";
-
+    /**
+     * <code>UPLOADASSET_RETURN_FILESIZE</code> The file size
+     */
     public static final String UPLOADASSET_RETURN_FILESIZE = "file-size";
+    /**
+     * <code>UPLOADASSET_RETURN_MIMETYPE</code> The mime type
+     */
     public static final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
-
+    /**
+     * <code>CONTENT_PREFIX</code> The content prefix
+     */
     public static final String CONTENT_PREFIX = "content";
-
+    /**
+     * <code>FILE_NAME_REGEXP</code> The regular expression for valid asset names
+     */
     public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_.]+";
-
-    // optional parameters for meta data according to dublin core
+    /**
+     * <code>DUBLIN_CORE_PARAMETERS</code> optional parameters for meta data according to dublin core
+     */
     public static final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject",
             "description", "publisher", "contributor", "date", "type", "format", "identifier",
             "source", "language", "relation", "coverage", "rights" };
@@ -103,8 +119,8 @@
         PublicationFactory factory = PublicationFactory.getInstance(getLogger());
         Publication pub = factory.getPublication(objectModel);
         DocumentIdentityMap map = new DocumentIdentityMap(pub);
-        pageEnvelope = PageEnvelopeFactory.getInstance().getPageEnvelope(map, objectModel);
-        document = pageEnvelope.getDocument();
+        this.pageEnvelope = PageEnvelopeFactory.getInstance().getPageEnvelope(map, objectModel);
+        this.document = this.pageEnvelope.getDocument();
 
         File assetFile;
 
@@ -142,7 +158,7 @@
         dublinCoreParams.put("extent", Integer.toString(fileSize));
 
         if (uploadType.equals("asset")) {
-            ResourcesManager resourcesMgr = new DefaultResourcesManager(document);
+            ResourcesManager resourcesMgr = new DefaultResourcesManager(this.document);
             assetFile = new File(resourcesMgr.getPath(), fileName);
 
             if (!resourcesMgr.getPath().exists()) {
@@ -157,7 +173,7 @@
         }
         // must be a content upload then
         else {
-            assetFile = new File(document.getFile().getParent(), fileName);
+            assetFile = new File(this.document.getFile().getParent(), fileName);
             getLogger().debug("assetFile: " + assetFile);
         }
 
@@ -216,7 +232,10 @@
      */
     protected Map getDublinCoreParameters(Request request) {
         HashMap dublinCoreParams = new HashMap();
-
+		String		key;
+		String		value;
+		Map.Entry	entry;
+		
         for (int i = 0; i < DUBLIN_CORE_PARAMETERS.length; i++) {
             String paramName = DUBLIN_CORE_PARAMETERS[i];
             String paramValue = request.getParameter(UPLOADASSET_PARAM_PREFIX + paramName);
@@ -228,10 +247,12 @@
             dublinCoreParams.put(paramName, paramValue);
         }
         
-        Iterator iter = dublinCoreParams.keySet().iterator();
+        Iterator iter = dublinCoreParams.entrySet().iterator();
         while (iter.hasNext()) {
-            String paramName = (String) iter.next();
-            getLogger().debug(paramName + ": " + dublinCoreParams.get(paramName));
+			entry 	= (Map.Entry)iter.next();
+			key 	= (String)entry.getKey();
+			value 	= (String)entry.getValue();
+            getLogger().debug(key + ": " + value);
         }
         
         return dublinCoreParams;
@@ -250,6 +271,9 @@
     protected void createMetaData(File metaDataFile, Map dublinCoreParams)
             throws TransformerConfigurationException, TransformerException, IOException,
             ParserConfigurationException {
+        Map.Entry entry;
+		String		key;
+		String		value;
 
         assert (metaDataFile.getParentFile().exists());
 
@@ -258,12 +282,13 @@
 
         Element root = helper.getDocument().getDocumentElement();
 
-        Iterator iter = dublinCoreParams.keySet().iterator();
+        Iterator iter = dublinCoreParams.entrySet().iterator();
 
         while (iter.hasNext()) {
-            String tagName = (String) iter.next();
-            String tagValue = (String) dublinCoreParams.get(tagName);
-            root.appendChild(helper.createElement(tagName, tagValue));
+			entry 	= (Map.Entry)iter.next();
+			key 	= (String)entry.getKey();
+			value 	= (String)entry.getValue();
+            root.appendChild(helper.createElement(key, value));
         }
 
         DocumentHelper.writeDocument(helper.getDocument(), metaDataFile);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/WorkflowInvokerAction.java Tue Feb  8 10:13:39 2005
@@ -45,9 +45,21 @@
  */
 public class WorkflowInvokerAction extends ServiceableAction {
 
+    /**
+     * <code>AREA</code> The area
+     */
     public static final String AREA = "area";
+    /**
+     * <code>DOCUMENT_ID</code> The document id
+     */
     public static final String DOCUMENT_ID = "document-id";
+    /**
+     * <code>LANGUAGE</code> The language
+     */
     public static final String LANGUAGE = "language";
+    /**
+     * <code>EVENT</code> The event
+     */
     public static final String EVENT = "event";
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org