You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jw...@apache.org on 2005/05/15 15:42:14 UTC

svn commit: r170220 - in /lenya/trunk/src: java/org/apache/lenya/cms/authoring/ java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/site/usecases/ webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/ webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/

Author: jwkaltz
Date: Sun May 15 06:42:13 2005
New Revision: 170220

URL: http://svn.apache.org/viewcvs?rev=170220&view=rev
Log:
factorized document creation into DocumentManager; removed usage of File in creation process

Added:
    lenya/trunk/src/java/org/apache/lenya/cms/authoring/NodeCreatorInterface.java
      - copied, changed from r170219, lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
Removed:
    lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java
    lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
    lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java
    lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java Sun May 15 06:42:13 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation
+ * Copyright  1999-2005 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.
@@ -19,8 +19,6 @@
 
 package org.apache.lenya.cms.authoring;
 
-import java.io.File;
-
 /**
  * Default creator for Documents of type branch (ie, they can have child documents)
  */
@@ -36,34 +34,22 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.authoring.DefaultCreator#getChildFileName(java.io.File, java.lang.String, java.lang.String)
+     * @see org.apache.lenya.cms.authoring.NodeCreatorInterface#getNewDocumentURI(String, String, String, String)
      */
-    protected String getChildFileName(
-        File parentDir,
-        String childId,
+    public String getNewDocumentURI(
+        String contentBaseURI,
+        String parentId,
+        String newId,
         String language) {
-        return parentDir
-            + File.separator
-            + childId
-            + File.separator
+        return 
+            contentBaseURI
+            + parentId
+            + "/"
+            + newId
+            + "/"
             + "index"
             + getLanguageSuffix(language)
             + ".xml";
     }
 
-    /**
-     * @see org.apache.lenya.cms.authoring.DefaultCreator#getChildMetaFileName(java.io.File, java.lang.String, java.lang.String)
-     */
-    protected String getChildMetaFileName(
-        File parentDir,
-        String childId,
-        String language) {
-        return parentDir
-            + File.separator
-            + childId
-            + File.separator
-            + "indexmeta"
-            + getLanguageSuffix(language)
-            + ".xml";
-    }
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java Sun May 15 06:42:13 2005
@@ -17,8 +17,6 @@
 
 package org.apache.lenya.cms.authoring;
 
-import java.io.File;
-import java.io.FileNotFoundException;
 import java.util.Map;
 
 import org.apache.avalon.framework.configuration.Configuration;
@@ -27,21 +25,21 @@
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.xml.DocumentHelper;
 import org.w3c.dom.Document;
 
 /**
- * The default creator for documents
+ * Base creator for creating documents
  * @version $Id$
  */
-public class DefaultCreator extends AbstractLogEnabled implements ParentChildCreatorInterface  {
+public abstract class DefaultCreator extends AbstractLogEnabled implements NodeCreatorInterface  {
 
     private String sampleResourceName = null;
     private ServiceManager manager;
 
     /**
-     * @see org.apache.lenya.cms.authoring.ParentChildCreatorInterface#init(Configuration, ServiceManager, Logger)
+     * @see org.apache.lenya.cms.authoring.NodeCreatorInterface#init(Configuration, ServiceManager, Logger)
      */
     public void init(Configuration conf, ServiceManager _manager, Logger _logger) {
         // parameter conf ignored: nothing to configure in current implementation
@@ -84,25 +82,30 @@
         return "abstract_default";
     }
 
-
     /**
-     * @see org.apache.lenya.cms.authoring.ParentChildCreatorInterface#create(String, File,
-     * String, short, String, String, Map)
+     * @see NodeCreatorInterface#create(String, String, String, short, String, Map)
       */
     public void create(
         String initialContentsURI,
-        File parentDir,
+        String newURI,
         String childId,
         short childType,
         String childName,
-        String language,
         Map parameters)
         throws Exception {
 
-        // Set filenames
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("DefaultCreator::create() called with\n"
+               + "\t initialContentsURI [" + initialContentsURI + "]\n"
+               + "\t newURI [" + newURI + "]\n"
+               + "\t childId [" + childId + "]\n"
+               + "\t childType [" + childType + "]\n"
+               + "\t childName [" + childName + "]\n"
+               + "\t non-empty parameters [" + (parameters != null) + "]\n"
+               );
+
+        // 
         String id = generateTreeId(childId, childType);
-        String filename = getChildFileName(parentDir, id, language);
-        String filenameMeta = getChildMetaFileName(parentDir, id, language);
 
         // Read initial contents as DOM
         if (getLogger().isDebugEnabled())
@@ -122,20 +125,13 @@
         // transform the xml if needed
         transformXML(doc, id, childType, childName, parameters);
 
-        // write the document (create the path, i.e. the parent
-        // directory first if needed)
-        File parent = new File(new File(filename).getParent());
-
-        if (!parent.exists()) {
-            parent.mkdirs();
+        // write the document 
+        try {
+            SourceUtil.writeDOM(doc, newURI, manager);
+        }
+        catch (Exception e) {
+            throw new DocumentBuildException("could not write document to URI [" + newURI + "], exception " + e.toString(), e);
         }
-
-        if (getLogger().isDebugEnabled())
-            getLogger().debug("write file: " + filename);
-
-        // Write file
-        DocumentHelper.writeDocument(doc, new File(filename));
-
     }
 
     /**
@@ -158,51 +154,13 @@
     }
 
     /**
-     * Apply some transformation on the meta file of newly created child.
-     * @param doc the xml document
-     * @param childId the id of the child
-     * @param childType the type of child
-     * @param childName the name of the child
-     * @param parameters additional parameters that can be used in the transformation
-     * @throws Exception if the transformation fails
+     * @see org.apache.lenya.cms.authoring.NodeCreatorInterface#getNewDocumentURI(String, String, String, String)
      */
-    protected void transformMetaXML(
-        Document doc,
-        String childId,
-        short childType,
-        String childName,
-        Map parameters)
-        throws Exception {
-	    // do nothing
-        }
-
-    /**
-     * Get the file name of the child
-     * @param parentDir the parent directory
-     * @param childId the id of the child
-     * @param language for which the document is created
-     * @return the file name of the child
-     */
-    protected String getChildFileName(
-        File parentDir,
-        String childId,
-        String language) {
-        return null;
-    }
-
-    /**
-     * Get the file name of the meta file
-     * @param parentDir the parent directory
-     * @param childId the id of the child
-     * @param language for which the document is created
-     * @return the name of the meta file
-     */
-    protected String getChildMetaFileName(
-        File parentDir,
-        String childId,
-        String language) {
-        return null;
-    }
+    public abstract String getNewDocumentURI(
+        String contentBaseURI,
+        String parentId,
+        String newId,
+        String language);
 
     /**
      * Create the language suffix for a file name given a language string

Copied: lenya/trunk/src/java/org/apache/lenya/cms/authoring/NodeCreatorInterface.java (from r170219, lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java)
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/authoring/NodeCreatorInterface.java?p2=lenya/trunk/src/java/org/apache/lenya/cms/authoring/NodeCreatorInterface.java&p1=lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java&r1=170219&r2=170220&rev=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/authoring/NodeCreatorInterface.java Sun May 15 06:42:13 2005
@@ -17,7 +17,6 @@
 
 package org.apache.lenya.cms.authoring;
 
-import java.io.File;
 import java.util.Map;
 
 import org.apache.avalon.framework.configuration.Configuration;
@@ -25,10 +24,10 @@
 import org.apache.avalon.framework.service.ServiceManager;
 
 /**
- * Interface for creation of hierarchical documents
+ * Interface for creation of nodes in the document hierarchy
  * @version $Id$
  */
-public interface ParentChildCreatorInterface {
+public interface NodeCreatorInterface {
     /**
      * Constant for a branch node. Branch nodes are somewhat related
      * to the concept of collections in WebDAV. They are not the same
@@ -86,26 +85,39 @@
     String generateTreeId(String childId, short childType) throws Exception;
 
     /**
-     * Create a new document.
+     * Create a physical representation for a new document.
      *
      * @param initialContentsURI the URI where initial content for this document can be found.
-     * @param parentDir in which directory the document is to be created.
+     * @param newURI the URI under which the new node is to be created. Can be retrieved via getNewDocumentURI()
      * @param childId the document id of the new document
-     * @param childType the type of the new document.
+     * @param childType the node type (branch, leaf)
      * @param childName the name of the new document.
-     * @param language for which the document is created.
-     * @param parameters additional parameters that can be used when creating the child
+     * @param parameters additional parameters that can be used when creating the document
      * 
+     * @see #getNewDocumentURI(String,String,String,String)
      * @exception Exception if an error occurs
      */
     void create(
         String initialContentsURI,
-        File parentDir,
+        String newURI,
         String childId,
         short childType,
         String childName,
-        String language,
         Map parameters)
         throws Exception;
+
+    /**
+     * Get the URI of a new document
+     * @param contentBaseURI the base URI of where contents are found
+     * @param parentId the id of the parent, if known
+     * @param newId the id of the new document
+     * @param language for which the document is created
+     * @return the new URI
+     */
+    String getNewDocumentURI(
+        String contentBaseURI,
+        String parentId,
+        String newId,
+        String language);
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Sun May 15 06:42:13 2005
@@ -15,8 +15,6 @@
  *
  */
 
-/* $Id$  */
-
 package org.apache.lenya.cms.publication;
 
 import java.io.File;
@@ -46,10 +44,12 @@
 
 /**
  * A typical CMS document.
+ * @version $Id$
  */
 public class DefaultDocument extends AbstractLogEnabled implements Document {
 
     private String id;
+    private String sourceURI;
     private DocumentIdentityMap identityMap;
     protected ServiceManager manager;
     private MetaDataManager metaDataManager;
@@ -469,11 +469,29 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.publication.Document#getSourceURI()
+     * When source URI has not been set by whoever created the document,
+     * provides a default mechanism for constructing the document's URI.
      */
-    public String getSourceURI() {
+    private String getDefaultSourceURI() {
         String path = publication.getPathMapper().getPath(getId(), getLanguage());
         return publication.getSourceURI() + "/content/" + getArea() + "/" + path;
+
+    }
+
+    /**
+     * @see org.apache.lenya.cms.publication.Document#getSourceURI()
+     */
+    public String getSourceURI() {
+        if (sourceURI == null)
+            sourceURI = getDefaultSourceURI();
+        return sourceURI;
+    }
+
+    /**
+     * @see org.apache.lenya.cms.publication.Document#setSourceURI(String)
+     */
+    public void setSourceURI(String _uri) {
+        sourceURI = _uri;
     }
 
     /**
@@ -544,4 +562,4 @@
         return this.resourceType;
     }
 
-}
\ No newline at end of file
+}

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java Sun May 15 06:42:13 2005
@@ -15,8 +15,6 @@
  *
  */
 
-/* $Id$  */
-
 package org.apache.lenya.cms.publication;
 
 import java.io.File;
@@ -30,6 +28,7 @@
 
 /**
  * A CMS document.
+ * @version $Id$
  */
 public interface Document extends MetaDataOwner, Workflowable, Identifiable {
     
@@ -175,6 +174,12 @@
      * @return A string.
      */
     String getSourceURI();
+    
+    /**
+     * Setter for the URI to resolve the document's source.
+     * @param uri URI
+     */
+    void setSourceURI(String uri);
     
     /**
      * Accepts a document visitor.

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java Sun May 15 06:42:13 2005
@@ -16,12 +16,13 @@
  */
 package org.apache.lenya.cms.publication;
 
+import java.util.Map;
 import org.apache.lenya.cms.publication.util.DocumentSet;
 
 /**
  * Helper to manage documents. It takes care of workflow, attachments etc.
  * 
- * @version $Id:$
+ * @version $Id$
  */
 public interface DocumentManager {
 
@@ -59,10 +60,31 @@
 
     /**
      * Adds a document to the publication.
-     * @param document The document.
+     *
+     * @param parentDocument The parent document.
+     * @param newDocumentNodeName the name of the node representing the new document
+     * @param newDocumentId the id of the new document
+     * @param documentTypeName the document type (aka resource type) of the new document 
+     * @param language language of the new document
+     * @param navigationTitle navigation title
+     * @param initialContentsURI an URI from which initial contents for the new document can be read. Optional parameter; may be set to null, in which case the default initial sample will be used.
+     * @param nodeType the node type, as defined by the constants in NodeCreatorInterface
+     * @param parameters any parameters the caller needs to pass to the creator
+     * @param useSiteManager set to true if the site manager is used in the publication; if set the site manager will be notified about the new document
+     * @throws DocumentBuildException if the document can not be created
      * @throws PublicationException if the document is already contained.
      */
-    void add(Document document) throws PublicationException;
+    Document add(Document parentDocument, 
+                 String newDocumentNodeName,
+                 String newDocumentId, 
+                 String documentTypeName, 
+                 String language, 
+                 String navigationTitle,
+                 String initialContentsURI,
+                 short nodeType,
+                 Map parameters,
+                 boolean useSiteManager) 
+       throws DocumentBuildException, PublicationException;
 
     /**
      * Deletes a document.

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Sun May 15 06:42:13 2005
@@ -16,7 +16,9 @@
  */
 package org.apache.lenya.cms.publication;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -32,12 +34,16 @@
 import org.apache.excalibur.source.ModifiableSource;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.authoring.NodeCreatorInterface;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.metadata.LenyaMetaData;
 import org.apache.lenya.cms.publication.util.DocumentSet;
 import org.apache.lenya.cms.publication.util.DocumentVisitor;
 import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.SiteUtil;
 import org.apache.lenya.cms.workflow.WorkflowManager;
+import org.apache.lenya.transaction.Transactionable;
+import org.apache.lenya.transaction.TransactionException;
 
 /**
  * DocumentManager implementation.
@@ -48,10 +54,140 @@
         Serviceable, Contextualizable {
 
     /**
-     * @see org.apache.lenya.cms.publication.DocumentManager#add(org.apache.lenya.cms.publication.Document)
+     * The instance of Document will be built by the implementation of DocumentBuilder; the physical representation will be built by the implementation of NodeCreatorInterface, where the implementation to be used is specified in doctypes.xconf (and thus depends on the publication and the resource type to be used)
+     *
+     * @see DocumentManager#add(Document,String,String,String,String,String,String,short,Map,boolean)
+     * @see org.apache.lenya.cms.authoring.NodeCreatorInterface
+     * @see org.apache.lenya.cms.publication.DocumentBuilder
      */
-    public void add(Document document) throws PublicationException {
+    public Document add(Document parentDocument, 
+                        String newDocumentNodeName,
+                        String newDocumentId, 
+                        String documentTypeName, 
+                        String language, 
+                        String navigationTitle,
+                        String initialContentsURI,
+                        short nodeType,
+                        Map parameters,
+                        boolean useSiteManager) 
+            throws DocumentBuildException, PublicationException {
 
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("DocumentManagerImpl::add() called with:\n"
+               + "\t parentDocument.getId() [" + parentDocument.getId() + "]\n"
+               + "\t newDocumentNodeName [" + newDocumentNodeName + "]\n"
+               + "\t newDocumentId [" + newDocumentId + "]\n"
+               + "\t documentTypeName [" + documentTypeName + "]\n"
+               + "\t language [" + language + "]\n"
+               + "\t navigationTitle [" + navigationTitle + "]\n"
+               + "\t initialContentsURI [" + initialContentsURI + "]\n"
+               + "\t nodeType [" + nodeType + "]\n"
+               + "\t non-empty parameters [" + (parameters != null) + "]\n"
+               + "\t useSiteManager [" + useSiteManager + "]\n"
+               );
+
+        Publication publication = parentDocument.getPublication();
+        DocumentIdentityMap map = parentDocument.getIdentityMap();
+        String area = parentDocument.getArea();
+
+        /*
+         * Get an instance of Document.
+         * This will (ultimately) be created by the implementation for
+         * the DocumentBuilder role.
+         */
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("DocumentManagerImpl::add() creating Document instance");
+        Document newDocument = map.get(publication, area, newDocumentId, language);
+
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("DocumentManagerImpl::add() looking up a DocumentTypeBuilder so that we can call the creator");
+
+        // Get an instance of DocumentType
+        DocumentTypeBuilder documentTypeBuilder = null;
+        DocumentType documentType = null;
+        try {
+            documentTypeBuilder = (DocumentTypeBuilder) this.manager.lookup(DocumentTypeBuilder.ROLE);
+
+            documentType = documentTypeBuilder.buildDocumentType(documentTypeName, publication);
+        } 
+        catch (Exception e) {
+            throw new DocumentBuildException("could not build type for new document", e);
+        }
+        finally {
+            if (documentTypeBuilder != null) {
+                this.manager.release(documentTypeBuilder);
+            }
+        }
+
+        // Call the creator for the document type to physically create a document of this type
+        try {
+            String parentId = "";
+            if (parentDocument != null)
+                parentId = parentDocument.getId().substring(1);
+
+            if (initialContentsURI == null)
+                initialContentsURI = documentType.getSampleContentLocation();
+
+            if (getLogger().isDebugEnabled())
+                getLogger().debug("DocumentManagerImpl::add() using initialContentsURI [" + initialContentsURI + "]");
+
+            // look up creator for documents of this type
+            NodeCreatorInterface creator = documentType.getCreator();
+
+            // the concrete creator implementation decides
+            // where, relative to content base (and potentially to the parent
+            // as well), the new document shall be created
+            String contentBaseURI = publication.getContentURI(area);
+            String newDocumentURI = creator.getNewDocumentURI(contentBaseURI, parentDocument.getId(), newDocumentNodeName, language);
+
+            // Important note:
+            // how the new document's source URI is constructed is
+            // publication dependant; this is handled through the creator
+            // for that type in that publication.
+            // Therefore, we must ask the creator what this URI is
+            // and set it in the document. 
+            newDocument.setSourceURI(newDocumentURI);
+
+            // now that the source is determined, lock involved nodes
+            Transactionable[] nodes = newDocument.getRepositoryNodes();
+            for (int i = 0; i < nodes.length; i++) {
+                nodes[i].lock();
+	    }
+
+            //
+            creator.create(
+                initialContentsURI,
+                newDocumentURI,
+                newDocumentNodeName,
+                nodeType,
+                navigationTitle,
+                parameters);
+        } 
+        catch (Exception e) {
+            throw new DocumentBuildException("call to creator for new document failed", e);
+        }
+        finally {
+            if (documentTypeBuilder != null) {
+                this.manager.release(documentTypeBuilder);
+            }
+        }
+
+        // Write Lenya-internal meta-data
+        Map lenyaMetaData = new HashMap(2);
+        lenyaMetaData.put(LenyaMetaData.ELEMENT_RESOURCE_TYPE, documentTypeName);
+        lenyaMetaData.put(LenyaMetaData.ELEMENT_CONTENT_TYPE, "xml");
+        newDocument.getMetaDataManager().setLenyaMetaData(lenyaMetaData);
+
+        // Notify site manager about new document
+        if (useSiteManager)
+            addToSiteManager(newDocument, navigationTitle);
+
+        return newDocument;
+    }
+
+    private void addToSiteManager(Document document, String navigationTitle) 
+        throws PublicationException 
+    {
         Publication publication = document.getPublication();
         SiteManager siteManager = null;
         ServiceSelector selector = null;
@@ -60,10 +196,11 @@
             siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
             if (siteManager.contains(document)) {
                 throw new PublicationException("The document [" + document
-                        + "] is already contained in this publication!");
+                   + "] is already contained in this publication!");
             }
 
             siteManager.add(document);
+            siteManager.setLabel(document, navigationTitle);
         } catch (ServiceException e) {
             throw new PublicationException(e);
         } finally {

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java Sun May 15 06:42:13 2005
@@ -23,7 +23,7 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
 
-import org.apache.lenya.cms.authoring.ParentChildCreatorInterface;
+import org.apache.lenya.cms.authoring.NodeCreatorInterface;
 
 
 /**
@@ -84,21 +84,21 @@
 	}
     
     
-    private ParentChildCreatorInterface creator = null;
+    private NodeCreatorInterface creator = null;
 
-	/**
-	 * Get the creator for this document type.
-	 * @return a <code>ParentChildCreatorInterface</code>
-	 */
-    public ParentChildCreatorInterface getCreator() {
+    /**
+     * Get the creator for this document type.
+     * @return a <code>NodeCreatorInterface</code>
+     */
+    public NodeCreatorInterface getCreator() {
         return this.creator;
     }
 
-	/**
-	 * Set the creator
-	 * @param _creator a <code>ParentChildCreatorInterface</code>
-	 */
-    protected void setCreator(ParentChildCreatorInterface _creator) {
+    /**
+     * Set the creator
+     * @param _creator a <code>NodeCreatorInterface</code>
+     */
+    protected void setCreator(NodeCreatorInterface _creator) {
         assert _creator != null;
         this.creator = _creator;
     }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java Sun May 15 06:42:13 2005
@@ -32,7 +32,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.lenya.cms.authoring.DefaultBranchCreator;
-import org.apache.lenya.cms.authoring.ParentChildCreatorInterface;
+import org.apache.lenya.cms.authoring.NodeCreatorInterface;
 import org.xml.sax.SAXException;
 
 /**
@@ -175,13 +175,13 @@
                     type.setSchemaDefinition(schemaFileName);
                 }
 
-                ParentChildCreatorInterface creator;
+                NodeCreatorInterface creator;
                 Configuration creatorConf = doctypeConf.getChild(CREATOR_ELEMENT, false);
 
                 if (creatorConf != null) {
                     String creatorClassName = creatorConf.getAttribute(SRC_ATTRIBUTE);
                     Class creatorClass = Class.forName(creatorClassName);
-                    creator = (ParentChildCreatorInterface) creatorClass.newInstance();
+                    creator = (NodeCreatorInterface) creatorClass.newInstance();
                     creator.init(creatorConf, manager, getLogger());
                 } else {
                     creator = new DefaultBranchCreator();
@@ -356,4 +356,4 @@
         }
     }
 
-}
\ No newline at end of file
+}

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java Sun May 15 06:42:13 2005
@@ -16,36 +16,28 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
-import java.io.File;
 import java.text.SimpleDateFormat;
-import java.util.Collections;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
 import org.apache.lenya.ac.Identity;
 import org.apache.lenya.ac.User;
-import org.apache.lenya.cms.authoring.ParentChildCreatorInterface;
-import org.apache.lenya.cms.metadata.LenyaMetaData;
+import org.apache.lenya.cms.authoring.NodeCreatorInterface;
 import org.apache.lenya.cms.metadata.dublincore.DublinCore;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.cms.publication.DocumentIdentityMap;
 import org.apache.lenya.cms.publication.DocumentManager;
-import org.apache.lenya.cms.publication.DocumentType;
-import org.apache.lenya.cms.publication.DocumentTypeBuilder;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.publication.PublicationFactory;
 import org.apache.lenya.cms.publication.URLInformation;
 import org.apache.lenya.cms.site.SiteException;
-import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.SiteStructure;
 import org.apache.lenya.cms.site.SiteUtil;
 import org.apache.lenya.cms.usecase.AbstractUsecase;
@@ -111,120 +103,34 @@
     protected void doExecute() throws Exception {
         super.doExecute();
 
-        Document document = createDocument();
-
-        if (getLogger().isDebugEnabled())
-            getLogger().debug("Create.doExecute() got document instance, now notifying document manager");
-
+        // create new document
         DocumentManager documentManager = null;
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
+        Document newDocument = null;
         try {
-            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
-            documentManager.add(document);
-
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(document.getPublication()
-                    .getSiteManagerHint());
-            siteManager.setLabel(document, getParameterAsString(DublinCore.ELEMENT_TITLE));
-        } finally {
-            if (documentManager != null) {
-                this.manager.release(documentManager);
-            }
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
-        }
-
-        if (getLogger().isDebugEnabled())
-            getLogger().debug("Create.doExecute() done notifying document manager, now setting meta data");
-
-        setMetaData(document);
-
-        setTargetURL(document.getCanonicalWebappURL());
-    }
-
-    /**
-     * Creates a document.
-     * @return A document.
-     * @throws Exception if an error occurs.
-     */
-    protected Document createDocument() throws Exception {
-        if (getLogger().isDebugEnabled())
-            getLogger().debug("createDocument() called");
-
-        Document usecaseDocument = getSourceDocument();
-        String newDocumentId = getNewDocumentId();
-        String navigationTitle = getParameterAsString(DublinCore.ELEMENT_TITLE);
-        String documentTypeName = getDocumentTypeName();
-        String language = getParameterAsString(LANGUAGE);
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("createDocument() read parameters:");
-            getLogger().debug("    UsecaseDocument document:   [" + usecaseDocument.getId() + "]");
-            getLogger().debug("    Child document:    [" + newDocumentId + "]");
-            getLogger().debug("    Language:          [" + language + "]");
-            getLogger().debug("    Document Type:     [" + documentTypeName + "]");
-            getLogger().debug("    Navigation Title:  [" + navigationTitle + "]");
+           documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+           newDocument = 
+               documentManager.add(getParentDocument(),
+                                   getNewDocumentName(),
+                                   getNewDocumentId(),
+                                   getDocumentTypeName(),
+                                   getParameterAsString(LANGUAGE),
+                                   getParameterAsString(DublinCore.ELEMENT_TITLE),
+                                   getInitialContentsURI(),
+                                   NodeCreatorInterface.BRANCH_NODE,
+                                   null,
+                                   true);
         }
-
-        Publication publication = usecaseDocument.getPublication();
-        DocumentIdentityMap map = usecaseDocument.getIdentityMap();
-        String area = usecaseDocument.getArea();
-
-        /*
-         * Get an instance of Document.
-         * This will (ultimately) be created by the implementation for
-         * the DocumentBuilder role.
-         */
-        if (getLogger().isDebugEnabled())
-            getLogger().debug("createDocument() creating Document instance");
-        Document document = map.get(publication, area, newDocumentId, language);
-        Transactionable[] nodes = document.getRepositoryNodes();
-        for (int i = 0; i < nodes.length; i++) {
-            nodes[i].lock();
+        finally {
+           if (documentManager != null)
+               this.manager.release(documentManager);
         }
 
-        if (getLogger().isDebugEnabled())
-            getLogger().debug("createDocument() looking up a DocumentTypeBuilder so that we can call the creator");
-
-        /*
-         * Create an instance of DocumentType, and then
-         * use the creator for this DocumentType to actually
-         * physically create a document of this type.
-         */
-        DocumentTypeBuilder documentTypeBuilder = null;
-        DocumentType documentType = null;
-        try {
-            documentTypeBuilder = (DocumentTypeBuilder) this.manager.lookup(DocumentTypeBuilder.ROLE);
+        // set dublin core meta-data
+        setMetaData(newDocument);
 
-            documentType = documentTypeBuilder.buildDocumentType(documentTypeName, publication);
+        // the location to navigate to after completion of usecase
+        setTargetURL(newDocument.getCanonicalWebappURL());
 
-            String parentId = "";
-            Document parentDocument = getParentDocument();
-            if (parentDocument != null)
-                parentId = parentDocument.getId().substring(1);
-
-            ParentChildCreatorInterface creator = documentType.getCreator();
-            creator.create(
-                getInitialContentsURI(usecaseDocument, documentType),
-                new File(publication.getContentDirectory(area), parentId),
-                getNewDocumentName(),
-                ParentChildCreatorInterface.BRANCH_NODE,
-                navigationTitle,
-                language,
-                Collections.EMPTY_MAP);
-        } 
-        finally {
-            if (documentTypeBuilder != null) {
-                this.manager.release(documentTypeBuilder);
-            }
-        }
-
-        return document;
     }
 
 
@@ -246,15 +152,13 @@
     protected abstract Document getParentDocument() throws DocumentBuildException;
 
     /**
-     * If there is a reference document from which to copy contents, 
-     * pass this as parameter. If there is no such document, the document 
-     * type will be used instead to read a sample content.
+     * If the document created in the usecase shall have initial contents
+     * copied from an existing document, construct that document's URI 
+     * in this method. 
      *
-     * @param referenceDocument the document to use as reference for the initial contents
-     * @param type the type of resource to be created
-     * @return A URI.
+     * @return a URI.
      */
-    protected abstract String getInitialContentsURI(Document referenceDocument, DocumentType type);
+    protected abstract String getInitialContentsURI();
 
     /**
      * @return The type of the created document.
@@ -268,6 +172,9 @@
      */
     protected void setMetaData(Document document) throws DocumentException {
 
+        if (document == null)
+            throw new IllegalArgumentException("parameter document may not be null");
+
         Map dcMetaData = new HashMap();
         dcMetaData.put(DublinCore.ELEMENT_TITLE,
                 getParameterAsString(DublinCore.ELEMENT_TITLE));
@@ -284,11 +191,7 @@
         dcMetaData.put(DublinCore.ELEMENT_LANGUAGE, 
                 getParameterAsString(LANGUAGE));
 
-        Map lenyaMetaData = new HashMap(2);
-        lenyaMetaData.put(LenyaMetaData.ELEMENT_RESOURCE_TYPE, getDocumentTypeName());
-        lenyaMetaData.put(LenyaMetaData.ELEMENT_CONTENT_TYPE, "xml");
-
-        document.getMetaDataManager().setMetaData(dcMetaData, lenyaMetaData, null);
+        document.getMetaDataManager().setDublinCoreMetaData(dcMetaData);
     }
 
     /**
@@ -314,8 +217,7 @@
     }
 
     /**
-     * @return The source document or <code>null</code> if the usecase was not invoked on a
-     *         document.
+     * @return The source document or <code>null</code> if the usecase was not invoked on a document.
      */
     protected Document getSourceDocument() {
         Document document = null;

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateDocument.java Sun May 15 06:42:13 2005
@@ -19,7 +19,6 @@
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentManager;
-import org.apache.lenya.cms.publication.DocumentType;
 
 /**
  * Usecase to create a document.
@@ -97,11 +96,11 @@
     }
 
     /**
-     * New document: reference not relevant, use type sample
-     * @see Create#getInitialContentsURI(Document, DocumentType)
+     * New document: no existing document is referenced
+     * @see Create#getInitialContentsURI()
      */
-    protected String getInitialContentsURI(Document referenceDocument, DocumentType type) {
-        return type.getSampleContentLocation();
+    protected String getInitialContentsURI() {
+        return null;
     }
 
 

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java Sun May 15 06:42:13 2005
@@ -54,12 +54,12 @@
         }
 
         if (getNonExistingLanguages().isEmpty()) {
-            addErrorMessage("All language versions do already exist.");
+            addErrorMessage("All language versions already exist.");
         }
     }
 
     /**
-     * @return All non-existing language strings for the source document.
+     * @return All languages supported by the publication for which this document does not yet have a version
      * @throws DocumentBuildException if an error occurs.
      * @throws DocumentException if an error occurs.
      */
@@ -69,10 +69,11 @@
         String[] languages = source.getPublication().getLanguages();
         DocumentIdentityMap map = source.getIdentityMap();
         for (int i = 0; i < languages.length; i++) {
-            Document version = map.get(source.getPublication(),
-                    source.getArea(),
-                    source.getId(),
-                    languages[i]);
+            Document version = 
+                map.get(source.getPublication(),
+                        source.getArea(),
+                        source.getId(),
+                        languages[i]);
             if (!version.exists()) {
                 nonExistingLanguages.add(languages[i]);
             }
@@ -99,8 +100,7 @@
     }
 
     /**
-     * For new language version of a document, name is the same
-     * as that document's
+     * For new language version of a document, name is the same as that document's
      * @see Create#getNewDocumentName()
      */
     protected String getNewDocumentName() {
@@ -108,8 +108,7 @@
     }
 
     /**
-     * For new language version of a document, id is the same
-     * as that document's
+     * For new language version of a document, id is the same as that document's
      * @see Create#getNewDocumentId()
      */
     protected String getNewDocumentId() {
@@ -127,16 +126,15 @@
     }
 
     /**
-     * New language version of a document: 
-     * use that document's content
-     * @see Create#getInitialContentsURI(Document, DocumentType)
+     * New language version of a document: use that document's content
+     * @see Create#getInitialContentsURI()
      */
-    protected String getInitialContentsURI(Document referenceDocument, DocumentType type) {
-        return referenceDocument.getSourceURI();
+    protected String getInitialContentsURI() {
+        return getSourceDocument().getSourceURI();
     }
 
     /**
-     * @see org.apache.lenya.cms.site.usecases.Create#getDocumentTypeName()
+     * @see Create#getDocumentTypeName()
      */
     protected String getDocumentTypeName() {
         if (this.documentTypeName == null) {

Modified: lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java Sun May 15 06:42:13 2005
@@ -28,7 +28,6 @@
 import org.apache.lenya.ac.Identity;
 import org.apache.lenya.xml.DocumentHelper;
 
-import java.io.File;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Map;
@@ -61,25 +60,44 @@
         day = fmtdd.format(date);
 
         if (getLogger().isDebugEnabled())
-            getLogger().debug("NewBlogEntryCreator.init(): Initialize Creator: " + year + "/" + month + "/" + day);
+            getLogger().debug("NewBlogEntryCreator.init(): " + year + "/" + month + "/" + day);
     }
 
     /**
-     *
+     * Implementation note: ignores parentId; blog has a specific site structure, not depending on parent
+     * 
+     * @see org.apache.lenya.cms.authoring.NodeCreatorInterface#getNewDocumentURI(String, String, String, String)
      */
-    protected String getChildFileName(File parentDir, String childId, String language) {
-        String newFilename = parentDir + File.separator + "entries" + File.separator + year + File.separator + month + File.separator + day + File.separator + childId + File.separator + "index.xml";
-
-        if (getLogger().isDebugEnabled())
-            getLogger().debug("NewBlogEntryCreator.getChildFileName(): " + newFilename);
-
-        return newFilename;
+    public String getNewDocumentURI(
+        String contentBaseURI,
+        String parentId,
+        String newId,
+        String language) {
+        return
+           contentBaseURI
+           + "/" 
+           + "entries" 
+           + "/" 
+           + year 
+           + "/" 
+           + month 
+           + "/" 
+           + day 
+           + "/" 
+           + newId 
+           + "/" 
+           + "index.xml";
     }
 
     /**
      *
      */
     protected void transformXML(Document doc, String childId, short childType, String childName, Map parameters) throws Exception {
+
+       // sanity check: blog entry creation depends on certain parameters
+       if (parameters == null)
+           throw new IllegalArgumentException("parameters may not be null for blog entry creation");
+
        Element parent = doc.getDocumentElement();
 
        if (getLogger().isDebugEnabled())

Modified: lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java?rev=170220&r1=170219&r2=170220&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java Sun May 15 06:42:13 2005
@@ -27,9 +27,10 @@
 
 import org.apache.lenya.ac.Identity;
 
-import org.apache.lenya.cms.authoring.ParentChildCreatorInterface;
+import org.apache.lenya.cms.authoring.NodeCreatorInterface;
 import org.apache.lenya.cms.metadata.dublincore.DublinCore;
 import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.DocumentType;
 import org.apache.lenya.cms.publication.DocumentTypeBuilder;
 import org.apache.lenya.cms.publication.Publication;
@@ -75,69 +76,54 @@
         super.doCheckExecutionConditions();
     }
 
-    protected String getNewDocumentName() {
-        return getParameterAsString(DOCUMENT_ID);
-    }
-
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+     */
     protected void doExecute() throws Exception {
         super.doExecute();
 
+        // prepare values necessary for blog entry creation
+        String documentId = "/" + getNewDocumentName();
         Document parent = getSourceDocument();
-
+        String language = parent.getPublication().getDefaultLanguage();
         Map objectModel = ContextHelper.getObjectModel(getContext());
         Request request = ObjectModelHelper.getRequest(objectModel);
         Session session = request.getSession(false);
-
-        String documentId = "/" + getNewDocumentName();
-        String title = getParameterAsString(DublinCore.ELEMENT_TITLE);
-        String documentTypeName = getDocumentTypeName();
-
-        Publication publication = parent.getPublication();
-        String language = publication.getDefaultLanguage();
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Creating document");
-            getLogger().debug("    Parent document:   [" + parent.getId() + "]");
-            getLogger().debug("    Child document:    [" + documentId + "]");
-            getLogger().debug("    Language:          [" + language + "]");
-            getLogger().debug("    Document Type:     [" + documentTypeName + "]");
-            getLogger().debug("    Title:             [" + title + "]");
-        }
-
-        String area = parent.getArea();
-        Document document = parent.getIdentityMap().get(parent.getPublication(),
-                area,
-                documentId,
-                language);
-
-        // create an instance of DocumentType
-        DocumentTypeBuilder documentTypeBuilder = null;
-        DocumentType documentType = null;
+        HashMap allParameters = new HashMap();
+        allParameters.put(Identity.class.getName(), session.getAttribute(Identity.class.getName()));
+        allParameters.put("title", getParameterAsString(DublinCore.ELEMENT_TITLE));
+
+        // create new document
+        // implementation note: since blog does not have a hierarchy,
+        // document id (full path) and document id-name (this leaf's id)
+        // are the same
+        DocumentManager documentManager = null;
+        Document newDocument = null;
         try {
-            documentTypeBuilder = (DocumentTypeBuilder) this.manager.lookup(DocumentTypeBuilder.ROLE);
-
-            documentType = documentTypeBuilder.buildDocumentType(documentTypeName, publication);
-
-            HashMap allParameters = new HashMap();
-            allParameters.put(Identity.class.getName(), session.getAttribute(Identity.class.getName()));
-            allParameters.put("title", title);
-
-            documentType.getCreator().create(
-                documentType.getSampleContentLocation(),
-                new File(publication.getContentDirectory(area), ""),
-                documentId,
-                ParentChildCreatorInterface.LEAF_NODE,
-                title,
-                language,
-                allParameters);
-        } 
+            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+            newDocument = 
+                documentManager.add(parent,
+                                    documentId,
+                                    documentId,
+                                    getDocumentTypeName(),
+                                    language,
+                                    getParameterAsString(DublinCore.ELEMENT_TITLE),
+                                    null,
+                                    NodeCreatorInterface.LEAF_NODE,
+                                    allParameters,
+                                    false);
+        }
         finally {
-            if (documentTypeBuilder != null) {
-                this.manager.release(documentTypeBuilder);
-            }
+            if (documentManager != null)
+                this.manager.release(documentManager);
         }
+    }
 
-
+    /**
+     * @see org.apache.lenya.cms.site.usecases.Create#getNewDocumentName()
+     */
+    protected String getNewDocumentName() {
+        return getParameterAsString(DOCUMENT_ID);
     }
 
     /**



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