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 2006/12/12 18:55:41 UTC

svn commit: r486256 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java targets/webapp-build.xml webapp/lenya/i18n.xmap

Author: andreas
Date: Tue Dec 12 09:55:40 2006
New Revision: 486256

URL: http://svn.apache.org/viewvc?view=rev&rev=486256
Log:
Set i18n pipelines to caching, close aggregated source validity correctly (improves performance)

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java
    lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java
    lenya/trunk/src/targets/webapp-build.xml
    lenya/trunk/src/webapp/lenya/i18n.xmap

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java?view=diff&rev=486256&r1=486255&r2=486256
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/AggregatingSource.java Tue Dec 12 09:55:40 2006
@@ -6,18 +6,18 @@
 import java.io.InputStream;
 
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.components.source.impl.MultiSourceValidity;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.source.SourceValidity;
-import org.apache.excalibur.source.impl.validity.AggregatedValidity;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.NamespaceHelper;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
- *
+ * 
  */
 public class AggregatingSource implements Source {
 
@@ -35,7 +35,7 @@
         this.sourceUris = uris;
         this.uri = uri;
     }
-    
+
     public String toString() {
         return getURI();
     }
@@ -43,10 +43,11 @@
     protected void loadDom() {
         try {
             for (int i = 0; i < sourceUris.length; i++) {
-                Document sourceDom = SourceUtil.readDOM(sourceUris[i], manager);
+                Document sourceDom = SourceUtil.readDOM(sourceUris[i], this.manager);
 
                 if (sourceDom == null) {
-                    throw new RuntimeException("The source [" + sourceUris[i] + "] doesn't contain XML.");
+                    throw new RuntimeException("The source [" + sourceUris[i]
+                            + "] doesn't contain XML.");
                 }
 
                 Element docElement = sourceDom.getDocumentElement();
@@ -57,9 +58,9 @@
 
                     if (namespaceUri == null || prefix == null) {
                         this.dom = DocumentHelper.createDocument(null, localName, null);
-                    }
-                    else {
-                        NamespaceHelper helper = new NamespaceHelper(namespaceUri, prefix, localName);
+                    } else {
+                        NamespaceHelper helper = new NamespaceHelper(namespaceUri, prefix,
+                                localName);
                         this.dom = helper.getDocument();
                     }
                 }
@@ -104,7 +105,7 @@
     }
 
     public boolean exists() {
-        return getData() != null;
+        return this.sourceUris.length > 0;
     }
 
     public long getContentLength() {
@@ -115,15 +116,15 @@
         if (!exists()) {
             throw new RuntimeException(this + " does not exist!");
         }
-        return new ByteArrayInputStream(this.data);
+        return new ByteArrayInputStream(getData());
     }
 
     public long getLastModified() {
         long lastModified = 0;
         for (int i = 0; i < this.sourceUris.length; i++) {
             try {
-                lastModified = Math
-                        .max(lastModified, SourceUtil.getLastModified(sourceUris[i], this.manager));
+                lastModified = Math.max(lastModified, SourceUtil.getLastModified(sourceUris[i],
+                        this.manager));
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
@@ -142,32 +143,35 @@
     public String getURI() {
         return this.uri;
     }
-    
+
     private SourceValidity validity;
 
     public SourceValidity getValidity() {
         if (this.validity == null) {
-            AggregatedValidity aggregatedValidity = new AggregatedValidity();
-            for (int i = 0; i < this.sourceUris.length; i++) {
-                SourceResolver resolver = null;
-                Source source = null;
-                try {
-                    resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-                    source = resolver.resolveURI(this.sourceUris[i]);
-                    aggregatedValidity.add(source.getValidity());
-                } catch (Exception e) {
-                    throw new RuntimeException(e);
-                }
-                finally {
-                    if (resolver != null) {
+            SourceResolver resolver = null;
+            try {
+                resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+                MultiSourceValidity aggregatedValidity = new MultiSourceValidity(resolver, 0);
+                for (int i = 0; i < this.sourceUris.length; i++) {
+                    Source source = null;
+                    try {
+                        source = resolver.resolveURI(this.sourceUris[i]);
+                        aggregatedValidity.addSource(source);
+                    } finally {
                         if (source != null) {
                             resolver.release(source);
                         }
-                        this.manager.release(resolver);
                     }
                 }
+                aggregatedValidity.close();
+                this.validity = aggregatedValidity;
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            } finally {
+                if (resolver != null) {
+                    this.manager.release(resolver);
+                }
             }
-            this.validity = aggregatedValidity;
         }
         return this.validity;
     }
@@ -175,6 +179,7 @@
     public void refresh() {
         this.dom = null;
         this.data = null;
+        this.validity = null;
     }
 
 }

Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java?view=diff&rev=486256&r1=486255&r2=486256
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java Tue Dec 12 09:55:40 2006
@@ -107,13 +107,18 @@
             builder = (DocumentBuilder) selector.select(hint);
 
             boolean provided = getParameterAsBoolean(PATH_PROVIDED, false);
-            if (!provided && !builder.isValidDocumentName(nodeName)) {
-                addErrorMessage("The document ID may not contain any special characters.");
-            } else {
+            
+            if (provided) {
                 String newPath = getNewDocumentPath();
                 if (pub.getArea(getArea()).getSite().contains(newPath)) {
                     addErrorMessage("The document with path " + newPath + " already exists.");
                 }
+            }
+            else if (nodeName == null) {
+                addErrorMessage("Please enter a node name.");
+            }
+            else if (!builder.isValidDocumentName(nodeName)) {
+                addErrorMessage("The node name may not contain any special characters.");
             }
         } finally {
             if (selector != null) {

Modified: lenya/trunk/src/targets/webapp-build.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/targets/webapp-build.xml?view=diff&rev=486256&r1=486255&r2=486256
==============================================================================
--- lenya/trunk/src/targets/webapp-build.xml (original)
+++ lenya/trunk/src/targets/webapp-build.xml Tue Dec 12 09:55:40 2006
@@ -23,6 +23,15 @@
   <description>
     Webapp Targets
   </description>
+  
+  <target name="compile-api" description="compile and deploy API">
+    <antcall target="compile-src">
+      <param name="compile.src.dir" value="${src.java.api.dir}"/>
+      <param name="compile.dest.dir" value="${build.dir}/api"/>
+      <param name="compile.classpath" value="classpath"/>
+      <param name="jar.name" value="api"/>
+    </antcall>
+  </target>
 
   <!-- 
   This target creates a webapp directory which exactly mirrors how
@@ -118,13 +127,7 @@
       </fileset>
     </delete>
 
-    <!-- compile and deploy API -->    
-    <antcall target="compile-src">
-      <param name="compile.src.dir" value="${src.java.api.dir}"/>
-      <param name="compile.dest.dir" value="${build.dir}/api"/>
-      <param name="compile.classpath" value="classpath"/>
-      <param name="jar.name" value="api"/>
-    </antcall>
+    <antcall target="compile-api"/>
     
     <path id="classpath.impl">
       <path refid="classpath"/>

Modified: lenya/trunk/src/webapp/lenya/i18n.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/i18n.xmap?view=diff&rev=486256&r1=486255&r2=486256
==============================================================================
--- lenya/trunk/src/webapp/lenya/i18n.xmap (original)
+++ lenya/trunk/src/webapp/lenya/i18n.xmap Tue Dec 12 09:55:40 2006
@@ -43,7 +43,7 @@
   
   <map:pipelines>
     
-    <map:pipeline type="noncaching">
+    <map:pipeline type="caching">
       
       <!-- i18n-catalogue/module/{module-id}/{catalogue}--> 
       <map:match pattern="i18n-catalogue/module/*/*">



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