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 10:29:11 UTC

svn commit: r486072 - in /lenya/trunk/src: impl/test/org/apache/lenya/cms/publication/util/ java/org/apache/lenya/cms/publication/util/ modules/collection/ modules/collection/config/ modules/collection/config/cocoon-xconf/ modules/collection/samples/ m...

Author: andreas
Date: Tue Dec 12 01:29:10 2006
New Revision: 486072

URL: http://svn.apache.org/viewvc?view=rev&rev=486072
Log:
Added collection module which provides the resource type necessary to make collection test work, register SourceNode as dirty only when output stream is closed

Added:
    lenya/trunk/src/modules/collection/
    lenya/trunk/src/modules/collection/config/
    lenya/trunk/src/modules/collection/config/cocoon-xconf/
    lenya/trunk/src/modules/collection/config/cocoon-xconf/resourcetype-collection.xconf
    lenya/trunk/src/modules/collection/module.xml
    lenya/trunk/src/modules/collection/samples/
    lenya/trunk/src/modules/collection/samples/collection.xml
Modified:
    lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java
    lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
    lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java

Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java?view=diff&rev=486072&r1=486071&r2=486072
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java Tue Dec 12 01:29:10 2006
@@ -22,11 +22,13 @@
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.impl.AbstractAccessControlTest;
 import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentIdentifier;
+import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
+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.cms.site.SiteManager;
@@ -51,11 +53,13 @@
         DocumentFactory map = DocumentUtil.createDocumentFactory(getManager(), session);
 
         Publication pub = getPublication("test");
-        DocumentIdentifier identifier = new DocumentIdentifier(pub, Publication.AUTHORING_AREA,
-                "12345", "en");
-        XlinkCollection collection = new XlinkCollection(getManager(), map, identifier, getLogger());
 
-        SiteStructure structure = pub.getArea(identifier.getArea()).getSite();
+        Document collectionDoc = createCollectionDocument(pub);
+
+        XlinkCollection collection = new XlinkCollection(getManager(), map, collectionDoc
+                .getIdentifier(), getLogger());
+
+        SiteStructure structure = pub.getArea("authoring").getSite();
         structure.getRepositoryNode().lock();
 
         SiteManager siteManager = null;
@@ -80,7 +84,8 @@
         collection.getDelegate().getRepositoryNode().unlock();
         structure.getRepositoryNode().unlock();
 
-        Collection coll2 = new XlinkCollection(getManager(), map, identifier, getLogger());
+        Collection coll2 = new XlinkCollection(getManager(), map, collectionDoc.getIdentifier(),
+                getLogger());
 
         assertSame(collection.getDelegate().getRepositoryNode(), coll2.getDelegate()
                 .getRepositoryNode());
@@ -89,6 +94,29 @@
         assertEquals(coll2.size(), 1);
         assertTrue(coll2.contains(doc));
 
+    }
+
+    protected Document createCollectionDocument(Publication pub) throws ServiceException,
+            DocumentBuildException, PublicationException {
+        ServiceSelector typeSelector = null;
+        ResourceType type = null;
+        DocumentManager docMgr = null;
+        Document doc;
+        try {
+            typeSelector = (ServiceSelector) getManager().lookup(ResourceType.ROLE + "Selector");
+            type = (ResourceType) typeSelector.select("collection");
+            docMgr = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
+            String sampleUri = type.getSampleURI(type.getSampleNames()[0]);
+            doc = docMgr.add(getFactory(), type, sampleUri, pub, "authoring", "en", ".xml");
+        } finally {
+            if (docMgr != null) {
+                getManager().release(docMgr);
+            }
+            if (typeSelector != null) {
+                getManager().release(typeSelector);
+            }
+        }
+        return doc;
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java?view=diff&rev=486072&r1=486071&r2=486072
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java Tue Dec 12 01:29:10 2006
@@ -29,6 +29,7 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentException;
@@ -66,7 +67,7 @@
         this.manager = manager;
         try {
             this.delegate = map.get(identifier);
-        } catch (DocumentBuildException e) {
+        } catch (Exception e) {
             throw new DocumentException(e);
         }
     }
@@ -157,6 +158,8 @@
                     Document document = loadDocument(documentElement);
                     this.documentsList.add(document);
                 }
+            } catch (RuntimeException e) {
+                throw e;
             } catch (DocumentException e) {
                 throw e;
             } catch (Exception e) {

Added: lenya/trunk/src/modules/collection/config/cocoon-xconf/resourcetype-collection.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/collection/config/cocoon-xconf/resourcetype-collection.xconf?view=auto&rev=486072
==============================================================================
--- lenya/trunk/src/modules/collection/config/cocoon-xconf/resourcetype-collection.xconf (added)
+++ lenya/trunk/src/modules/collection/config/cocoon-xconf/resourcetype-collection.xconf Tue Dec 12 01:29:10 2006
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+
+<!-- $Id: doctypes.xconf 164635 2005-04-25 20:01:43Z tschlabach $ -->
+
+<xconf xpath="/cocoon/resource-types" unless="/cocoon/resource-types/component-instance[@name = 'collection']">
+
+  <component-instance name="collection"
+                      logger="lenya.resourcetypes.collectoin"
+                      class="org.apache.lenya.cms.publication.ResourceTypeImpl">
+    <sample-name>fallback://lenya/modules/collection/samples/collection.xml</sample-name>
+  </component-instance>
+
+</xconf>

Added: lenya/trunk/src/modules/collection/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/collection/module.xml?view=auto&rev=486072
==============================================================================
--- lenya/trunk/src/modules/collection/module.xml (added)
+++ lenya/trunk/src/modules/collection/module.xml Tue Dec 12 01:29:10 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<!-- $Id: publication.xml 374687 2006-02-03 15:24:55Z michi $ -->
+
+<module xmlns="http://apache.org/lenya/module/1.0">
+  <id>org.apache.lenya.modules.collection</id>
+  <package>org.apache.lenya.modules</package>
+  <version>0.1-dev</version>
+  <name>Collection</name>
+  <lenya-version>@lenya.version@</lenya-version>
+  <description>Collection resource type</description>
+</module>
\ No newline at end of file

Added: lenya/trunk/src/modules/collection/samples/collection.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/collection/samples/collection.xml?view=auto&rev=486072
==============================================================================
--- lenya/trunk/src/modules/collection/samples/collection.xml (added)
+++ lenya/trunk/src/modules/collection/samples/collection.xml Tue Dec 12 01:29:10 2006
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<collection xmlns="http://apache.org/cocoon/lenya/collection/1.0"/>

Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java?view=diff&rev=486072&r1=486071&r2=486072
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java Tue Dec 12 01:29:10 2006
@@ -377,7 +377,7 @@
     }
 
     public boolean exists() throws RepositoryException {
-        return this.contentSource.exists() || this.metaSource.exists();
+        return this.contentSource.exists();
     }
 
     public OutputStream getOutputStream() throws RepositoryException {

Modified: lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java?view=diff&rev=486072&r1=486071&r2=486072
==============================================================================
--- lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java (original)
+++ lenya/trunk/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceWrapper.java Tue Dec 12 01:29:10 2006
@@ -313,6 +313,11 @@
         public synchronized void close() throws IOException {
             SourceWrapper.this.data = super.toByteArray();
             SourceWrapper.this.lastModified = new Date().getTime();
+            try {
+                SourceWrapper.this.getNode().registerDirty();
+            } catch (RepositoryException e) {
+                throw new RuntimeException(e);
+            }
             super.close();
         }
     }
@@ -411,11 +416,6 @@
     public synchronized OutputStream getOutputStream() throws RepositoryException {
         if (getLogger().isDebugEnabled())
             getLogger().debug("Get OutputStream for " + getSourceUri());
-        try {
-            getNode().registerDirty();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
         return new NodeOutputStream();
     }
 



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