svn commit: r801597 - /lenya/branches/BRANCH_2_0_X/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Thu Aug  6 10:53:52 2009
New Revision: 801597

URL: http://svn.apache.org/viewvc?rev=801597&view=rev
Log:
Adding workaround for bug 47621: Use independent session for link rewriting.

Modified:
    lenya/branches/BRANCH_2_0_X/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java

Modified: lenya/branches/BRANCH_2_0_X/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_0_X/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java?rev=801597&r1=801596&r2=801597&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_0_X/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java (original)
+++ lenya/branches/BRANCH_2_0_X/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/LinkConverter.java Thu Aug  6 10:53:52 2009
@@ -24,8 +24,12 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
 import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.xpath.XPathAPI;
 import org.w3c.dom.Attr;
@@ -86,7 +90,14 @@
                 ChainLinkRewriter incomingRewriter = new ChainLinkRewriter();
                 incomingRewriter.add(new RelativeToAbsoluteLinkRewriter(examinedDocument.getCanonicalWebappURL()));
                 incomingRewriter.add(new IncomingLinkRewriter(pub));
-                LinkRewriter urlToUuidRewriter = new UrlToUuidRewriter(examinedDocument.getFactory());
+
+                // Workaround:
+                // We create a new session because the sitetree of the transaction doesn't yet contain
+                // references to any new documents that were uploaded during the transaction.
+                // See https://issues.apache.org/bugzilla/show_bug.cgi?id=47621
+                Session readOnlySession = RepositoryUtil.createSession(this.manager, examinedDocument.getSession().getIdentity(), false);
+                DocumentFactory newFactory = DocumentUtil.createDocumentFactory(this.manager, readOnlySession);
+                LinkRewriter urlToUuidRewriter = new UrlToUuidRewriter(newFactory);
 
                 org.w3c.dom.Document xml = DocumentHelper.readDocument(examinedDocument
                         .getInputStream());
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.