You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by fl...@apache.org on 2010/11/24 15:34:13 UTC

svn commit: r1038626 - in /lenya/trunk/org.apache.lenya.core.linking: ./ src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/ src/main/java/org/apache/lenya/cms/cocoon/source/ src/main/java/org/apache/lenya/cms/cocoon/transformation/ src...

Author: florent
Date: Wed Nov 24 14:34:13 2010
New Revision: 1038626

URL: http://svn.apache.org/viewvc?rev=1038626&view=rev
Log:
- solve cyclic dependencie
- solve urlinformation and servlethelper changes

Modified:
    lenya/trunk/org.apache.lenya.core.linking/pom.xml
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/AbstractLinkTransformer.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/IncomingProxyTransformer.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ContentLinkManager.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkManager.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkResolverImpl.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UrlToUuidRewriter.java
    lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UuidToUrlRewriter.java

Modified: lenya/trunk/org.apache.lenya.core.linking/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/pom.xml?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.core.linking/pom.xml Wed Nov 24 14:34:13 2010
@@ -31,5 +31,25 @@
       <groupId>org.apache.lenya</groupId>
       <artifactId>lenya-core-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-publication-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-document-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-utils</artifactId>
+    </dependency>
+        <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-proxy</artifactId>
+    </dependency>
   </dependencies>
 </project>

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java Wed Nov 24 14:34:13 2010
@@ -28,7 +28,8 @@ import org.apache.lenya.cms.linking.Link
 import org.apache.lenya.cms.linking.UuidToUrlRewriter;
 import org.apache.lenya.cms.publication.Repository;
 import org.apache.lenya.cms.publication.Session;
-import org.apache.lenya.util.ServletHelper;
+//import org.apache.lenya.util.ServletHelper;
+import org.apache.lenya.utils.ServletHelper;
 
 /**
  * Transform lenya-document: URLs to web application URLs.
@@ -44,7 +45,8 @@ public class UuidToUrlModule extends Abs
         Request request = ObjectModelHelper.getRequest(objectModel);
         try {
             Session session = this.repository.getSession(request);
-            String currentUrl = ServletHelper.getWebappURI(request);
+            //String currentUrl = ServletHelper.getWebappURI(request);
+            String currentUrl = new URLInformation().getWebappUrl();
             
             UuidToUrlRewriter rewriter = new UuidToUrlRewriter(currentUrl, linkResolver, session);
             if (session.getUriHandler().isDocument(currentUrl)) {

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java Wed Nov 24 14:34:13 2010
@@ -39,9 +39,11 @@ import org.apache.lenya.cms.publication.
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.Repository;
 import org.apache.lenya.cms.publication.Session;
-import org.apache.lenya.cms.publication.URLInformation;
+//import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.utils.URLInformation;
 import org.apache.lenya.util.Query;
-import org.apache.lenya.util.ServletHelper;
+//import org.apache.lenya.util.ServletHelper;
+import org.apache.lenya.utils.ServletHelper;
 
 /**
  * <p>
@@ -89,11 +91,12 @@ public class DocumentSourceFactory exten
         try {
 
             Session session = this.repository.getSession(request);
-            String webappUrl = ServletHelper.getWebappURI(request);
+            //String webappUrl = ServletHelper.getWebappURI(request);
+            String webappUrl = new URLInformation().getWebappUrl();
             LinkTarget target;
             if (session.getUriHandler().isDocument(webappUrl)) {
                 Document currentDoc = session.getUriHandler().getDocument(webappUrl);
-                target = getLinkResolver().resolve(currentDoc, linkUri);
+                target = getLinkResolver().resolve(session, currentDoc, linkUri);
             } else {
                 Link link = new Link(linkUri);
                 contextualize(link, webappUrl);
@@ -141,7 +144,8 @@ public class DocumentSourceFactory exten
      * @param webappUrl The web application URL to extract the context information from..
      */
     protected void contextualize(Link link, String webappUrl) {
-        URLInformation url = new URLInformation(webappUrl);
+        //URLInformation url = new URLInformation(webappUrl);
+    	URLInformation url = new URLInformation();
         if (link.getPubId() == null) {
             link.setPubId(url.getPublicationId());
         }
@@ -153,7 +157,7 @@ public class DocumentSourceFactory exten
     protected Source getFormatSource(Document doc, String format) throws DocumentException,
             ServiceException, IOException {
         String formatBaseUri = doc.getResourceType().getFormatURI(format);
-        String formatUri = formatBaseUri + "/" + doc.getPublication().getId() + "/" + doc.getArea()
+        String formatUri = formatBaseUri + "/" + doc.getPublicationId() + "/" + doc.getArea()
                 + "/" + doc.getUUID() + "/" + doc.getLanguage();
 
         return this.sourceResolver.resolveURI(formatUri);

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/AbstractLinkTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/AbstractLinkTransformer.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/AbstractLinkTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/AbstractLinkTransformer.java Wed Nov 24 14:34:13 2010
@@ -34,13 +34,14 @@ import org.apache.cocoon.environment.Obj
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.transformation.AbstractSAXTransformer;
-import org.apache.lenya.ac.AccessControlException;
+//import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.cms.linking.LinkRewriteAttribute;
 import org.apache.lenya.cms.linking.LinkRewriteAttributes;
 import org.apache.lenya.cms.linking.LinkRewriter;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.URLInformation;
-import org.apache.lenya.util.ServletHelper;
+//import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.utils.URLInformation;
+import org.apache.lenya.utils.ServletHelper;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
@@ -76,8 +77,11 @@ public abstract class AbstractLinkTransf
     public void setup(SourceResolver resolver, Map objectModel, String src, Parameters params)
             throws ProcessingException, SAXException, IOException {
         super.setup(resolver, objectModel, src, params);
-        String webappUrl = getWebappUrl(params, objectModel);
-        URLInformation url = new URLInformation(webappUrl);
+        /* TODO : florent : remove it when ok, change of urlinformation apî
+         * 	String webappUrl = getWebappUrl(params, objectModel);
+         * URLInformation url = new URLInformation(webappUrl);
+         */
+        URLInformation url = new URLInformation();
         this.area = url.getArea();
     }
 
@@ -98,7 +102,8 @@ public abstract class AbstractLinkTransf
             }
         } else {
             Request request = ObjectModelHelper.getRequest(objectModel);
-            webappUrl = ServletHelper.getWebappURI(request);
+            //webappUrl = ServletHelper.getWebappURI(request);
+            webappUrl = new URLInformation().getWebappUrl();
         }
         return webappUrl;
     }
@@ -330,7 +335,9 @@ public abstract class AbstractLinkTransf
      * @throws AccessControlException when something went wrong.
      */
     protected void markBrokenLink(AttributesImpl newAttrs, String attrName, String brokenLinkUri)
-            throws AccessControlException {
+      //TODO : remove this accessControlException in order to solve cyclic dependencies. See how to clean this
+    	//throws AccessControlException {
+    	{
         if (this.brokenLinkAttribute != null) {
             if (newAttrs.getIndex(this.brokenLinkAttribute) > -1) {
                 newAttrs.removeAttribute(newAttrs.getIndex(this.brokenLinkAttribute));

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/IncomingProxyTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/IncomingProxyTransformer.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/IncomingProxyTransformer.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/cocoon/transformation/IncomingProxyTransformer.java Wed Nov 24 14:34:13 2010
@@ -29,7 +29,8 @@ import org.apache.lenya.cms.linking.Inco
 import org.apache.lenya.cms.linking.LinkRewriter;
 import org.apache.lenya.cms.publication.Repository;
 import org.apache.lenya.cms.publication.Session;
-import org.apache.lenya.cms.publication.URLInformation;
+//import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.utils.URLInformation;
 import org.xml.sax.SAXException;
 
 /**
@@ -48,8 +49,9 @@ public class IncomingProxyTransformer ex
 
         try {
             Session session = this.repository.getSession(request);
-            String webappUrl = getWebappUrl(params, objectModel);
-            URLInformation info = new URLInformation(webappUrl);
+            //String webappUrl = getWebappUrl(params, objectModel);
+            //URLInformation info = new URLInformation(webappUrl);
+            URLInformation info = new URLInformation();
             String pubId = info.getPublicationId();
             this.rewriter = new IncomingLinkRewriter(session.getPublication(pubId));
         } catch (final Exception e) {

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ContentLinkManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ContentLinkManager.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ContentLinkManager.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/ContentLinkManager.java Wed Nov 24 14:34:13 2010
@@ -98,6 +98,9 @@ public class ContentLinkManager extends 
         return uri.startsWith(LinkResolver.SCHEME + ":");
     }
 
+    //TODO : florent : first just used in core-workflow o.a.l.c.workflow.usecase, but seem that Deactivate d'ont need to use it
+    //so, func commented, suppress when ok. This use the suppressed document.area func
+    /*
     public Document[] getReferencingDocuments(Document target) {
 
         Document[] allDocs = target.area().getDocuments();
@@ -124,7 +127,7 @@ public class ContentLinkManager extends 
             }
         }
         return (Document[]) docs.toArray(new Document[docs.size()]);
-    }
+    }*/
 
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkManager.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkManager.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkManager.java Wed Nov 24 14:34:13 2010
@@ -43,6 +43,7 @@ public interface LinkManager {
      * @param target The target document.
      * @return An array of documents.
      */
-    Document[] getReferencingDocuments(Document target);
+    //TODO : florent : remove as it don't seem to be used (see o.a.l.c.linking.ContentLinkManager : supress when ok
+    //Document[] getReferencingDocuments(Document target);
 
 }

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkResolverImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkResolverImpl.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkResolverImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/LinkResolverImpl.java Wed Nov 24 14:34:13 2010
@@ -38,21 +38,27 @@ public class LinkResolverImpl extends Ab
      */
     public static final String ROLE = LinkResolverImpl.class.getName();
 
-    public LinkTarget resolve(Document currentDoc, String linkUri) throws MalformedURLException {
+    //TODO : florent : change the method signature by adding a session attribute because document don't still handle his session
+    // remove comments when ok
+    public LinkTarget resolve(Session session, Document currentDoc, String linkUri) throws MalformedURLException {
 
         Link link = new Link(linkUri);
 
         String language = getValue(link.getLanguage(), currentDoc.getLanguage());
         String revisionString = getValue(link.getRevision(), null);
         String area = getValue(link.getArea(), currentDoc.getArea());
-        String pubId = getValue(link.getPubId(), currentDoc.getPublication().getId());
-
+        //TODO : florent : remove it when ok
+        //String pubId = getValue(link.getPubId(), currentDoc.getPublication().getId());
+        String pubId = getValue(link.getPubId(), currentDoc.getPublicationId());
+        
         String uuid = getValue(link.getUuid(), currentDoc.getUUID());
         if (uuid.length() == 0) {
             uuid = currentDoc.getUUID();
         }
 
-        return resolve(currentDoc.getSession(), pubId, area, uuid, language, revisionString);
+        //TODO : florent : remove comment when ok
+        //return resolve(currentDoc.getSession(), pubId, area, uuid, language, revisionString);
+        return resolve(session, pubId, area, uuid, language, revisionString);
     }
 
     protected String getValue(String value, String defaultValue) {

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UrlToUuidRewriter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UrlToUuidRewriter.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UrlToUuidRewriter.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UrlToUuidRewriter.java Wed Nov 24 14:34:13 2010
@@ -22,8 +22,8 @@ import java.util.Arrays;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.Session;
-import org.apache.lenya.cms.publication.URLInformation;
-
+//import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.utils.URLInformation;
 /**
  * <p>
  * Converts webapp URLs to UUID-based internal links. If the URL doesn't refer to a document, the
@@ -46,7 +46,8 @@ public class UrlToUuidRewriter implement
 
     public boolean matches(String url) {
         if (url.startsWith("/")) {
-            URLInformation info = new URLInformation(url);
+           // URLInformation info = new URLInformation(url);
+        	 URLInformation info = new URLInformation();
             String pubId = info.getPublicationId();
             String area = info.getArea();
             if (pubId != null && area != null) {

Modified: lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UuidToUrlRewriter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UuidToUrlRewriter.java?rev=1038626&r1=1038625&r2=1038626&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UuidToUrlRewriter.java (original)
+++ lenya/trunk/org.apache.lenya.core.linking/src/main/java/org/apache/lenya/cms/linking/UuidToUrlRewriter.java Wed Nov 24 14:34:13 2010
@@ -21,11 +21,12 @@ import java.net.MalformedURLException;
 import java.util.StringTokenizer;
 
 import org.apache.commons.lang.Validate;
-import org.apache.lenya.ac.AccessControlException;
+//import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.Session;
-import org.apache.lenya.cms.publication.URLInformation;
+//import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.utils.URLInformation;
 import org.apache.lenya.util.Query;
 
 /**
@@ -96,7 +97,8 @@ public class UuidToUrlRewriter implement
 
         String rewrittenUrl = null;
 
-        URLInformation info = new URLInformation(this.currentUrl);
+        //URLInformation info = new URLInformation(this.currentUrl);
+        URLInformation info = new URLInformation();
         if (linkUrl.startsWith(SCHEME)) {
 
             String anchor = null;
@@ -125,7 +127,7 @@ public class UuidToUrlRewriter implement
             LinkTarget target;
             try {
                 if (this.currentDoc != null) {
-                    target = this.linkResolver.resolve(this.currentDoc, linkUri);
+                    target = this.linkResolver.resolve(this.session, this.currentDoc, linkUri);
                 } else {
                     Link link = getAbsoluteLink(info, linkUri);
                     target = this.linkResolver.resolve(this.session, link.getUri());
@@ -178,7 +180,10 @@ public class UuidToUrlRewriter implement
      * @throws AccessControlException when something went wrong.
      */
     protected String getWebappUrl(Document targetDocument, String anchor, String queryString,
-            String extension) throws AccessControlException {
+            String extension) {
+    	//TODO : exception removed for cyclic dependencies. See if create another exception
+    	//throws AccessControlException {
+    
 
         String webappUrl = targetDocument.getCanonicalWebappURL();
 



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