cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r606927 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/ cocoon-portal-impl/src/main/resources/org/apache/cocoo...
Date Wed, 26 Dec 2007 18:27:53 GMT
Author: cziegeler
Date: Wed Dec 26 10:27:51 2007
New Revision: 606927

URL: http://svn.apache.org/viewvc?rev=606927&view=rev
Log:
Add variable resolver implementation to handle skinpath variable in renderer configuration.

Added:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultVariableResolver.java
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-borderless-window.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-column.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-decorated-frame.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-linktab.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-nowindow.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-row.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-tab.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-window.xml

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
Wed Dec 26 10:27:51 2007
@@ -34,7 +34,6 @@
 import org.apache.cocoon.portal.services.PortalManager;
 import org.apache.cocoon.portal.services.UserService;
 import org.apache.cocoon.portal.services.VariableResolver;
-import org.apache.cocoon.portal.services.VariableResolver.CompiledExpression;
 import org.apache.cocoon.portal.spi.RequestContextProvider;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -87,6 +86,9 @@
     /** Configuration. */
     protected Properties configuration;
 
+    /** The variable resolver. */
+    protected VariableResolver variableResolver;
+
     /** By default we use the logger for this class. */
     private Log logger = LogFactory.getLog(getClass());
 
@@ -270,36 +272,13 @@
     }
 
     /**
-     * TODO Make this a real service
      * @see org.apache.cocoon.portal.PortalService#getVariableResolver()
      */
     public VariableResolver getVariableResolver() {
-        return new VariableResolverImpl();
-    }
-
-    public static final class VariableResolverImpl implements VariableResolver {
-
-        public CompiledExpression compile(String expression) {
-            return new CompiledExpressionImpl(expression);
-        }
-
-        public String resolve(String expression) {
-            return expression;
-        }
-    }
-
-    public static final class CompiledExpressionImpl implements CompiledExpression {
-
-        protected final String expression;
-
-        public CompiledExpressionImpl(String e) {
-            this.expression = e;
+        if ( this.variableResolver == null ) {
+            this.variableResolver = (VariableResolver)this.getService(VariableResolver.class.getName());
         }
-
-        public String resolve() {
-            return this.expression;
-        }
-
+        return this.variableResolver;
     }
 }
 

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultVariableResolver.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultVariableResolver.java?rev=606927&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultVariableResolver.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultVariableResolver.java
Wed Dec 26 10:27:51 2007
@@ -0,0 +1,115 @@
+/*
+ * 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.cocoon.portal.services.impl;
+
+import java.util.Iterator;
+
+import org.apache.cocoon.configuration.PropertyHelper;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.om.SkinDescription;
+import org.apache.cocoon.portal.services.VariableResolver;
+import org.apache.cocoon.portal.util.AbstractBean;
+
+/**
+ * This is the default implementation of the {@link VariableResolver}.
+ * It uses the settings object to replace variables.
+ *
+ * @version $Id$
+ */
+public class DefaultVariableResolver
+    extends AbstractBean
+    implements VariableResolver {
+
+    /** TODO - we should provide a way to query the whole object model. */
+    protected static final String SKINPATH = "{skinpath}";
+
+    /** The settings object. */
+    protected Settings settings;
+
+    public void setSettings(final Settings s) {
+        this.settings = s;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.VariableResolver#compile(java.lang.String)
+     */
+    public CompiledExpression compile(String expression) {
+        return new CompiledExpressionImpl(PropertyHelper.replace(expression, this.settings),
this.settings, this.portalService);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.VariableResolver#resolve(java.lang.String)
+     */
+    public String resolve(String expression) {
+        return this.compile(expression).resolve();
+    }
+
+    protected static final class CompiledExpressionImpl implements CompiledExpression {
+
+        final protected String value;
+
+        final int insertPos;
+
+        final PortalService portalService;
+
+        final Settings settings;
+
+        public CompiledExpressionImpl(final String v, final Settings s, final PortalService
ps) {
+            this.insertPos = v.indexOf(SKINPATH);
+            if ( this.insertPos != -1 ) {
+                if ( this.insertPos == 0 ) {
+                    this.value = v.substring(SKINPATH.length());
+                } else {
+                    this.value = v.substring(0, insertPos) + v.substring(insertPos + SKINPATH.length());
+                }
+            } else {
+                this.value = v;
+            }
+            this.portalService = ps;
+            this.settings = s;
+        }
+
+        /**
+         * @see org.apache.cocoon.portal.services.VariableResolver.CompiledExpression#resolve()
+         */
+        public String resolve() {
+            if ( insertPos == -1 ) {
+                return this.value;
+            }
+            // TODO - Skin detection should be moved to the portal and user service.
+            final String skinName = this.settings.getProperty("skin");
+            // find the correct skin
+            SkinDescription desc = null;
+            final Iterator i = this.portalService.getSkinDescriptions().iterator();
+            while ( i.hasNext() && desc == null ) {
+                final SkinDescription current = (SkinDescription)i.next();
+                if ( current.getName().equals(skinName) ) {
+                    desc = current;
+                }
+            }
+            String skinPath = "";
+            if ( desc != null ) {
+                skinPath = desc.getBasePath();
+            }
+            if ( insertPos == 0 ) {
+                return skinPath + this.value;
+            }
+            return this.value.substring(0, this.insertPos) + skinPath + this.value.substring(this.insertPos);
+        }
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultVariableResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultVariableResolver.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
Wed Dec 26 10:27:51 2007
@@ -251,6 +251,17 @@
           scope="singleton" init-method="init"/>
 
   <!--+
+      | Variable Resolver.
+      |
+      +-->
+    <bean name="org.apache.cocoon.portal.services.VariableResolver"
+          class="org.apache.cocoon.portal.services.impl.DefaultVariableResolver"
+          parent="org.apache.cocoon.portal.util.AbstractBean"
+          scope="singleton">
+        <property name="settings" ref="org.apache.cocoon.configuration.Settings"/>
+    </bean>
+
+  <!--+
       | Profile Manager.
       |
       +-->

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-borderless-window.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-borderless-window.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-borderless-window.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-borderless-window.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/borderless-window.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/borderless-window.xsl"/>
         </portal:aspect>
         <portal:aspect type="parameter">
           <portal:property name="tag-name" value="window"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-column.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-column.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-column.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-column.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/column.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/column.xsl"/>
         </portal:aspect>
         <portal:aspect type="parameter">
           <portal:property name="tag-name" value="column-layout"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-decorated-frame.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-decorated-frame.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-decorated-frame.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-decorated-frame.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/frame.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/frame.xsl"/>
         </portal:aspect>
         <portal:aspect type="parameter">
           <portal:property name="tag-name" value="frame"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-linktab.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-linktab.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-linktab.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-linktab.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/linktab.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/linktab.xsl"/>
         </portal:aspect>
         <portal:aspect type="parameter">
           <portal:property name="tag-name" value="linktab-layout"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-nowindow.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-nowindow.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-nowindow.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-nowindow.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/nowindow.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/nowindow.xsl"/>
         </portal:aspect>
         <portal:aspect type="window"/>
         <portal:aspect type="coplet-cinclude"/>      

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-row.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-row.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-row.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-row.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/row.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/row.xsl"/>
         </portal:aspect>
         <portal:aspect type="parameter">
           <portal:property name="tag-name" value="row-layout"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-tab.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-tab.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-tab.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-tab.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/tab.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/tab.xsl"/>
         </portal:aspect>
         <portal:aspect type="parameter">
           <portal:property name="tag-name" value="tab-layout"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-window.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-window.xml?rev=606927&r1=606926&r2=606927&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-window.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-window.xml
Wed Dec 26 10:27:51 2007
@@ -32,7 +32,7 @@
     <property name="aspectChain">
       <portal:renderer-aspects>
         <portal:aspect type="xslt">
-          <portal:property name="style" value="{portal-skin:skin.basepath}/styles/window.xsl"/>
+          <portal:property name="style" value="{skinpath}/styles/window.xsl"/>
         </portal:aspect>
         <portal:aspect type="parameter">
           <portal:property name="tag-name" value="window"/>



Mime
View raw message