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/03/09 17:56:02 UTC

svn commit: r384556 - in /lenya/trunk/src: java/org/apache/lenya/cms/editors/kupu/ java/org/apache/lenya/cms/metadata/ java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/site/usecases/ modules/opendocument/ modules/opendocument/java/src/o...

Author: andreas
Date: Thu Mar  9 08:56:01 2006
New Revision: 384556

URL: http://svn.apache.org/viewcvs?rev=384556&view=rev
Log:
Add extension attribute to LenyaMetaData. This way, the extension can be accessed by the DocumentIdToPathMapper - this allows custom source extensions (like .odt, ...) and is a first step towards handling assets and documents in the same way.

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/editors/kupu/Kupu.java
    lenya/trunk/src/java/org/apache/lenya/cms/metadata/LenyaMetaData.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.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/IdentityDocumentIdToPathMapper.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
    lenya/trunk/src/modules/opendocument/java/src/org/apache/lenya/cms/site/usecases/CreateOpenDocument.java
    lenya/trunk/src/modules/opendocument/sitemap.xmap
    lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java
    lenya/trunk/src/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java
    lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/webdav/Put.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/editors/kupu/Kupu.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/editors/kupu/Kupu.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/editors/kupu/Kupu.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/editors/kupu/Kupu.java Thu Mar  9 08:56:01 2006
@@ -46,7 +46,9 @@
 
             Document doc = getSourceDocument();
             DocumentIdToPathMapper mapper = doc.getPublication().getPathMapper();
-            String path = mapper.getPath(doc.getId(), getSourceDocument().getLanguage());
+            String path = mapper.getPath(doc.getId(),
+                    getSourceDocument().getLanguage(),
+                    getSourceDocument().getSourceExtension());
             String sourceUri = doc.getSourceURI();
             String pubId = doc.getPublication().getId();
             String tempSourceUri = "context://lenya/pubs/" + pubId + "/work/bxe/content/"
@@ -68,6 +70,7 @@
             }
         }
     }
+
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
      */
@@ -83,7 +86,6 @@
         }
     }
 
-
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
      */
@@ -95,5 +97,5 @@
     protected String getEvent() {
         return "edit";
     }
-    
+
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/metadata/LenyaMetaData.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/metadata/LenyaMetaData.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/metadata/LenyaMetaData.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/LenyaMetaData.java Thu Mar  9 08:56:01 2006
@@ -47,6 +47,11 @@
      * be used e.g. to provide an appropriate management interface.
      */
     public static final String ELEMENT_CONTENT_TYPE = "contentType";
+    
+    /**
+     * The extension to use for the document source.
+     */
+    public static final String ELEMENT_EXTENSION = "extension";
 
     /**
      * A workflow version.
@@ -69,7 +74,8 @@
        ELEMENT_WORKFLOW_VERSION,
        ELEMENT_PLACEHOLDER,
        ELEMENTE_HEIGHT,
-       ELEMENT_WIDTH
+       ELEMENT_WIDTH,
+       ELEMENT_EXTENSION
     };
 
     /**

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=384556&r1=384555&r2=384556&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 Thu Mar  9 08:56:01 2006
@@ -115,7 +115,8 @@
         return getPublication().getPathMapper().getFile(getPublication(),
                 getArea(),
                 getId(),
-                getLanguage());
+                getLanguage(),
+                getSourceExtension());
     }
 
     /**
@@ -190,6 +191,20 @@
         return this.extension;
     }
 
+    public String getSourceExtension() {
+        String extension;
+        try {
+            extension = getMetaDataManager().getLenyaMetaData()
+                    .getFirstValue(LenyaMetaData.ELEMENT_EXTENSION);
+        } catch (DocumentException e) {
+            throw new RuntimeException(e);
+        }
+        if (extension == null) {
+            extension = "xml";
+        }
+        return extension;
+    }
+
     /**
      * Sets the extension of the file in the URL.
      * @param _extension A string.
@@ -260,7 +275,7 @@
         }
         return exists;
     }
-    
+
     protected DocumentIdentifier getIdentifier() {
         return this.identifier;
     }
@@ -331,7 +346,9 @@
             RepositorySource source = null;
             try {
                 resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-                source = (RepositorySource) resolver.resolveURI(getSourceURI());
+                String sourceUri = getPublication().getSourceURI() + "/content/" + getArea()
+                        + getId() + "/index_" + getLanguage() + ".xml";
+                source = (RepositorySource) resolver.resolveURI(sourceUri);
                 this.metaDataManager = source.getNode().getMetaDataManager();
             } catch (Exception e) {
                 throw new RuntimeException(e);
@@ -373,7 +390,9 @@
      * @return A URI.
      */
     private String getDefaultSourceURI() {
-        String path = getPublication().getPathMapper().getPath(getId(), getLanguage());
+        String path = getPublication().getPathMapper().getPath(getId(),
+                getLanguage(),
+                getSourceExtension());
         return getPublication().getSourceURI() + "/content/" + getArea() + "/" + path;
 
     }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java Thu Mar  9 08:56:01 2006
@@ -24,71 +24,67 @@
  * 
  * @version $Id$
  */
-public class DefaultDocumentIdToPathMapper
-    implements DocumentIdToPathMapper, PathToDocumentIdMapper {
-    	
+public class DefaultDocumentIdToPathMapper implements DocumentIdToPathMapper,
+        PathToDocumentIdMapper {
+
     /**
      * The file name.
      */
     public static final String BASE_FILENAME_PREFIX = "index";
-    
-    /**
-     * The file extension.
-     */
-    public static final String BASE_FILENAME_SUFFIX = ".xml";
 
     /**
-	 * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFile(org.apache.lenya.cms.publication.Publication,
-	 *      java.lang.String, java.lang.String, java.lang.String)
-	 */
-    public File getFile(Publication publication, String area, String documentId, String language) {
-        File file = new File(getDirectory(publication, area, documentId), getFilename(language));
+     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFile(org.apache.lenya.cms.publication.Publication,
+     *      java.lang.String, java.lang.String, java.lang.String, String)
+     */
+    public File getFile(Publication publication, String area, String documentId, String language,
+            String extension) {
+        File file = new File(getDirectory(publication, area, documentId), getFilename(language,
+                extension));
         return file;
     }
 
     /**
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication,
-	 *      java.lang.String, java.lang.String)
-	 */
+     * (non-Javadoc)
+     * 
+     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication,
+     *      java.lang.String, java.lang.String)
+     */
     public File getDirectory(Publication publication, String area, String documentId) {
         assert documentId.startsWith("/");
         // remove leading slash
         documentId = documentId.substring(1);
         documentId = documentId.replace('/', File.separatorChar);
 
-        File file =
-            new File(
-                publication.getDirectory(),
-                Publication.CONTENT_PATH + File.separator + area + File.separator + documentId);
+        File file = new File(publication.getDirectory(), Publication.CONTENT_PATH + File.separator
+                + area + File.separator + documentId);
 
         return file;
     }
 
     /**
-	 * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getPath(java.lang.String,
-	 *      java.lang.String)
-	 */
-    public String getPath(String documentId, String language) {
+     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getPath(java.lang.String,
+     *      java.lang.String, String)
+     */
+    public String getPath(String documentId, String language, String extension) {
         assert documentId.startsWith("/");
         // remove leading slash
         documentId = documentId.substring(1);
-        return documentId + "/" + getFilename(language);
+        return documentId + "/" + getFilename(language, extension);
     }
 
     /**
-	 * Constructs the filename for a given language.
-	 * 
-	 * @param language The language.
-	 * @return A string value.
-	 */
-    protected String getFilename(String language) {
+     * Constructs the filename for a given language.
+     * 
+     * @param language The language.
+     * @param extension The extension.
+     * @return A string value.
+     */
+    protected String getFilename(String language, String extension) {
         String languageSuffix = "";
         if (language != null && !"".equals(language)) {
             languageSuffix = "_" + language;
         }
-        return BASE_FILENAME_PREFIX + languageSuffix + BASE_FILENAME_SUFFIX;
+        return BASE_FILENAME_PREFIX + languageSuffix + "." + extension;
     }
 
     /**
@@ -97,55 +93,46 @@
      * @param area The area.
      * @param file The file representing the document.
      * @return A string.
-     * @throws DocumentDoesNotExistException when the document
-     * referenced by the file does not exist.
+     * @throws DocumentDoesNotExistException when the document referenced by the file does not
+     *             exist.
      */
-    public String getDocumentId(
-        Publication publication,
-        String area,
-        File file)
-        throws DocumentDoesNotExistException {
+    public String getDocumentId(Publication publication, String area, File file)
+            throws DocumentDoesNotExistException {
 
         String fileName = file.getAbsolutePath();
-        String contentDirName =
-            publication.getContentDirectory(area).getAbsolutePath();
+        String contentDirName = publication.getContentDirectory(area).getAbsolutePath();
         if (fileName.startsWith(contentDirName)) {
             // trim everything up to the documentId
-            String relativeFileName =
-                fileName.substring(contentDirName.length());
+            String relativeFileName = fileName.substring(contentDirName.length());
             // trim everything after the documentId
-            relativeFileName =
-                relativeFileName.substring(
-                    0,
+            relativeFileName = relativeFileName.substring(0,
                     relativeFileName.lastIndexOf(File.separator));
             // and replace the os specific separator by '/'
             return relativeFileName.replace(File.separatorChar, '/');
         }
         // Document does not seem to exist
-        throw new DocumentDoesNotExistException(
-            "No document associated with file" + fileName);
+        throw new DocumentDoesNotExistException("No document associated with file" + fileName);
     }
-    
+
     /**
      * Returns the language for a certain file
      * 
      * @param file the document file
      * 
-     * @return the language for the given document file or null if
-     * the file has no language.
+     * @return the language for the given document file or null if the file has no language.
      */
     public String getLanguage(File file) {
         String fileName = file.getName();
         String language = null;
 
+        int lastDotIndex = fileName.lastIndexOf(".");
+        String suffix = fileName.substring(lastDotIndex);
+
         // check if the file is of the form index.html or index_en.html
 
-        if (fileName.startsWith(BASE_FILENAME_PREFIX)
-            && fileName.endsWith(BASE_FILENAME_SUFFIX)) {
-            String languageSuffix =
-                fileName.substring(
-                    BASE_FILENAME_PREFIX.length(),
-                    fileName.indexOf(BASE_FILENAME_SUFFIX));
+        if (fileName.startsWith(BASE_FILENAME_PREFIX) && fileName.endsWith(suffix)) {
+            String languageSuffix = fileName.substring(BASE_FILENAME_PREFIX.length(),
+                    fileName.indexOf(suffix));
             if (languageSuffix.length() > 0) {
                 // trim the leading '_'
                 language = languageSuffix.substring(1);

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=384556&r1=384555&r2=384556&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 Thu Mar  9 08:56:01 2006
@@ -197,4 +197,9 @@
      * @throws DocumentException if an error occurs.
      */
     ResourceType getResourceType() throws DocumentException;
+    
+    /**
+     * @return The source extension used by this document.
+     */
+    String getSourceExtension();
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java Thu Mar  9 08:56:01 2006
@@ -25,43 +25,43 @@
  * Document Id to Path mapper interface
  */
 public interface DocumentIdToPathMapper {
-    
+
     /**
-     * Compute the document-path for a given publication, area
-     * and document-id. The file separator is the slash (/).
-     *
+     * Compute the document-path for a given publication, area and document-id. The file separator
+     * is the slash (/).
+     * 
      * @param documentId the document-id of the document
      * @param language the language of the document
+     * @param extension The source extension.
      * 
      * @return the path to the document, without publication ID and area
      */
-    String getPath(String documentId, String language);
+    String getPath(String documentId, String language, String extension);
 
     /**
-     * Compute the document-path for a given publication, area, 
-     * document-id and language
-     *
+     * Compute the document-path for a given publication, area, document-id and language
+     * 
      * @param publication the publication of the document
      * @param area the area of the document
      * @param documentId the document-id of the document
      * @param language the language of the document
+     * @param extension The source extension.
      * 
      * @return the path to the document
      */
-    File getFile(Publication publication, String area, String documentId,
-        String language);
+    File getFile(Publication publication, String area, String documentId, String language,
+            String extension);
 
     /**
-     * Compute the document-path for a given publication, area and 
-     * document-id. As there are possibly multiple files for the same 
-     * document-id (for different languages) the return value is a directory.
-     *  
+     * Compute the document-path for a given publication, area and document-id. As there are
+     * possibly multiple files for the same document-id (for different languages) the return value
+     * is a directory.
+     * 
      * @param publication The publication.
      * @param area The area.
      * @param documentId The document id.
      * 
-     * @return The directory where all the files with the same 
-     * document-id are located
+     * @return The directory where all the files with the same document-id are located
      */
     File getDirectory(Publication publication, String area, String documentId);
 }

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=384556&r1=384555&r2=384556&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 Thu Mar  9 08:56:01 2006
@@ -74,6 +74,7 @@
      * 
      * @param document The document to add.
      * @param resourceType the document type (aka resource type) of the new document
+     * @param extension The extension to use for the document source.
      * @param navigationTitle navigation title
      * @param visibleInNav determines the visibility of a node in the navigation
      * @param parameters any parameters the caller needs to pass to the creator
@@ -83,6 +84,7 @@
      */
     void add(Document document,
             ResourceType resourceType,
+            String extension,
             String navigationTitle,
             boolean visibleInNav,
             Map parameters) throws DocumentBuildException, PublicationException;
@@ -93,6 +95,7 @@
      * 
      * @param document The document to add.
      * @param sourceDocument The document to initialize the contents and meta data from.
+     * @param extension The extension to use for the document source.
      * @param navigationTitle navigation title
      * @param visibleInNav determines the visibility of a node in the navigation
      * @param parameters any parameters the caller needs to pass to the creator
@@ -102,6 +105,7 @@
      */
     void add(Document document,
             Document sourceDocument,
+            String extension,
             String navigationTitle,
             boolean visibleInNav,
             Map parameters) throws DocumentBuildException, PublicationException;

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=384556&r1=384555&r2=384556&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 Thu Mar  9 08:56:01 2006
@@ -51,28 +51,34 @@
      * 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, ResourceType, String, boolean, Map)
+     * @see DocumentManager#add(Document, ResourceType, String, String, boolean, Map)
      * @see org.apache.lenya.cms.authoring.NodeCreatorInterface
      * @see org.apache.lenya.cms.publication.DocumentBuilder
      */
-    public void add(Document document, ResourceType documentType, String navigationTitle,
-            boolean visibleInNav, 
-            Map parameters) throws DocumentBuildException, PublicationException {
+    public void add(Document document, ResourceType documentType, String extension,
+            String navigationTitle, boolean visibleInNav, Map parameters)
+            throws DocumentBuildException, PublicationException {
 
         String contentsURI = documentType.getSampleURI();
-        add(document, documentType, navigationTitle, visibleInNav, parameters, contentsURI);
+        add(document, documentType, extension, navigationTitle, visibleInNav, parameters, contentsURI);
     }
 
     /**
      * @see org.apache.lenya.cms.publication.DocumentManager#add(org.apache.lenya.cms.publication.Document,
-     *      org.apache.lenya.cms.publication.Document, java.lang.String, boolean, 
+     *      org.apache.lenya.cms.publication.Document, String, java.lang.String, boolean,
      *      java.util.Map)
      */
-    public void add(Document document, Document sourceDocument, String navigationTitle,
-            boolean visibleInNav,
-            Map parameters) throws DocumentBuildException, PublicationException {
+    public void add(Document document, Document sourceDocument, String extension,
+            String navigationTitle, boolean visibleInNav, Map parameters)
+            throws DocumentBuildException, PublicationException {
         String contentsURI = sourceDocument.getSourceURI();
-        add(document, sourceDocument.getResourceType(), navigationTitle, visibleInNav, parameters, contentsURI);
+        add(document,
+                sourceDocument.getResourceType(),
+                extension,
+                navigationTitle,
+                visibleInNav,
+                parameters,
+                contentsURI);
         MetaDataManager mgr = document.getMetaDataManager();
         MetaDataManager srcMgr = sourceDocument.getMetaDataManager();
         mgr.getLenyaMetaData().replaceBy(srcMgr.getLenyaMetaData());
@@ -84,6 +90,7 @@
      * Adds a document.
      * @param document The document.
      * @param documentType The document type.
+     * @param extension The extension for the document source.
      * @param navigationTitle The navigation title.
      * @param visibleInNav determines the visibility of a node in the navigation
      * @param parameters The parameters for the creator.
@@ -93,9 +100,9 @@
      * @throws PublicationException if an error occurs.
      */
 
-    protected void add(Document document, ResourceType documentType, String navigationTitle,
-            boolean visibleInNav, Map parameters, String initialContentsURI) throws DocumentBuildException,
-            DocumentException, PublicationException {
+    protected void add(Document document, ResourceType documentType, String extension, String navigationTitle,
+            boolean visibleInNav, Map parameters, String initialContentsURI)
+            throws DocumentBuildException, DocumentException, PublicationException {
 
         try {
 
@@ -123,6 +130,7 @@
         Map lenyaMetaData = new HashMap(2);
         lenyaMetaData.put(LenyaMetaData.ELEMENT_RESOURCE_TYPE, documentType.getName());
         lenyaMetaData.put(LenyaMetaData.ELEMENT_CONTENT_TYPE, "xml");
+        lenyaMetaData.put(LenyaMetaData.ELEMENT_EXTENSION, extension);
         document.getMetaDataManager().setLenyaMetaData(lenyaMetaData);
 
         // Notify site manager about new document
@@ -192,10 +200,10 @@
             }
         }
     }
-    
+
     /**
-     * Method to copy a document without it's resources. Override {@link #copyDocumentSource(Document, Document)}
-     * to implement access to a custom repository.
+     * Method to copy a document without it's resources. Override
+     * {@link #copyDocumentSource(Document, Document)} to implement access to a custom repository.
      * @see org.apache.lenya.cms.publication.DocumentManager#copy(org.apache.lenya.cms.publication.Document,
      *      org.apache.lenya.cms.publication.Document)
      */
@@ -397,7 +405,8 @@
         RepositoryManager repoManager = null;
         try {
             repoManager = (RepositoryManager) this.manager.lookup(RepositoryManager.ROLE);
-            repoManager.copy(sourceDocument.getRepositoryNode(), destinationDocument.getRepositoryNode());
+            repoManager.copy(sourceDocument.getRepositoryNode(),
+                    destinationDocument.getRepositoryNode());
         } catch (Exception e) {
             throw new PublicationException(e);
         } finally {

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java Thu Mar  9 08:56:01 2006
@@ -27,43 +27,48 @@
 public class IdentityDocumentIdToPathMapper implements DocumentIdToPathMapper {
 
     /**
-     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFile(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String, java.lang.String)
+     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFile(org.apache.lenya.cms.publication.Publication,
+     *      java.lang.String, java.lang.String, java.lang.String, String)
      */
-    public File getFile(Publication publication, String area, String documentId, String language) {
-        File areaDirectory =
-            new File(publication.getDirectory(), Publication.CONTENT_PATH + File.separator + area);
-        File file = new File(areaDirectory, getPath(documentId, language));
+    public File getFile(Publication publication, String area, String documentId, String language,
+            String extension) {
+        File areaDirectory = new File(publication.getDirectory(), Publication.CONTENT_PATH
+                + File.separator + area);
+        File file = new File(areaDirectory, getPath(documentId, language, extension));
         return file;
     }
 
     /**
-     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String)
+     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication,
+     *      java.lang.String, java.lang.String)
      */
     public File getDirectory(Publication publication, String area, String documentId) {
-        return getFile(publication, area, documentId, null).getParentFile();
+        return getFile(publication, area, documentId, null, null).getParentFile();
     }
 
     /**
-     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getPath(java.lang.String, java.lang.String)
+     * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getPath(java.lang.String,
+     *      java.lang.String, String)
      */
-    public String getPath(String documentId, String language) {
+    public String getPath(String documentId, String language, String extension) {
         assert documentId.startsWith("/");
         // remove leading slash
         documentId = documentId.substring(1);
-        return documentId + getSuffix(language);
+        return documentId + getSuffix(language, extension);
     }
 
     /**
      * Constructs the filename for a given language.
      * @param language The language.
+     * @param extension The extension.
      * @return A string value.
      */
-    protected String getSuffix(String language) {
+    protected String getSuffix(String language, String extension) {
         String languageSuffix = "";
         if (language != null && !"".equals(language)) {
             languageSuffix = "_" + language;
         }
-        return languageSuffix + ".xml";
+        return languageSuffix + "." + extension;
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Thu Mar  9 08:56:01 2006
@@ -201,22 +201,13 @@
      */
     public Publication getPublication() {
         /*
-        if (this.publication == null) {
-            try {
-                Publication pub = PublicationManagerImpl.getInstance(new ConsoleLogger())
-                        .getPublication(this.webappUrl, this.servletContext);
-                if (pub.exists()) {
-                    this.publication = pub;
-                    if (getIdentityMap().isDocument(this.webappUrl)) {
-                        Document _document = getIdentityMap().getFromURL(this.webappUrl);
-                        setDocument(_document);
-                    }
-                }
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        }
-        */
+         * if (this.publication == null) { try { Publication pub =
+         * PublicationManagerImpl.getInstance(new ConsoleLogger()) .getPublication(this.webappUrl,
+         * this.servletContext); if (pub.exists()) { this.publication = pub; if
+         * (getIdentityMap().isDocument(this.webappUrl)) { Document _document =
+         * getIdentityMap().getFromURL(this.webappUrl); setDocument(_document); } } } catch
+         * (Exception e) { throw new RuntimeException(e); } }
+         */
         return this.publication;
     }
 
@@ -254,8 +245,9 @@
      * @return a <code>File<code> value
      */
     public String getDocumentPath() {
-        return getPublication().getPathMapper().getPath(getDocument().getId(),
-                getDocument().getLanguage());
+            return getPublication().getPathMapper().getPath(getDocument().getId(),
+                    getDocument().getLanguage(),
+                    getDocument().getSourceExtension());
     }
 
     /**

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=384556&r1=384555&r2=384556&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 Thu Mar  9 08:56:01 2006
@@ -55,329 +55,322 @@
  */
 public abstract class Create extends AbstractUsecase {
 
-  protected static final String RESOURCE_TYPES = "resourceTypes";
+    protected static final String RESOURCE_TYPES = "resourceTypes";
 
-  protected static final String LANGUAGE = "language";
+    protected static final String LANGUAGE = "language";
 
-  protected static final String LANGUAGES = "languages";
+    protected static final String LANGUAGES = "languages";
 
-  protected static final String DOCUMENT_ID = "documentId";
+    protected static final String DOCUMENT_ID = "documentId";
 
-  protected static final String VISIBLEINNAV = "visibleInNav";
-
-  protected static final String SAMPLE = "sample";
-
-  protected static final String SAMPLES = "samples";
-
-  /**
-   * Ctor.
-   */
-  public Create() {
-    super();
-  }
-
-  /**
-   * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
-   */
-  protected void doCheckPreconditions() throws Exception {
-    super.doCheckPreconditions();
-
-    if (!getArea().equals(Publication.AUTHORING_AREA)) {
-      addErrorMessage("This usecase can only be invoked in the authoring area!");
-    }
-  }
-
-  /**
-   * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
-   */
-  protected Node[] getNodesToLock() throws UsecaseException {
-    try {
-      SiteStructure structure = SiteUtil.getSiteStructure(this.manager,
-          getSourceDocument());
-      Node[] nodes = { structure.getRepositoryNode() };
-      return nodes;
-    } catch (SiteException e) {
-      throw new UsecaseException(e);
-    }
-  }
-
-  /**
-   * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
-   */
-  protected void doCheckExecutionConditions() throws Exception {
-    String navigationTitle = getParameterAsString(DublinCore.ELEMENT_TITLE);
-    if (navigationTitle.equals("")) {
-      addErrorMessage("The navigation title is required.");
-    }
-
-    if (getInitialDocument() == null) {
-      List samples = (List) getParameter(SAMPLES);
-      String sample = getParameterAsString(SAMPLE);
-      if (samples != null && samples.size() > 1
-          && (sample == null || sample.equals(""))) {
-        addErrorMessage("Please select a page layout.");
-      }
-    }
-
-    String doctypeName = getDocumentTypeName();
-    if (doctypeName != null) {
-      initSampleParameters();
-    }
-  }
-
-  /**
-   * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
-   */
-  protected void doExecute() throws Exception {
-    super.doExecute();
-
-    // create new document
-    DocumentManager documentManager = null;
-    ServiceSelector selector = null;
-    ResourceType resourceType = null;
-    try {
-
-      documentManager = (DocumentManager) this.manager
-          .lookup(DocumentManager.ROLE);
-
-      DocumentIdentityMap map = getDocumentIdentityMap();
-      Document document = map.get(getPublication(), getArea(),
-          getNewDocumentId(), getParameterAsString(LANGUAGE));
-
-      Document initialDocument = getInitialDocument();
-      if (initialDocument == null) {
-        selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE
-            + "Selector");
-        resourceType = (ResourceType) selector.select(getDocumentTypeName());
-        if (getParameterAsString(SAMPLE) != null
-            && getParameterAsString(SAMPLE).length() > 0)
-          resourceType.setSampleURI(getParameterAsString(SAMPLE));
-        documentManager.add(document, resourceType,
-            getParameterAsString(DublinCore.ELEMENT_TITLE), getVisibleInNav(),
-            null);
-        resourceType.setSampleURI(""); // reset to default sample
-      } else {
-        documentManager.add(document, initialDocument,
-            getParameterAsString(DublinCore.ELEMENT_TITLE), getVisibleInNav(),
-            null);
-      }
-
-      setMetaData(document);
-
-      // the location to navigate to after completion of usecase
-      setTargetURL(document.getCanonicalWebappURL());
-
-    } finally {
-      if (documentManager != null) {
-        this.manager.release(documentManager);
-      }
-      if (selector != null) {
-        if (resourceType != null) {
-          selector.release(resourceType);
-        }
-        this.manager.release(selector);
-      }
-    }
-
-  }
-
-  /**
-   * @return the name of the document being created in the usecase
-   */
-  protected abstract String getNewDocumentName();
-
-  /**
-   * @return the id of the new document being created in the usecase
-   */
-  protected abstract String getNewDocumentId();
-
-  /**
-   * If the document created in the usecase shall have initial contents copied
-   * from an existing document, construct that document in this method.
-   * 
-   * @return A document.
-   */
-  protected Document getInitialDocument() {
-    return null;
-  }
-
-  /**
-   * @return The type of the created document.
-   */
-  protected abstract String getDocumentTypeName();
-
-  /**
-   * Sets the meta data of the created document.
-   * 
-   * @param document
-   *          The document.
-   * @throws DocumentException
-   *           if an error occurs.
-   */
-  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));
-    dcMetaData.put(DublinCore.ELEMENT_CREATOR,
-        getParameterAsString(DublinCore.ELEMENT_CREATOR));
-    dcMetaData.put(DublinCore.ELEMENT_PUBLISHER,
-        getParameterAsString(DublinCore.ELEMENT_PUBLISHER));
-    dcMetaData.put(DublinCore.ELEMENT_SUBJECT,
-        getParameterAsString(DublinCore.ELEMENT_SUBJECT));
-    dcMetaData.put(DublinCore.ELEMENT_DATE,
-        getParameterAsString(DublinCore.ELEMENT_DATE));
-    dcMetaData.put(DublinCore.ELEMENT_RIGHTS,
-        getParameterAsString(DublinCore.ELEMENT_RIGHTS));
-    dcMetaData.put(DublinCore.ELEMENT_LANGUAGE, getParameterAsString(LANGUAGE));
-
-    document.getMetaDataManager().setDublinCoreMetaData(dcMetaData);
-  }
-
-  /**
-   * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
-   */
-  protected void initParameters() {
-    super.initParameters();
-
-    Map objectModel = ContextHelper.getObjectModel(getContext());
-    Request request = ObjectModelHelper.getRequest(objectModel);
-    Session session = request.getSession(false);
-    Identity identity = (Identity) session.getAttribute(Identity.class
-        .getName());
-    User user = identity.getUser();
-    if (user != null) {
-      setParameter(DublinCore.ELEMENT_CREATOR, user.getId());
-    } else {
-      setParameter(DublinCore.ELEMENT_CREATOR, "");
-    }
-
-    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    setParameter(DublinCore.ELEMENT_DATE, format.format(new GregorianCalendar()
-        .getTime()));
-
-    String doctypeName = getDocumentTypeName();
-    if (doctypeName != null) {
-      initSampleParameters();
-      setParameter(RESOURCE_TYPES, Collections.EMPTY_LIST);
-    } else {
-      String[] resourceTypes = getPublication().getResourceTypeNames();
-      setParameter(RESOURCE_TYPES, Arrays.asList(resourceTypes));
-    }
-  }
-
-  protected void initSampleParameters() {
-    ServiceSelector selector = null;
-    ResourceType resourceType = null;
-    try {
-      selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE
-          + "Selector");
-      resourceType = (ResourceType) selector.select(getDocumentTypeName());
-      setParameter(SAMPLES, Arrays.asList(resourceType.getSampleNames()));
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    } finally {
-      if (selector != null) {
-        if (resourceType != null) {
-          selector.release(resourceType);
-        }
-        this.manager.release(selector);
-      }
-    }
-  }
-
-  /**
-   * @return The source document or <code>null</code> if the usecase was not
-   *         invoked on a document.
-   */
-  protected Document getSourceDocument() {
-    Document document = null;
-    String url = getSourceURL();
-    try {
-      if (getDocumentIdentityMap().isDocument(url)) {
-        document = getDocumentIdentityMap().getFromURL(url);
-      }
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-    return document;
-  }
-
-  /**
-   * @return The new document.
-   */
-  protected Document getNewDocument() {
-    Document document = null;
-    // get new document
-    DocumentManager documentManager = null;
-    ServiceSelector selector = null;
-    ResourceType resourceType = null;
-    try {
-      documentManager = (DocumentManager) this.manager
-          .lookup(DocumentManager.ROLE);
-
-      DocumentIdentityMap map = getDocumentIdentityMap();
-      document = map.get(getPublication(), getArea(), getNewDocumentId(),
-          getParameterAsString(LANGUAGE));
-
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    } finally {
-      if (documentManager != null) {
-        this.manager.release(documentManager);
-      }
-      if (selector != null) {
-        if (resourceType != null) {
-          selector.release(resourceType);
-        }
-        this.manager.release(selector);
-      }
-    }
-    return document;
-  }
-
-  /**
-   * @return The area without the "info-" prefix.
-   */
-  public String getArea() {
-    URLInformation info = new URLInformation(getSourceURL());
-    return info.getArea();
-  }
-
-  private Publication publication;
-
-  /**
-   * Access to the current publication. Use this when the publication is not yet
-   * known in the usecase: e.g. when creating a global asset. When adding a
-   * resource or a child to a document, access the publication via that
-   * document's interface instead.
-   * 
-   * @return the publication in which the use-case is being executed
-   */
-  protected Publication getPublication() {
-    if (this.publication == null) {
-      try {
-        this.publication = PublicationUtil.getPublicationFromUrl(this.manager,
-            getSourceURL());
-      } catch (PublicationException e) {
-        throw new RuntimeException(e);
-      }
-    }
-    return this.publication;
-  }
-
-  /**
-   * @return the visibleInNav Attribute of the document being created in the
-   *         usecase
-   */
-  protected boolean getVisibleInNav() {
-    if (getParameterAsString(VISIBLEINNAV).equals("false")) {
-      return false;
+    protected static final String VISIBLEINNAV = "visibleInNav";
+
+    protected static final String SAMPLE = "sample";
+
+    protected static final String SAMPLES = "samples";
+
+    /**
+     * Ctor.
+     */
+    public Create() {
+        super();
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
+     */
+    protected void doCheckPreconditions() throws Exception {
+        super.doCheckPreconditions();
+
+        if (!getArea().equals(Publication.AUTHORING_AREA)) {
+            addErrorMessage("This usecase can only be invoked in the authoring area!");
+        }
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
+     */
+    protected Node[] getNodesToLock() throws UsecaseException {
+        try {
+            SiteStructure structure = SiteUtil.getSiteStructure(this.manager, getSourceDocument());
+            Node[] nodes = { structure.getRepositoryNode() };
+            return nodes;
+        } catch (SiteException e) {
+            throw new UsecaseException(e);
+        }
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
+     */
+    protected void doCheckExecutionConditions() throws Exception {
+        String navigationTitle = getParameterAsString(DublinCore.ELEMENT_TITLE);
+        if (navigationTitle.equals("")) {
+            addErrorMessage("The navigation title is required.");
+        }
+
+        if (getInitialDocument() == null) {
+            List samples = (List) getParameter(SAMPLES);
+            String sample = getParameterAsString(SAMPLE);
+            if (samples != null && samples.size() > 1 && (sample == null || sample.equals(""))) {
+                addErrorMessage("Please select a page layout.");
+            }
+        }
+
+        String doctypeName = getDocumentTypeName();
+        if (doctypeName != null) {
+            initSampleParameters();
+        }
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+     */
+    protected void doExecute() throws Exception {
+        super.doExecute();
+
+        // create new document
+        DocumentManager documentManager = null;
+        ServiceSelector selector = null;
+        ResourceType resourceType = null;
+        try {
+
+            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+
+            DocumentIdentityMap map = getDocumentIdentityMap();
+            Document document = map.get(getPublication(),
+                    getArea(),
+                    getNewDocumentId(),
+                    getParameterAsString(LANGUAGE));
+
+            Document initialDocument = getInitialDocument();
+            if (initialDocument == null) {
+                selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
+                resourceType = (ResourceType) selector.select(getDocumentTypeName());
+                if (getParameterAsString(SAMPLE) != null
+                        && getParameterAsString(SAMPLE).length() > 0)
+                    resourceType.setSampleURI(getParameterAsString(SAMPLE));
+                documentManager.add(document,
+                        resourceType,
+                        "xml",
+                        getParameterAsString(DublinCore.ELEMENT_TITLE),
+                        getVisibleInNav(),
+                        null);
+                resourceType.setSampleURI(""); // reset to default sample
+            } else {
+                documentManager.add(document,
+                        initialDocument,
+                        "xml",
+                        getParameterAsString(DublinCore.ELEMENT_TITLE),
+                        getVisibleInNav(),
+                        null);
+            }
+
+            setMetaData(document);
+
+            // the location to navigate to after completion of usecase
+            setTargetURL(document.getCanonicalWebappURL());
+
+        } finally {
+            if (documentManager != null) {
+                this.manager.release(documentManager);
+            }
+            if (selector != null) {
+                if (resourceType != null) {
+                    selector.release(resourceType);
+                }
+                this.manager.release(selector);
+            }
+        }
+
+    }
+
+    /**
+     * @return the name of the document being created in the usecase
+     */
+    protected abstract String getNewDocumentName();
+
+    /**
+     * @return the id of the new document being created in the usecase
+     */
+    protected abstract String getNewDocumentId();
+
+    /**
+     * If the document created in the usecase shall have initial contents copied from an existing
+     * document, construct that document in this method.
+     * 
+     * @return A document.
+     */
+    protected Document getInitialDocument() {
+        return null;
+    }
+
+    /**
+     * @return The type of the created document.
+     */
+    protected abstract String getDocumentTypeName();
+
+    /**
+     * Sets the meta data of the created document.
+     * 
+     * @param document The document.
+     * @throws DocumentException if an error occurs.
+     */
+    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));
+        dcMetaData.put(DublinCore.ELEMENT_CREATOR, getParameterAsString(DublinCore.ELEMENT_CREATOR));
+        dcMetaData.put(DublinCore.ELEMENT_PUBLISHER,
+                getParameterAsString(DublinCore.ELEMENT_PUBLISHER));
+        dcMetaData.put(DublinCore.ELEMENT_SUBJECT, getParameterAsString(DublinCore.ELEMENT_SUBJECT));
+        dcMetaData.put(DublinCore.ELEMENT_DATE, getParameterAsString(DublinCore.ELEMENT_DATE));
+        dcMetaData.put(DublinCore.ELEMENT_RIGHTS, getParameterAsString(DublinCore.ELEMENT_RIGHTS));
+        dcMetaData.put(DublinCore.ELEMENT_LANGUAGE, getParameterAsString(LANGUAGE));
+
+        document.getMetaDataManager().setDublinCoreMetaData(dcMetaData);
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
+     */
+    protected void initParameters() {
+        super.initParameters();
+
+        Map objectModel = ContextHelper.getObjectModel(getContext());
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        Session session = request.getSession(false);
+        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+        User user = identity.getUser();
+        if (user != null) {
+            setParameter(DublinCore.ELEMENT_CREATOR, user.getId());
+        } else {
+            setParameter(DublinCore.ELEMENT_CREATOR, "");
+        }
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        setParameter(DublinCore.ELEMENT_DATE, format.format(new GregorianCalendar().getTime()));
+
+        String doctypeName = getDocumentTypeName();
+        if (doctypeName != null) {
+            initSampleParameters();
+            setParameter(RESOURCE_TYPES, Collections.EMPTY_LIST);
+        } else {
+            String[] resourceTypes = getPublication().getResourceTypeNames();
+            setParameter(RESOURCE_TYPES, Arrays.asList(resourceTypes));
+        }
+    }
+
+    protected void initSampleParameters() {
+        ServiceSelector selector = null;
+        ResourceType resourceType = null;
+        try {
+            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
+            resourceType = (ResourceType) selector.select(getDocumentTypeName());
+            setParameter(SAMPLES, Arrays.asList(resourceType.getSampleNames()));
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (selector != null) {
+                if (resourceType != null) {
+                    selector.release(resourceType);
+                }
+                this.manager.release(selector);
+            }
+        }
+    }
+
+    /**
+     * @return The source document or <code>null</code> if the usecase was not invoked on a
+     *         document.
+     */
+    protected Document getSourceDocument() {
+        Document document = null;
+        String url = getSourceURL();
+        try {
+            if (getDocumentIdentityMap().isDocument(url)) {
+                document = getDocumentIdentityMap().getFromURL(url);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return document;
+    }
+
+    /**
+     * @return The new document.
+     */
+    protected Document getNewDocument() {
+        Document document = null;
+        // get new document
+        DocumentManager documentManager = null;
+        ServiceSelector selector = null;
+        ResourceType resourceType = null;
+        try {
+            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+
+            DocumentIdentityMap map = getDocumentIdentityMap();
+            document = map.get(getPublication(),
+                    getArea(),
+                    getNewDocumentId(),
+                    getParameterAsString(LANGUAGE));
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (documentManager != null) {
+                this.manager.release(documentManager);
+            }
+            if (selector != null) {
+                if (resourceType != null) {
+                    selector.release(resourceType);
+                }
+                this.manager.release(selector);
+            }
+        }
+        return document;
+    }
+
+    /**
+     * @return The area without the "info-" prefix.
+     */
+    public String getArea() {
+        URLInformation info = new URLInformation(getSourceURL());
+        return info.getArea();
+    }
+
+    private Publication publication;
+
+    /**
+     * Access to the current publication. Use this when the publication is not yet known in the
+     * usecase: e.g. when creating a global asset. When adding a resource or a child to a document,
+     * access the publication via that document's interface instead.
+     * 
+     * @return the publication in which the use-case is being executed
+     */
+    protected Publication getPublication() {
+        if (this.publication == null) {
+            try {
+                this.publication = PublicationUtil.getPublicationFromUrl(this.manager,
+                        getSourceURL());
+            } catch (PublicationException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return this.publication;
+    }
+
+    /**
+     * @return the visibleInNav Attribute of the document being created in the usecase
+     */
+    protected boolean getVisibleInNav() {
+        if (getParameterAsString(VISIBLEINNAV).equals("false")) {
+            return false;
+        }
+        return true;
     }
-    return true;
-  }
 
 }

Modified: lenya/trunk/src/modules/opendocument/java/src/org/apache/lenya/cms/site/usecases/CreateOpenDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/opendocument/java/src/org/apache/lenya/cms/site/usecases/CreateOpenDocument.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/modules/opendocument/java/src/org/apache/lenya/cms/site/usecases/CreateOpenDocument.java (original)
+++ lenya/trunk/src/modules/opendocument/java/src/org/apache/lenya/cms/site/usecases/CreateOpenDocument.java Thu Mar  9 08:56:01 2006
@@ -113,25 +113,22 @@
         ServiceSelector selector = null;
         DocumentBuilder builder = null;
         try {
-            selector = (ServiceSelector) this.manager
-                            .lookup(DocumentBuilder.ROLE + "Selector");
-            String hint = getSourceDocument().getPublication()
-                            .getDocumentBuilderHint();
+            selector = (ServiceSelector) this.manager.lookup(DocumentBuilder.ROLE + "Selector");
+            String hint = getSourceDocument().getPublication().getDocumentBuilderHint();
             builder = (DocumentBuilder) selector.select(hint);
 
-            boolean provided = getParameterAsBoolean(DOCUMENT_ID_PROVIDED,
-                            false);
+            boolean provided = getParameterAsBoolean(DOCUMENT_ID_PROVIDED, false);
             if (!provided && !builder.isValidDocumentName(documentName)) {
                 addErrorMessage("The document ID may not contain any special characters.");
             } else {
                 Publication publication = getSourceDocument().getPublication();
                 String newDocumentId = getNewDocumentId();
-                Document document = getSourceDocument().getIdentityMap().get(
-                                publication, getSourceDocument().getArea(),
-                                newDocumentId, language);
+                Document document = getSourceDocument().getIdentityMap().get(publication,
+                        getSourceDocument().getArea(),
+                        newDocumentId,
+                        language);
                 if (document.exists()) {
-                    addErrorMessage("The document with ID " + newDocumentId
-                                    + " already exists.");
+                    addErrorMessage("The document with ID " + newDocumentId + " already exists.");
                 }
             }
         } finally {
@@ -155,18 +152,16 @@
         ResourceType resourceType = null;
         try {
 
-            documentManager = (DocumentManager) this.manager
-                            .lookup(DocumentManager.ROLE);
+            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
 
             DocumentIdentityMap map = getDocumentIdentityMap();
-            Document document = map.get(getPublication(), getArea(),
-                            getNewDocumentId(), getParameterAsString(LANGUAGE));
-            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE
-                            + "Selector");
-            resourceType = (ResourceType) selector
-                            .select(getDocumentTypeName());
-            if (getParameterAsString(SAMPLE) != null
-                            && getParameterAsString(SAMPLE).length() > 0)
+            Document document = map.get(getPublication(),
+                    getArea(),
+                    getNewDocumentId(),
+                    getParameterAsString(LANGUAGE));
+            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
+            resourceType = (ResourceType) selector.select(getDocumentTypeName());
+            if (getParameterAsString(SAMPLE) != null && getParameterAsString(SAMPLE).length() > 0)
                 resourceType.setSampleURI(getParameterAsString(SAMPLE));
             // now that the source is determined, lock involved nodes
             Node node = document.getRepositoryNode();
@@ -196,8 +191,7 @@
 
     }
 
-    protected void addODT(Document document, ResourceType resourceType)
-                    throws Exception {
+    protected void addODT(Document document, ResourceType resourceType) throws Exception {
         SourceResolver resolver = null;
         String publicationId = null;
         String contentDir = null;
@@ -207,46 +201,44 @@
         ServiceSelector selector = null;
         try {
             selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            resolver = (SourceResolver) this.manager
-                            .lookup(SourceResolver.ROLE);
-            String pubBase = Node.LENYA_PROTOCOL
-                            + Publication.PUBLICATION_PREFIX_URI + "/";
-            String publicationsPath = document.getPublication().getSourceURI()
-                            .substring(pubBase.length());
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+            String pubBase = Node.LENYA_PROTOCOL + Publication.PUBLICATION_PREFIX_URI + "/";
+            String publicationsPath = document.getPublication()
+                    .getSourceURI()
+                    .substring(pubBase.length());
             publicationId = publicationsPath.split("/")[0];
-            Publication pub = PublicationUtil.getPublication(this.manager,
-                            publicationId);
+            Publication pub = PublicationUtil.getPublication(this.manager, publicationId);
             contentDir = pub.getContentDir();
-            String urlID = "content/" + document.getArea() + document.getId()
-                            + "/" + DEFAULT_INDEX + "_"
-                            + document.getLanguage() + ODT_EXTENSION;
+            String urlID = "content/" + document.getArea() + document.getId() + "/" + DEFAULT_INDEX
+                    + "_" + document.getLanguage() + ODT_EXTENSION;
             if (contentDir == null) {
-                destination = SourceNode.CONTEXT_PREFIX
-                                + Publication.PUBLICATION_PREFIX_URI + "/"
-                                + publicationId + "/" + urlID;
+                destination = SourceNode.CONTEXT_PREFIX + Publication.PUBLICATION_PREFIX_URI + "/"
+                        + publicationId + "/" + urlID;
             } else {
                 if (new File(contentDir).isAbsolute()) {
                     // Absolute
-                    destination = SourceNode.FILE_PREFIX + contentDir
-                                    + File.separator + urlID;
+                    destination = SourceNode.FILE_PREFIX + contentDir + File.separator + urlID;
                 } else {
                     // Relative
-                    destination = SourceNode.CONTEXT_PREFIX + contentDir
-                                    + File.separator + urlID;
+                    destination = SourceNode.CONTEXT_PREFIX + contentDir + File.separator + urlID;
                 }
             }
             SourceUtil.copy(resolver, sourceUri, destination);
-            siteManager = (SiteManager) selector.select(document
-                            .getPublication().getSiteManagerHint());
+            siteManager = (SiteManager) selector.select(document.getPublication()
+                    .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,
-                            getParameterAsString(DublinCore.ELEMENT_TITLE));
+            siteManager.setLabel(document, getParameterAsString(DublinCore.ELEMENT_TITLE));
             siteManager.setVisibleInNav(document, getVisibleInNav());
+
+            String extension = ODT_EXTENSION.substring(1);
+            document.getMetaDataManager()
+                    .getLenyaMetaData()
+                    .setValue(LenyaMetaData.ELEMENT_EXTENSION, extension);
         } catch (Exception e) {
             throw new Exception(e);
         } finally {
@@ -268,8 +260,7 @@
         final String documentId = getParameterAsString(DOCUMENT_ID);
         String documentName;
         if (getParameterAsBoolean(DOCUMENT_ID_PROVIDED, false)) {
-            documentName = documentId
-                            .substring(documentId.lastIndexOf("/") + 1);
+            documentName = documentId.substring(documentId.lastIndexOf("/") + 1);
         } else {
             documentName = documentId;
         }
@@ -277,8 +268,7 @@
     }
 
     /**
-     * @return The relation between the source document and the created
-     *         document.
+     * @return The relation between the source document and the created document.
      */
     protected String getRelation() {
         return getParameterAsString(RELATION);
@@ -296,17 +286,13 @@
             if (relation.equals(RELATION_CHILD)) {
                 return sourceDoc.getId() + "/" + getNewDocumentName();
             } else if (relation.equals(RELATION_BEFORE)) {
-                return sourceDoc.getId().substring(
-                                0,
-                                sourceDoc.getId().lastIndexOf(
-                                                sourceDoc.getName()))
-                                + getNewDocumentName();
+                return sourceDoc.getId().substring(0,
+                        sourceDoc.getId().lastIndexOf(sourceDoc.getName()))
+                        + getNewDocumentName();
             } else if (relation.equals(RELATION_AFTER)) {
-                return sourceDoc.getId().substring(
-                                0,
-                                sourceDoc.getId().lastIndexOf(
-                                                sourceDoc.getName()))
-                                + getNewDocumentName();
+                return sourceDoc.getId().substring(0,
+                        sourceDoc.getId().lastIndexOf(sourceDoc.getName()))
+                        + getNewDocumentName();
             } else {
                 return getSourceDocument().getId() + "/" + getNewDocumentName();
             }
@@ -330,8 +316,7 @@
         String[] paramNames = getParameterNames();
         for (int i = 0; i < paramNames.length; i++) {
             if (paramNames[i].startsWith(Metadata.CUSTOM_FORM_PREFIX)) {
-                String key = paramNames[i]
-                                .substring(Metadata.CUSTOM_FORM_PREFIX.length());
+                String key = paramNames[i].substring(Metadata.CUSTOM_FORM_PREFIX.length());
                 String value = getParameterAsString(paramNames[i]);
                 customMeta.addValue(key, value);
             }

Modified: lenya/trunk/src/modules/opendocument/sitemap.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/opendocument/sitemap.xmap?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/modules/opendocument/sitemap.xmap (original)
+++ lenya/trunk/src/modules/opendocument/sitemap.xmap Thu Mar  9 08:56:01 2006
@@ -39,7 +39,7 @@
       <map:match pattern="davget.xml">
         <map:act type="set-header">
           <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
-          <map:read src="context://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}/{page-envelope:document-id}/index_{page-envelope:document-language}.odt" mime-type="application/vnd.oasis.opendocument.text"/>
+          <map:read src="lenyadoc://{page-envelope:publication-id}/{page-envelope:area}/{page-envelope:document-language}/{page-envelope:document-id}" mime-type="application/vnd.oasis.opendocument.text"/>
         </map:act>
       </map:match>
 
@@ -49,7 +49,7 @@
 <!-- Fixme The path of the odt file should be get with the input module, like for the xml file.
  Write a special DocumentIdToPathMapper, permit a Resource to have its own Mapper-->
       <map:match pattern="*.xml">
-        <map:generate src="zip:context://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}/{page-envelope:document-id}/index_{page-envelope:document-language}.odt!/content.xml"/>
+        <map:generate src="zip:lenyadoc://{page-envelope:publication-id}/{page-envelope:area}/{page-envelope:document-language}/{page-envelope:document-id}!/content.xml"/>
 
 <!--
         <map:transform src="fallback://lenya/modules/opendocument/xslt/main_html.xsl">
@@ -63,7 +63,7 @@
         <map:serialize type="xml"/>
       </map:match>
       <map:match pattern="**.odt">
-        <map:read src="context://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}{page-envelope:document-id}/index_{page-envelope:document-language}.odt" mime-type="application/vnd.oasis.opendocument.text"/>
+        <map:read src="lenyadoc://{page-envelope:publication-id}/{page-envelope:area}/{page-envelope:document-language}/{page-envelope:document-id}" mime-type="application/vnd.oasis.opendocument.text"/>
       </map:match>
 
     </map:pipeline>

Modified: lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java (original)
+++ lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java Thu Mar  9 08:56:01 2006
@@ -85,7 +85,7 @@
                             doc.getLanguage());
 
                     resourceType = (ResourceType) selector.select("xhtml");
-                    documentManager.add(document, resourceType, doc.getName(), true, null);
+                    documentManager.add(document, resourceType, "xml", doc.getName(), true, null);
 
                     setMetaData(document);
                     doc = document;
@@ -103,7 +103,9 @@
             }
 
             DocumentIdToPathMapper mapper = doc.getPublication().getPathMapper();
-            String path = mapper.getPath(doc.getId(), getSourceDocument().getLanguage());
+            String path = mapper.getPath(doc.getId(),
+                    getSourceDocument().getLanguage(),
+                    doc.getSourceExtension());
             String sourceUri = doc.getSourceURI();
             String pubId = doc.getPublication().getId();
             String uploadSourceUri = "cocoon:/request/PUT";
@@ -131,7 +133,7 @@
                 // validity check
                 ResourceType resourceType = doc.getResourceType();
                 Schema schema = resourceType.getSchema();
-                
+
                 org.w3c.dom.Document xmlDoc = DocumentHelper.readDocument(tempSource.getInputStream());
                 ValidationUtil.validate(this.manager, xmlDoc, schema, new UsecaseErrorHandler(this));
 

Modified: lenya/trunk/src/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java (original)
+++ lenya/trunk/src/pubs/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java Thu Mar  9 08:56:01 2006
@@ -18,27 +18,21 @@
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
-import java.util.Map;
 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.cms.metadata.dublincore.DublinCore;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentIdentityMap;
 import org.apache.lenya.cms.publication.DocumentManager;
-import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.ResourceType;
-import org.apache.lenya.cms.publication.util.DocumentSet;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteStructure;
@@ -62,15 +56,13 @@
      */
     protected Node[] getNodesToLock() throws UsecaseException {
         try {
-            SiteStructure structure = SiteUtil.getSiteStructure(this.manager,
-            getSourceDocument());
+            SiteStructure structure = SiteUtil.getSiteStructure(this.manager, getSourceDocument());
             Node[] nodes = { structure.getRepositoryNode() };
             return nodes;
         } catch (SiteException e) {
             throw new UsecaseException(e);
         }
     }
-    
 
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
@@ -82,7 +74,6 @@
         setParameter(PARENT_ID, parent.getId());
     }
 
-        
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
      */
@@ -133,11 +124,14 @@
             DocumentIdentityMap map = getDocumentIdentityMap();
 
             String documentId = getDocumentID();
-            Document document = map.get(getSourceDocument().getPublication(), getSourceDocument()
-                    .getArea(), documentId, language);
+            Document document = map.get(getSourceDocument().getPublication(),
+                    getSourceDocument().getArea(),
+                    documentId,
+                    language);
 
             documentManager.add(document,
                     resourceType,
+                    "xml",
                     getParameterAsString(DublinCore.ELEMENT_TITLE),
                     true,
                     allParameters);

Modified: lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/webdav/Put.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/webdav/Put.java?rev=384556&r1=384555&r2=384556&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/webdav/Put.java (original)
+++ lenya/trunk/src/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/webdav/Put.java Thu Mar  9 08:56:01 2006
@@ -86,7 +86,7 @@
                             doc.getLanguage());
 
                     resourceType = (ResourceType) selector.select("xhtml");
-                    documentManager.add(document, resourceType, doc.getName(), true, null);
+                    documentManager.add(document, resourceType, "xml", doc.getName(), true, null);
 
                     setMetaData(document);
                     doc = document;
@@ -104,7 +104,7 @@
             }
 
             DocumentIdToPathMapper mapper = doc.getPublication().getPathMapper();
-            String path = mapper.getPath(doc.getId(), getSourceDocument().getLanguage());
+            String path = mapper.getPath(doc.getId(), getSourceDocument().getLanguage(), doc.getSourceExtension());
             String sourceUri = doc.getSourceURI();
             String pubId = doc.getPublication().getId();
             String uploadSourceUri = "cocoon:/request/PUT";



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


Re: svn commit: r384556

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler wrote:
> El vie, 10-03-2006 a las 14:25 +0100, Andreas Hartmann escribió:
>> Thorsten Scherler wrote:
>>
>> [...]
>>
>>>>> Yeah, to move the meta to
>>>>> lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml.meta but
>>>>> that does make 0% sense for custom mapping if I want this location I
>>>>> would not write a custom mapper.
>>>> The hard-coded location applies only to the meta sources.
>>>> The location of the actual document sources is determined by
>>>> your custom DocumentIdToPathMapper.
>>>>
>>> Well the problem is now with my pub that you cannot create any pages
>>> anymore because the meta data file will be written to a different
>>> location then I need.
>> That's very strange. Do you access the meta data files directly?
> 
> No, it happends in the DocumentManagerImpl.java. When add() is called.
> 
> We have now 2 *different* ids when we use custom mapping.

You're right :(

The problem is in SourceNode:

     protected String getMetaSourceURI() {
         return getSourceURI() + ".meta";
     }

That won't work.
I'll take a look.

-- Andreas


-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


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


Re: svn commit: r384556

Posted by Thorsten Scherler <th...@apache.org>.
El vie, 10-03-2006 a las 14:25 +0100, Andreas Hartmann escribió:
> Thorsten Scherler wrote:
> 
> [...]
> 
> >>> Yeah, to move the meta to
> >>> lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml.meta but
> >>> that does make 0% sense for custom mapping if I want this location I
> >>> would not write a custom mapper.
> >> The hard-coded location applies only to the meta sources.
> >> The location of the actual document sources is determined by
> >> your custom DocumentIdToPathMapper.
> >>
> > 
> > Well the problem is now with my pub that you cannot create any pages
> > anymore because the meta data file will be written to a different
> > location then I need.
> 
> That's very strange. Do you access the meta data files directly?

No, it happends in the DocumentManagerImpl.java. When add() is called.

We have now 2 *different* ids when we use custom mapping.

salu2

> 
> -- Andreas
> 
> 
> 
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


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


Re: svn commit: r384556

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler wrote:

[...]

>>> Yeah, to move the meta to
>>> lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml.meta but
>>> that does make 0% sense for custom mapping if I want this location I
>>> would not write a custom mapper.
>> The hard-coded location applies only to the meta sources.
>> The location of the actual document sources is determined by
>> your custom DocumentIdToPathMapper.
>>
> 
> Well the problem is now with my pub that you cannot create any pages
> anymore because the meta data file will be written to a different
> location then I need.

That's very strange. Do you access the meta data files directly?

-- Andreas



-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


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


Re: svn commit: r384556

Posted by Thorsten Scherler <th...@apache.org>.
El vie, 10-03-2006 a las 13:41 +0100, Andreas Hartmann escribió:
> Thorsten Scherler wrote:
> > El vie, 10-03-2006 a las 13:13 +0100, Andreas Hartmann escribió:
> >> Thorsten Scherler wrote:
> >>
> >> [...]
> >>
> >>> ...
> >>>> @@ -331,7 +346,9 @@
> >>>>              RepositorySource source = null;
> >>>>              try {
> >>>>                  resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
> >>>> -                source = (RepositorySource) resolver.resolveURI(getSourceURI());
> >>>> +                String sourceUri = getPublication().getSourceURI() + "/content/" + getArea()
> >>>> +                        + getId() + "/index_" + getLanguage() + ".xml";
> >>>> +                source = (RepositorySource) resolver.resolveURI(sourceUri);
> >>>>                  this.metaDataManager = source.getNode().getMetaDataManager();
> >>>>              } catch (Exception e) {
> >>>>                  throw new RuntimeException(e);
> >>> This code change is not compatible with custom mapping.
> >> It is compatible. You just have to move your meta files once.
> > 
> > ¿?
> > 
> > The above string is looking up:
> > lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml
> > 
> > Yeah, to move the meta to
> > lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml.meta but
> > that does make 0% sense for custom mapping if I want this location I
> > would not write a custom mapper.
> 
> The hard-coded location applies only to the meta sources.
> The location of the actual document sources is determined by
> your custom DocumentIdToPathMapper.
> 

Well the problem is now with my pub that you cannot create any pages
anymore because the meta data file will be written to a different
location then I need.

:(

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


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


Re: svn commit: r384556

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler wrote:
> El vie, 10-03-2006 a las 13:13 +0100, Andreas Hartmann escribió:
>> Thorsten Scherler wrote:
>>
>> [...]
>>
>>> ...
>>>> @@ -331,7 +346,9 @@
>>>>              RepositorySource source = null;
>>>>              try {
>>>>                  resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
>>>> -                source = (RepositorySource) resolver.resolveURI(getSourceURI());
>>>> +                String sourceUri = getPublication().getSourceURI() + "/content/" + getArea()
>>>> +                        + getId() + "/index_" + getLanguage() + ".xml";
>>>> +                source = (RepositorySource) resolver.resolveURI(sourceUri);
>>>>                  this.metaDataManager = source.getNode().getMetaDataManager();
>>>>              } catch (Exception e) {
>>>>                  throw new RuntimeException(e);
>>> This code change is not compatible with custom mapping.
>> It is compatible. You just have to move your meta files once.
> 
> ¿?
> 
> The above string is looking up:
> lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml
> 
> Yeah, to move the meta to
> lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml.meta but
> that does make 0% sense for custom mapping if I want this location I
> would not write a custom mapper.

The hard-coded location applies only to the meta sources.
The location of the actual document sources is determined by
your custom DocumentIdToPathMapper.


> We need to change this ASAP. I recommend to create a meta data dir (like
> mentioned from others as well) and get the metada from there.

This is fine with me. I just used the behavior of the
DefaultDocumentIdToPathMapper for the moment so that most people don't
have to migrate their meta files to a new location.


>>> We need use the Mapper to lookup the sourceURI.
>> No, you can't use the mapper, because the mapper has to access the
>> document source extension. But this would require access to the meta
>> data. You'll end up with a StackOverflowError. I already mentioned
>> this problem a couple of times.
>>
> 
> Yeah, I just found out myself. ;)

:)

-- Andreas

-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


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


Re: svn commit: r384556

Posted by Thorsten Scherler <th...@wyona.com>.
El vie, 10-03-2006 a las 13:13 +0100, Andreas Hartmann escribió:
> Thorsten Scherler wrote:
> 
> [...]
> 
> > ...
> >> @@ -331,7 +346,9 @@
> >>              RepositorySource source = null;
> >>              try {
> >>                  resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
> >> -                source = (RepositorySource) resolver.resolveURI(getSourceURI());
> >> +                String sourceUri = getPublication().getSourceURI() + "/content/" + getArea()
> >> +                        + getId() + "/index_" + getLanguage() + ".xml";
> >> +                source = (RepositorySource) resolver.resolveURI(sourceUri);
> >>                  this.metaDataManager = source.getNode().getMetaDataManager();
> >>              } catch (Exception e) {
> >>                  throw new RuntimeException(e);
> > 
> > This code change is not compatible with custom mapping.
> 
> It is compatible. You just have to move your meta files once.

¿?

The above string is looking up:
lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml

Yeah, to move the meta to
lenya://lenya/pubs/myPub/content/authoring/index/index_en.xml.meta but
that does make 0% sense for custom mapping if I want this location I
would not write a custom mapper.

We need to change this ASAP. I recommend to create a meta data dir (like
mentioned from others as well) and get the metada from there.

> 
> 
> > We need use the Mapper to lookup the sourceURI.
> 
> No, you can't use the mapper, because the mapper has to access the
> document source extension. But this would require access to the meta
> data. You'll end up with a StackOverflowError. I already mentioned
> this problem a couple of times.
> 

Yeah, I just found out myself. ;)

salu2
-- 
Thorsten Scherler
COO Spain
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org


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


Re: svn commit: r384556

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler wrote:

[...]

> ...
>> @@ -331,7 +346,9 @@
>>              RepositorySource source = null;
>>              try {
>>                  resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
>> -                source = (RepositorySource) resolver.resolveURI(getSourceURI());
>> +                String sourceUri = getPublication().getSourceURI() + "/content/" + getArea()
>> +                        + getId() + "/index_" + getLanguage() + ".xml";
>> +                source = (RepositorySource) resolver.resolveURI(sourceUri);
>>                  this.metaDataManager = source.getNode().getMetaDataManager();
>>              } catch (Exception e) {
>>                  throw new RuntimeException(e);
> 
> This code change is not compatible with custom mapping.

It is compatible. You just have to move your meta files once.


> We need use the Mapper to lookup the sourceURI.

No, you can't use the mapper, because the mapper has to access the
document source extension. But this would require access to the meta
data. You'll end up with a StackOverflowError. I already mentioned
this problem a couple of times.

-- Andreas


-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


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


Re: svn commit: r384556

Posted by Thorsten Scherler <th...@wyona.com>.
El jue, 09-03-2006 a las 16:56 +0000, andreas@apache.org escribió:
> Author: andreas
> Date: Thu Mar  9 08:56:01 2006
> New Revision: 384556
> 
> URL: http://svn.apache.org/viewcvs?rev=384556&view=rev
> Log:
> Add extension attribute to LenyaMetaData. This way, the extension can be accessed by the DocumentIdToPathMapper - this allows custom source extensions (like .odt, ...) and is a first step towards handling assets and documents in the same way.
> 
> Modified:
...
>     lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
...

> 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=384556&r1=384555&r2=384556&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 Thu Mar  9 08:56:01 2006
> @@ -115,7 +115,8 @@
>  
...
> @@ -331,7 +346,9 @@
>              RepositorySource source = null;
>              try {
>                  resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
> -                source = (RepositorySource) resolver.resolveURI(getSourceURI());
> +                String sourceUri = getPublication().getSourceURI() + "/content/" + getArea()
> +                        + getId() + "/index_" + getLanguage() + ".xml";
> +                source = (RepositorySource) resolver.resolveURI(sourceUri);
>                  this.metaDataManager = source.getNode().getMetaDataManager();
>              } catch (Exception e) {
>                  throw new RuntimeException(e);

This code change is not compatible with custom mapping. 

We need use the Mapper to lookup the sourceURI.

I will try to fix it right now.

salu2
-- 
Thorsten Scherler
COO Spain
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org


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