You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/01/11 19:24:32 UTC

svn commit: r495317 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ modules-core/linking/java/src/org/apache/lenya/cms/linking/ modules/bxe/resources/javascrip...

Author: andreas
Date: Thu Jan 11 10:24:31 2007
New Revision: 495317

URL: http://svn.apache.org/viewvc?view=rev&rev=495317
Log:
Use uuid-based links for images

Added:
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java
Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java
    lenya/trunk/src/modules/bxe/resources/javascript/insertAsset.js
    lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java
    lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java
    lenya/trunk/src/modules/webdav/module.xml
    lenya/trunk/src/modules/xhtml/config/cocoon-xconf/resource-type-xhtml.xconf
    lenya/trunk/src/modules/xhtml/menus.xmap
    lenya/trunk/src/modules/xhtml/sitemap.xmap
    lenya/trunk/src/modules/xhtml/xslt/helper-object.xsl
    lenya/trunk/src/pubs/default/modules/homepage/config/cocoon-xconf/resource-type-homepage.xconf
    lenya/trunk/src/pubs/default/sitemap.xmap

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java Thu Jan 11 10:24:31 2007
@@ -235,8 +235,15 @@
      */
     public String getExtension() {
         if (extension == null) {
-            getLogger().info("Default extension will be used: " + defaultExtension);
-            return defaultExtension;
+            String sourceExtension = getSourceExtension();
+            if (sourceExtension.equals("xml") || sourceExtension.equals("")) {
+                getLogger().info("Default extension will be used: " + defaultExtension);
+                return defaultExtension;
+            }
+            else {
+                return sourceExtension;
+            }
+            
         }
         return this.extension;
     }

Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/LinkRewritingTransformer.java Thu Jan 11 10:24:31 2007
@@ -18,6 +18,7 @@
 package org.apache.lenya.cms.cocoon.transformation;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Map;
 
 import org.apache.avalon.framework.activity.Disposable;
@@ -80,7 +81,7 @@
     protected static final String BROKEN_ATTRIB = "class";
     protected static final String BROKEN_VALUE = "brokenlink";
 
-    private boolean ignoreAElement = false;
+    private boolean ignoreLinkElement = false;
     private ServiceSelector serviceSelector;
     private PolicyManager policyManager;
     private AccessControllerResolver acResolver;
@@ -154,13 +155,11 @@
         return this.currentDocument;
     }
 
-    /**
-     * The local name of the HTML <a> href attribute.
-     */
-    public static final String ATTRIBUTE_HREF = "href";
-
     private String indent = "";
 
+    protected String[] elementNames = { "a", "object", "img" };
+    protected String[] attributeNames = { "href", "src", "data" };
+
     /**
      * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
      *      java.lang.String, java.lang.String, org.xml.sax.Attributes)
@@ -170,73 +169,75 @@
 
         if (getLogger().isDebugEnabled()) {
             getLogger().debug(
-                    this.indent + "<" + qname + "> (ignoreAElement = " + this.ignoreAElement + ")");
+                    this.indent + "<" + qname + "> (ignoreAElement = " + this.ignoreLinkElement
+                            + ")");
             this.indent += "  ";
         }
 
         AttributesImpl newAttrs = null;
-        if (lookingAtAElement(name)) {
+        if (lookingAtLinkElement(name)) {
 
-            this.ignoreAElement = false;
+            this.ignoreLinkElement = false;
 
-            String href = attrs.getValue(ATTRIBUTE_HREF);
-            if (href != null) {
+            for (int i = 0; i < attributeNames.length; i++) {
+                String linkUrl = attrs.getValue(attributeNames[i]);
+                if (linkUrl != null) {
+                    try {
+                        newAttrs = new AttributesImpl(attrs);
 
-                Document doc = getCurrentDocument();
-
-                try {
-                    newAttrs = new AttributesImpl(attrs);
-
-                    if (getLogger().isDebugEnabled()) {
-                        getLogger().debug(this.indent + "href URL: [" + href + "]");
-                    }
+                        if (getLogger().isDebugEnabled()) {
+                            getLogger().debug(this.indent + "link URL: [" + linkUrl + "]");
+                        }
 
-                    if (href.startsWith("lenya-document:")) {
+                        if (linkUrl.startsWith("lenya-document:")) {
+                            Document doc = getCurrentDocument();
 
-                        String anchor = null;
-                        String url = null;
+                            String anchor = null;
+                            String url = null;
 
-                        int anchorIndex = href.indexOf("#");
-                        if (anchorIndex > -1) {
-                            url = href.substring(0, anchorIndex);
-                            anchor = href.substring(anchorIndex + 1);
-                        } else {
-                            url = href;
-                        }
+                            int anchorIndex = linkUrl.indexOf("#");
+                            if (anchorIndex > -1) {
+                                url = linkUrl.substring(0, anchorIndex);
+                                anchor = linkUrl.substring(anchorIndex + 1);
+                            } else {
+                                url = linkUrl;
+                            }
 
-                        String[] linkUriAndQuery = url.split("\\?");
-                        String linkUri = linkUriAndQuery[0];
-                        String queryString = null;
-                        if (linkUriAndQuery.length > 1) {
-                            queryString = linkUriAndQuery[1];
-                        }
-                        LinkTarget target = this.linkResolver.resolve(doc, linkUri);
-                        if (target.exists()) {
-                            Document targetDocument = target.getDocument();
-                            String extension = targetDocument.getExtension();
-                            if (extension.length() > 0) {
-                                extension = "." + extension;
+                            String[] linkUriAndQuery = url.split("\\?");
+                            String linkUri = linkUriAndQuery[0];
+                            String queryString = null;
+                            if (linkUriAndQuery.length > 1) {
+                                queryString = linkUriAndQuery[1];
+                            }
+                            LinkTarget target = this.linkResolver.resolve(doc, linkUri);
+                            if (target.exists()) {
+                                Document targetDocument = target.getDocument();
+                                String extension = targetDocument.getExtension();
+                                if (extension.length() > 0) {
+                                    extension = "." + extension;
+                                }
+                                rewriteLink(newAttrs, attributeNames[i], targetDocument, anchor,
+                                        queryString, extension);
+                            } else if (doc.getArea().equals(Publication.AUTHORING_AREA)) {
+                                markBrokenLink(newAttrs, attributeNames[i], linkUrl);
+                            } else {
+                                this.ignoreLinkElement = true;
                             }
-                            rewriteLink(newAttrs, targetDocument, anchor, queryString, extension);
-                        } else if (doc.getArea().equals(Publication.AUTHORING_AREA)) {
-                            markBrokenLink(newAttrs, href);
-                        } else {
-                            this.ignoreAElement = true;
                         }
+
+                    } catch (final Exception e) {
+                        getLogger().error("startElement failed: ", e);
+                        throw new SAXException(e);
                     }
-                } catch (final Exception e) {
-                    getLogger().error("startElement failed: ", e);
-                    throw new SAXException(e);
                 }
             }
-
         }
 
         if (getLogger().isDebugEnabled()) {
-            getLogger().debug(this.indent + "ignoreAElement: " + this.ignoreAElement);
+            getLogger().debug(this.indent + "ignoreAElement: " + this.ignoreLinkElement);
         }
 
-        if (!(lookingAtAElement(name) && this.ignoreAElement)) {
+        if (!(lookingAtLinkElement(name) && this.ignoreLinkElement)) {
             if (newAttrs != null) {
                 attrs = newAttrs;
             }
@@ -252,18 +253,19 @@
      * attribute.
      * 
      * @param newAttrs The new attributes.
-     * @param brokenHref The broken link URI.
+     * @param attrName The attribute name.
+     * @param brokenUrl The broken link URI.
      * @throws AccessControlException when something went wrong.
      */
-    protected void markBrokenLink(AttributesImpl newAttrs, String brokenHref)
+    protected void markBrokenLink(AttributesImpl newAttrs, String attrName, String brokenUrl)
             throws AccessControlException {
         if (newAttrs.getIndex(BROKEN_ATTRIB) > -1)
             newAttrs.removeAttribute(newAttrs.getIndex(BROKEN_ATTRIB));
         if (newAttrs.getIndex("title") > -1)
             newAttrs.removeAttribute(newAttrs.getIndex("title"));
-        if (newAttrs.getIndex("href") > -1)
-            newAttrs.setAttribute(newAttrs.getIndex("href"), "", "href", "href", "CDATA", "");
-        String warning = "Broken Link: " + brokenHref;
+        if (newAttrs.getIndex(attrName) > -1)
+            newAttrs.setAttribute(newAttrs.getIndex(attrName), "", attrName, attrName, "CDATA", "");
+        String warning = "Broken Link: " + brokenUrl;
         newAttrs.addAttribute("", "title", "title", "CDATA", warning);
         newAttrs.addAttribute("", BROKEN_ATTRIB, BROKEN_ATTRIB, "CDATA", BROKEN_VALUE);
     }
@@ -272,14 +274,16 @@
      * Rewrites a link.
      * 
      * @param newAttrs The new attributes.
+     * @param attributeName The name of the attribute to rewrite.
      * @param targetDocument The target document.
      * @param anchor The anchor (the string after the # character in the URL).
      * @param queryString The query string without question mark.
      * @param extension The extension to use.
      * @throws AccessControlException when something went wrong.
      */
-    protected void rewriteLink(AttributesImpl newAttrs, Document targetDocument, String anchor,
-            String queryString, String extension) throws AccessControlException {
+    protected void rewriteLink(AttributesImpl newAttrs, String attributeName,
+            Document targetDocument, String anchor, String queryString, String extension)
+            throws AccessControlException {
 
         String webappUrl = targetDocument.getCanonicalWebappURL();
         Policy policy = this.policyManager.getPolicy(this.accreditableManager, webappUrl);
@@ -313,19 +317,20 @@
             getLogger().debug(this.indent + "Rewriting URL to: [" + rewrittenURL + "]");
         }
 
-        setHrefAttribute(newAttrs, rewrittenURL);
+        setAttribute(newAttrs, attributeName, rewrittenURL);
     }
 
     /**
      * Sets the value of the href attribute.
      * 
      * @param attr The attributes.
+     * @param name The attribute name.
      * @param value The value.
      * @throws IllegalArgumentException if the href attribute is not contained
      *         in this attributes.
      */
-    protected void setHrefAttribute(AttributesImpl attr, String value) {
-        int position = attr.getIndex(ATTRIBUTE_HREF);
+    protected void setAttribute(AttributesImpl attr, String name, String value) {
+        int position = attr.getIndex(name);
         if (position == -1) {
             throw new IllegalArgumentException("The href attribute is not available!");
         }
@@ -341,8 +346,8 @@
             this.indent = this.indent.substring(2);
             getLogger().debug(this.indent + "</" + qname + ">");
         }
-        if (lookingAtAElement(name) && this.ignoreAElement) {
-            this.ignoreAElement = false;
+        if (lookingAtLinkElement(name) && this.ignoreLinkElement) {
+            this.ignoreLinkElement = false;
         } else {
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug(this.indent + "</" + qname + "> sent");
@@ -351,8 +356,8 @@
         }
     }
 
-    private boolean lookingAtAElement(String name) {
-        return name.equals("a");
+    private boolean lookingAtLinkElement(String name) {
+        return Arrays.asList(this.elementNames).contains(name);
     }
 
     /**
@@ -377,6 +382,6 @@
      * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
      */
     public void recycle() {
-        this.ignoreAElement = false;
+        this.ignoreLinkElement = false;
     }
 }

Added: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java?view=auto&rev=495317
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java (added)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java Thu Jan 11 10:24:31 2007
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.linking;
+
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.xpath.XPathAPI;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Utility class to convert <code>lenya-document:</code> links from and to URL links.
+ */
+public class LinkConverter extends AbstractLogEnabled {
+    
+    private ServiceManager manager;
+
+    /**
+     * Creates a link converter.
+     * @param manager The service manager.
+     * @param logger The logger.
+     */
+    public LinkConverter(ServiceManager manager, Logger logger) {
+        ContainerUtil.enableLogging(this, logger);
+        this.manager = manager;
+    }
+    
+    /**
+     * Converts all URL-based links to UUID-based links.
+     * @param doc The document to convert.
+     */
+    public void convertUrlsToUuids(Document doc) {
+        convertUrlsToUuids(doc.getPublication(), doc);
+    }
+
+    /**
+     * Converts all URL-based links to UUID-based links. The link URLs can
+     * originate from a different publication.
+     * @param srcPub The publication where the content comes from.
+     * @param examinedDocument The document in the target publication.
+     */
+    public void convertUrlsToUuids(Publication srcPub, Document examinedDocument) {
+        boolean linksRewritten = false;
+        LinkResolver linkResolver = null;
+        try {
+            ResourceType type = examinedDocument.getResourceType();
+            String[] xPaths = type.getLinkAttributeXPaths();
+
+            if (xPaths.length == 0) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug(
+                            "Convert links: No XPaths for resource type [" + type.getName() + "]");
+                }
+            } else {
+                linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
+                DocumentFactory factory = examinedDocument.getFactory();
+
+                org.w3c.dom.Document xmlDocument = SourceUtil.readDOM(examinedDocument
+                        .getSourceURI(), this.manager);
+
+                for (int xPathIndex = 0; xPathIndex < xPaths.length; xPathIndex++) {
+                    if (getLogger().isDebugEnabled()) {
+                        getLogger()
+                                .debug("Convert links: Check XPath [" + xPaths[xPathIndex] + "]");
+                    }
+                    NodeList nodes = XPathAPI.selectNodeList(xmlDocument, xPaths[xPathIndex]);
+                    for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
+                        Node node = nodes.item(nodeIndex);
+                        if (node.getNodeType() != Node.ATTRIBUTE_NODE) {
+                            throw new RuntimeException("The XPath [" + xPaths[xPathIndex]
+                                    + "] may only match attribute nodes!");
+                        }
+                        Attr attribute = (Attr) node;
+                        final String url = attribute.getValue();
+                        if (getLogger().isDebugEnabled()) {
+                            getLogger().debug("Convert links: Check URL [" + url + "]");
+                        }
+
+                        if (url.startsWith("/" + srcPub.getId() + "/" + examinedDocument.getArea()
+                                + "/")) {
+                            String targetPubId = examinedDocument.getPublication().getId();
+                            final String webappUrl = "/" + targetPubId
+                                    + url.substring(("/" + srcPub.getId()).length());
+                            if (factory.isDocument(webappUrl)) {
+                                Document targetDocument = factory.getFromURL(webappUrl);
+
+                                if (getLogger().isDebugEnabled()) {
+                                    getLogger().debug(
+                                            "Convert links: Check webapp URL [" + webappUrl + "]");
+                                }
+
+                                Link link = new Link();
+                                link.setUuid(targetDocument.getUUID());
+                                attribute.setValue(link.getUri());
+                                linksRewritten = true;
+                            }
+                        }
+                    }
+                }
+
+                if (linksRewritten) {
+                    SourceUtil.writeDOM(xmlDocument, examinedDocument.getSourceURI(), this.manager);
+                }
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("Error rewriting document: [" + examinedDocument
+                    + "] - source URI: [" + examinedDocument.getSourceURI() + "]", e);
+        } finally {
+            if (linkResolver != null) {
+                this.manager.release(linkResolver);
+            }
+        }
+    }
+
+}

Modified: lenya/trunk/src/modules/bxe/resources/javascript/insertAsset.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/bxe/resources/javascript/insertAsset.js?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/bxe/resources/javascript/insertAsset.js (original)
+++ lenya/trunk/src/modules/bxe/resources/javascript/insertAsset.js Thu Jan 11 10:24:31 2007
@@ -17,7 +17,7 @@
       var type = document.forms['image'].type.value;
       var height = document.forms['image'].height.value;
       var width = document.forms['image'].width.value;
-      var content = '<object xmlns="'+window.opener.XHTMLNS+'" href="'+link+'" title="'+title+'" type="'+type+'" data="'+src+'" height="'+height+'" width="'+width+'">'+src+'</object>'; 
+      var content = '<object xmlns="'+window.opener.XHTMLNS+'" href="'+link+'" title="'+title+'" type="'+type+'" data="'+src+'" height="'+height+'" width="'+width+'">'+title+'</object>'; 
       window.opener.bxe_insertContent(content,window.opener.bxe_ContextNode); 
       window.close();
    }

Modified: lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java (original)
+++ lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java Thu Jan 11 10:24:31 2007
@@ -22,12 +22,10 @@
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
-import org.apache.lenya.cms.linking.Link;
-import org.apache.lenya.cms.linking.LinkResolver;
+import org.apache.lenya.cms.linking.LinkConverter;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.publication.Area;
 import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.ResourceType;
@@ -36,11 +34,7 @@
 import org.apache.lenya.cms.site.tree.DefaultSiteTree;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.NamespaceHelper;
-import org.apache.xpath.XPathAPI;
-import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  * Import content.
@@ -187,80 +181,8 @@
     protected void convertLinks(Publication srcPub, Area area) {
         Document[] docs = area.getDocuments();
         for (int i = 0; i < docs.length; i++) {
-            convertLinks(srcPub, docs[i]);
-        }
-    }
-
-    protected void convertLinks(Publication srcPub, Document examinedDocument) {
-        boolean linksRewritten = false;
-        LinkResolver linkResolver = null;
-        try {
-            ResourceType type = examinedDocument.getResourceType();
-            String[] xPaths = type.getLinkAttributeXPaths();
-
-            if (xPaths.length == 0) {
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug(
-                            "Convert links: No XPaths for resource type [" + type.getName() + "]");
-                }
-            } else {
-                linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
-                DocumentFactory factory = examinedDocument.getFactory();
-
-                org.w3c.dom.Document xmlDocument = SourceUtil.readDOM(examinedDocument
-                        .getSourceURI(), this.manager);
-
-                for (int xPathIndex = 0; xPathIndex < xPaths.length; xPathIndex++) {
-                    if (getLogger().isDebugEnabled()) {
-                        getLogger()
-                                .debug("Convert links: Check XPath [" + xPaths[xPathIndex] + "]");
-                    }
-                    NodeList nodes = XPathAPI.selectNodeList(xmlDocument, xPaths[xPathIndex]);
-                    for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
-                        Node node = nodes.item(nodeIndex);
-                        if (node.getNodeType() != Node.ATTRIBUTE_NODE) {
-                            throw new RuntimeException("The XPath [" + xPaths[xPathIndex]
-                                    + "] may only match attribute nodes!");
-                        }
-                        Attr attribute = (Attr) node;
-                        final String url = attribute.getValue();
-                        if (getLogger().isDebugEnabled()) {
-                            getLogger().debug("Convert links: Check URL [" + url + "]");
-                        }
-
-                        if (url.startsWith("/" + srcPub.getId() + "/" + examinedDocument.getArea()
-                                + "/")) {
-                            String targetPubId = examinedDocument.getPublication().getId();
-                            final String webappUrl = "/" + targetPubId
-                                    + url.substring(("/" + srcPub.getId()).length());
-                            if (factory.isDocument(webappUrl)) {
-                                Document targetDocument = factory.getFromURL(webappUrl);
-
-                                if (getLogger().isDebugEnabled()) {
-                                    getLogger().debug(
-                                            "Convert links: Check webapp URL [" + webappUrl + "]");
-                                }
-
-                                Link link = new Link();
-                                link.setUuid(targetDocument.getUUID());
-                                attribute.setValue(link.getUri());
-                                linksRewritten = true;
-                            }
-                        }
-                    }
-                }
-
-                if (linksRewritten) {
-                    SourceUtil.writeDOM(xmlDocument, examinedDocument.getSourceURI(), this.manager);
-                }
-            }
-        } catch (Exception e) {
-            throw new RuntimeException("Error rewriting document: [" + examinedDocument
-                    + "] - source URI: [" + examinedDocument.getSourceURI() + "]", e);
-        } finally {
-            if (linkResolver != null) {
-                this.manager.release(linkResolver);
-            }
+            LinkConverter converter = new LinkConverter(this.manager, getLogger());
+            converter.convertUrlsToUuids(srcPub, docs[i]);
         }
     }
 

Modified: lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java (original)
+++ lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java Thu Jan 11 10:24:31 2007
@@ -27,6 +27,7 @@
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.linking.LinkConverter;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.metadata.MetaDataException;
 import org.apache.lenya.cms.metadata.dublincore.DublinCore;
@@ -158,6 +159,9 @@
                     addErrorMessage("invalid source xml. Full exception: " + e);
                 }
             }
+            
+            LinkConverter converter = new LinkConverter(this.manager, getLogger());
+            converter.convertUrlsToUuids(doc);
 
             String event = getParameterAsString(EVENT);
             if (event != null) {

Modified: lenya/trunk/src/modules/webdav/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/webdav/module.xml?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/webdav/module.xml (original)
+++ lenya/trunk/src/modules/webdav/module.xml Thu Jan 11 10:24:31 2007
@@ -22,6 +22,7 @@
   <id>org.apache.lenya.modules.webdav</id>
   <depends module="org.apache.lenya.modules.usecase"/>
   <depends module="org.apache.lenya.modules.sitemanagement"/>
+  <depends module="org.apache.lenya.modules.linking"/>
   <package>org.apache.lenya.modules</package>
   <version>0.1-dev</version>
   <name>WebDAV Module</name>

Modified: lenya/trunk/src/modules/xhtml/config/cocoon-xconf/resource-type-xhtml.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/xhtml/config/cocoon-xconf/resource-type-xhtml.xconf?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/xhtml/config/cocoon-xconf/resource-type-xhtml.xconf (original)
+++ lenya/trunk/src/modules/xhtml/config/cocoon-xconf/resource-type-xhtml.xconf Thu Jan 11 10:24:31 2007
@@ -33,6 +33,7 @@
     <!-- <sample-name name="Two Column Layout">fallback://lenya/modules/xhtml/samples/xhtml-2col.xml</sample-name> -->
     
     <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@href"/>
+    <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@data"/>
     <format name="xhtml" uri="cocoon://modules/xhtml/xhtml.xml"/>
     <format name="webdavGET" uri="cocoon://modules/xhtml/davget.xml"/>
     <format name="luceneIndex" uri="cocoon://modules/xhtml/lucene-index"/>

Modified: lenya/trunk/src/modules/xhtml/menus.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/xhtml/menus.xmap?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/xhtml/menus.xmap (original)
+++ lenya/trunk/src/modules/xhtml/menus.xmap Thu Jan 11 10:24:31 2007
@@ -26,6 +26,9 @@
     	
       <map:match pattern="**">
         <map:generate type="serverpages" src="fallback://lenya/modules/xhtml/config/menu.xsp"/>
+        <map:transform type="log">
+          <map:parameter name="logfile" value="logbxe.txt"/>
+        </map:transform>
         <map:serialize type="xml"/>
       </map:match>
       

Modified: lenya/trunk/src/modules/xhtml/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/xhtml/sitemap.xmap?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/xhtml/sitemap.xmap (original)
+++ lenya/trunk/src/modules/xhtml/sitemap.xmap Thu Jan 11 10:24:31 2007
@@ -71,7 +71,8 @@
       <map:match pattern="davget.xml">
         <map:act type="set-header">
           <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
-          <map:generate src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
+          <map:generate src="lenya-document:{page-envelope:document-uuid},lang={page-envelope:document-language}"/>
+          <map:transform type="link-rewrite"/>
           <map:serialize type="xml-get"/>
         </map:act>
       </map:match>

Modified: lenya/trunk/src/modules/xhtml/xslt/helper-object.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/xhtml/xslt/helper-object.xsl?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/modules/xhtml/xslt/helper-object.xsl (original)
+++ lenya/trunk/src/modules/xhtml/xslt/helper-object.xsl Thu Jan 11 10:24:31 2007
@@ -35,6 +35,9 @@
       <img border="0">
         <xsl:attribute name="src">
           <xsl:choose>
+            <xsl:when test="starts-with(@data, 'lenya-document:')">
+              <xsl:value-of select="@data"/>
+            </xsl:when>
             <xsl:when test="not(starts-with(@data, '/'))">
               <xsl:value-of select="$nodeid"/>/<xsl:value-of select="@data"/>
             </xsl:when>

Modified: lenya/trunk/src/pubs/default/modules/homepage/config/cocoon-xconf/resource-type-homepage.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/homepage/config/cocoon-xconf/resource-type-homepage.xconf?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/pubs/default/modules/homepage/config/cocoon-xconf/resource-type-homepage.xconf (original)
+++ lenya/trunk/src/pubs/default/modules/homepage/config/cocoon-xconf/resource-type-homepage.xconf Thu Jan 11 10:24:31 2007
@@ -30,6 +30,7 @@
 
     <sample-name>homepage.xml</sample-name>
     <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@href"/>
+    <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@data"/>
     <format name="xhtml" uri="cocoon://modules/homepage/xhtml.xml"/>
     <format name="luceneIndex" uri="cocoon://modules/xhtml/lucene-index"/>
     <format name="webdavGET" uri="cocoon://modules/xhtml/davget.xml"/>

Modified: lenya/trunk/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/sitemap.xmap?view=diff&rev=495317&r1=495316&r2=495317
==============================================================================
--- lenya/trunk/src/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/default/sitemap.xmap Thu Jan 11 10:24:31 2007
@@ -101,7 +101,6 @@
       <map:match pattern="**/">
          <map:redirect-to uri="index.html"/>
       </map:match>
-
     </map:pipeline>
 
     
@@ -137,6 +136,7 @@
           <map:part src="cocoon://modules/sitetree/{2}/{3}/search/{5}.xml"/>
           <map:part src="{resource-type:format-xhtml}?rendertype={1}"/>
         </map:aggregate>
+        <map:transform type="link-rewrite"/>
         <map:transform src="fallback://lenya/modules/svg/xslt/image2svg.xsl"/>
         <map:select type="resource-exists">
           <map:parameter name="prefix" value="fallback://"/>
@@ -198,13 +198,8 @@
         </map:transform>
         <map:transform type="i18n">      
           <map:parameter name="locale" value="{page-envelope:document-language}"/>
-        </map:transform>    
-        <map:select type="parameter">
-          <map:parameter name="parameter-selector-test" value="{1}"/>
-          <map:when test="view">
-            <map:transform type="link-rewrite"/>
-          </map:when>
-        </map:select>
+        </map:transform>
+        <map:transform type="link-rewrite"/>
         <map:serialize type="xml"/>
       </map:match>
     </map:pipeline>
@@ -214,6 +209,7 @@
     request. It then aggregates the lenya menu (for the given area) and
     the lenya body, the actual document. -->
     <map:pipeline>
+      
       <map:match pattern="**.bxe.html">
         <map:generate src="cocoon:/lenyabody-edit/{page-envelope:publication-id}/{page-envelope:area}/{page-envelope:document-type}{page-envelope:document-url}"/>
         <map:serialize type="xml"/>



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