cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r414200 - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/ src/blocks/portal/java/org/apache/cocoon/portal/transformation/ src/blocks/portal/java/org/apache/cocoon/portal/util/
Date Wed, 14 Jun 2006 11:25:03 GMT
Author: cziegeler
Date: Wed Jun 14 04:25:02 2006
New Revision: 414200

URL: http://svn.apache.org/viewvc?rev=414200&view=rev
Log:
Add support for input modules in start uri for application coplet.

Added:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/util/InputModuleHelper.java
  (with props)
Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java?rev=414200&r1=414199&r2=414200&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
Wed Jun 14 04:25:02 2006
@@ -94,7 +94,7 @@
 
     protected List variables = new ArrayList();
 
-    protected Parameters parameters = null;
+    protected Parameters parameters;
 
     protected VariableResolverFactory variableFactory;
     

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java?rev=414200&r1=414199&r2=414200&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
Wed Jun 14 04:25:02 2006
@@ -27,6 +27,7 @@
 import java.util.Enumeration;
 import java.util.Map;
 
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
 import org.apache.avalon.framework.parameters.Parameters;
@@ -42,6 +43,7 @@
 import org.apache.cocoon.portal.coplet.CopletData;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.profile.ProfileManager;
+import org.apache.cocoon.portal.util.InputModuleHelper;
 import org.apache.cocoon.transformation.AbstractTransformer;
 import org.apache.cocoon.util.NetUtils;
 import org.apache.cocoon.xml.XMLUtils;
@@ -67,7 +69,7 @@
  */
 public class ProxyTransformer
     extends AbstractTransformer
-    implements Serviceable, Parameterizable {
+    implements Serviceable, Disposable, Parameterizable {
 
     /**
      * Parameter for specifying the envelope tag
@@ -141,12 +143,25 @@
     /** The sitemap parameters */
     protected Parameters parameters;
 
-    /* (non-Javadoc)
+    /** Helper for resolving input modules. */
+    protected InputModuleHelper imHelper;
+
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
+        this.imHelper = new InputModuleHelper(manager);
+    }
 
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if ( this.imHelper != null ) {
+            this.imHelper.dispose();
+            this.imHelper = null;
+        }
     }
 
     /**
@@ -172,14 +187,13 @@
 
         final CopletData copletData = this.copletInstanceData.getCopletData();
 
-        final String startURI = (String)copletData.getAttribute(START_URI);
-
         this.link = (String) this.copletInstanceData.getTemporaryAttribute(LINK);
 
         this.documentBase = (String) this.copletInstanceData.getAttribute(DOCUMENT_BASE);
 
         if (this.link == null) {
-            this.link = startURI;
+            final String startURI = (String)copletData.getAttribute(START_URI);
+            this.link = this.imHelper.resolve(startURI);
         }
 
         if (documentBase == null) {
@@ -196,7 +210,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
      */
     public void recycle() {
@@ -265,7 +279,7 @@
                     }
                 }
             }
-            
+
             // now append parameters from the sitemap - if any
             final String[] names = this.parameters.getNames();
             for(int i=0; i<names.length; i++) {
@@ -293,7 +307,6 @@
                         result = readXML(connection);
                         remoteURI = checkForRedirect(result, documentBase);
                     }
-
                 }
                 while (remoteURI != null);
             } catch (IOException ex) {
@@ -335,6 +348,7 @@
 
         return firstparameter;
     }
+
     /**
      * Check the http status code of the http response to detect any redirects.
      * @param connection The HttpURLConnection
@@ -583,7 +597,6 @@
     */
     public static String resolveURI(String uri, String documentBase)
     throws MalformedURLException {
-
         if (uri == null) {
             throw new IllegalArgumentException("URI to be resolved must not be null!");
         }
@@ -632,18 +645,17 @@
     }
 
     /**
-    * Method getInstanceData.
-    * @param manager
-    * @param objectModel
-    * @param parameters
-    * @return CopletInstanceData
-    * @throws ProcessingException
-    */
+     * Method getInstanceData.
+     * @param manager
+     * @param objectModel
+     * @param parameters
+     * @return CopletInstanceData
+     * @throws ProcessingException
+     */
     public static CopletInstanceData getInstanceData(ServiceManager manager,
                                                      Map objectModel,
                                                      Parameters parameters)
     throws ProcessingException {
-
         PortalService portalService = null;
         try {
             portalService = (PortalService) manager.lookup(PortalService.ROLE);
@@ -671,5 +683,4 @@
             manager.release(portalService);
         }
     }
-
 }

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/util/InputModuleHelper.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/util/InputModuleHelper.java?rev=414200&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/util/InputModuleHelper.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/util/InputModuleHelper.java
Wed Jun 14 04:25:02 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.cocoon.portal.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.variables.VariableResolver;
+import org.apache.cocoon.components.variables.VariableResolverFactory;
+import org.apache.cocoon.sitemap.PatternException;
+
+/**
+ * @version $Id$ 
+ */
+public class InputModuleHelper {
+
+    /** Service manager. */
+    protected final ServiceManager manager;
+
+    protected final VariableResolverFactory variableFactory;
+
+    protected final Map processedPatterns = new HashMap();
+
+    public InputModuleHelper(ServiceManager serviceManager)
+    throws ServiceException {
+        this.manager = serviceManager;
+        this.variableFactory = (VariableResolverFactory) this.manager.lookup(VariableResolverFactory.ROLE);
+    }
+
+    public void dispose() {
+        final Iterator i = this.processedPatterns.values().iterator();
+        while ( i.hasNext() ) {
+            final VariableResolver resolver = (VariableResolver)i.next();
+            this.variableFactory.release(resolver);
+        }
+        this.processedPatterns.clear();
+        this.manager.release(this.variableFactory);
+    }
+
+    public String resolve(String value) throws ProcessingException {
+        VariableResolver resolver = null;
+        try {
+            resolver = this.variableFactory.lookup( value );
+            return resolver.resolve();
+        } catch (PatternException e) {
+            throw new ProcessingException("Error parsing pattern: " + value, e);
+        } finally {
+            this.variableFactory.release(resolver);
+        }
+    }
+
+    public VariableResolver getVariableResolver(String value) throws ProcessingException
{
+        VariableResolver resolver = (VariableResolver)this.processedPatterns.get(value);
+        if ( resolver == null ) {
+            try {
+                resolver = this.variableFactory.lookup( value );
+                this.processedPatterns.put(value, resolver);
+            } catch (PatternException e) {
+                throw new ProcessingException("Error parsing pattern: " + value, e);
+            }
+        }
+        return resolver;
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/util/InputModuleHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/util/InputModuleHelper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=414200&r1=414199&r2=414200&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Wed Jun 14 04:25:02 2006
@@ -182,6 +182,9 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.10" date="TBD">
+    <action dev="CZ" type="add">
+      Portal Block: Add support for input modules in start uri for application coplet.
+    </action>
     <action dev="VG" type="fix" fixes-bug="COCOON-1247">
       Databases: Support multiple results in SQLTransformer.
     </action>



Mime
View raw message