You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by th...@apache.org on 2006/07/21 14:51:01 UTC

svn commit: r424292 - in /lenya/trunk/src/modules/resource: ./ config/ config/cocoon-xconf/ config/menus/ java/ java/src/ java/src/org/ java/src/org/apache/ java/src/org/apache/lenya/ java/src/org/apache/lenya/cms/ java/src/org/apache/lenya/cms/site/ j...

Author: thorsten
Date: Fri Jul 21 05:50:59 2006
New Revision: 424292

URL: http://svn.apache.org/viewvc?rev=424292&view=rev
Log:
Donation of the resource module from the Wyona AG. 
This module is an alternative way of keeping resources in lenya.

This code is based on https://svn.wyona.com/repos/public/lenya/modules/resource revision 15504.
I did some adjustments to workaround the missing icons which cannot be included in this module 
due to license issues.

Please submit us icons.

Added:
    lenya/trunk/src/modules/resource/
    lenya/trunk/src/modules/resource/README.txt   (with props)
    lenya/trunk/src/modules/resource/config/
    lenya/trunk/src/modules/resource/config/cocoon-xconf/
    lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf   (with props)
    lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-create-resource.xconf   (with props)
    lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-upload-resource.xconf   (with props)
    lenya/trunk/src/modules/resource/config/menus/
    lenya/trunk/src/modules/resource/config/menus/resource.xsp   (with props)
    lenya/trunk/src/modules/resource/java/
    lenya/trunk/src/modules/resource/java/src/
    lenya/trunk/src/modules/resource/java/src/org/
    lenya/trunk/src/modules/resource/java/src/org/apache/
    lenya/trunk/src/modules/resource/java/src/org/apache/lenya/
    lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/
    lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/
    lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/
    lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/CreateResource.java   (with props)
    lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/UploadResource.java   (with props)
    lenya/trunk/src/modules/resource/menus.xmap   (with props)
    lenya/trunk/src/modules/resource/module.xml   (with props)
    lenya/trunk/src/modules/resource/resources/
    lenya/trunk/src/modules/resource/resources/icons/
    lenya/trunk/src/modules/resource/resources/icons/default.gif   (with props)
    lenya/trunk/src/modules/resource/resources/icons/default_med.gif   (with props)
    lenya/trunk/src/modules/resource/resources/schemas/
    lenya/trunk/src/modules/resource/resources/schemas/resource.rng   (with props)
    lenya/trunk/src/modules/resource/samples/
    lenya/trunk/src/modules/resource/samples/resource.xml   (with props)
    lenya/trunk/src/modules/resource/sitemap.xmap   (with props)
    lenya/trunk/src/modules/resource/usecases/
    lenya/trunk/src/modules/resource/usecases/create-resource.jx
    lenya/trunk/src/modules/resource/usecases/upload-resource.jx
    lenya/trunk/src/modules/resource/xslt/
    lenya/trunk/src/modules/resource/xslt/common/
    lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl   (with props)
    lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl   (with props)

Added: lenya/trunk/src/modules/resource/README.txt
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/README.txt?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/README.txt (added)
+++ lenya/trunk/src/modules/resource/README.txt Fri Jul 21 05:50:59 2006
@@ -0,0 +1,18 @@
+README
+
+Till now this module just provide *one* icon (the default one).
+The default icon (default_med.gif) is a question mark.
+
+If you can provide icons with a ASF style license we are happy 
+to add them to the module.
+
+Until then all icon calls like e.g. jpg_med.gif for a jpg image are 
+substituted with the default icon if they cannot be found.
+
+If you want your own set of icons, then please add them 
+to {yourPub}/lenya/modules/resource/resources/icons/
+
+You can download e.g. the ones from 
+https://svn.wyona.com/repos/public/lenya/modules/resource/resources/icons
+
+Have fun.

Propchange: lenya/trunk/src/modules/resource/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf (added)
+++ lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf Fri Jul 21 05:50:59 2006
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id:$ -->
+
+<xconf xpath="/cocoon/resource-types" unless="/cocoon/resource-types/component-instance[@name = 'resource']">
+
+  <component-instance name="resource"
+                      logger="lenya.resourcetypes.resource"
+                      class="org.apache.lenya.cms.publication.ResourceTypeImpl">
+    <schema src="fallback://lenya/modules/resource/resources/schemas/resource.rng" language="http://relaxng.org/ns/structure/0.9"/>
+    <sample-name>fallback://lenya/modules/resource/samples/resource.xml</sample-name>
+    <link-attribute xpath="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']/@href"/>
+    <format name="xhtml" uri="cocoon://modules/resource/xhtml.xml"/>
+  </component-instance>
+
+</xconf>

Propchange: lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-create-resource.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-create-resource.xconf?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-create-resource.xconf (added)
+++ lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-create-resource.xconf Fri Jul 21 05:50:59 2006
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+  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.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+  <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'create.resource']">
+    <component-instance name="create.resource" 
+                        logger="lenya.site" 
+                        class="org.apache.lenya.cms.site.usecases.CreateResource">
+      <view template="modules/resource/usecases/create-resource.jx" menu="true"/>
+    </component-instance>
+  </xconf>

Propchange: lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-create-resource.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-upload-resource.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-upload-resource.xconf?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-upload-resource.xconf (added)
+++ lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-upload-resource.xconf Fri Jul 21 05:50:59 2006
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: usecase-create-metadata.xconf 7081 2005-11-11 13:04:23Z felix $ -->
+
+<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'upload.resource']">
+
+  <component-instance name="upload.resource" logger="lenya.module.resource"
+    class="org.apache.lenya.cms.site.usecases.UploadResource">
+    <view template="modules/resource/usecases/upload-resource.jx"/>
+  </component-instance>
+  
+</xconf>

Propchange: lenya/trunk/src/modules/resource/config/cocoon-xconf/usecase-upload-resource.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/config/menus/resource.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/config/menus/resource.xsp?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/config/menus/resource.xsp (added)
+++ lenya/trunk/src/modules/resource/config/menus/resource.xsp Fri Jul 21 05:50:59 2006
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id:$ -->
+
+<xsp:page 
+    language="java" 
+    xmlns:xsp="http://apache.org/xsp"
+    xmlns:xsp-request="http://apache.org/xsp/request/2.0"
+    xmlns:input="http://apache.org/cocoon/xsp/input/1.0"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
+    xmlns:wf="http://apache.org/cocoon/lenya/workflow/1.0"
+    xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
+    xmlns="http://apache.org/cocoon/lenya/menubar/1.0"
+>
+  <xsp:structure>
+    <xsp:include>org.apache.lenya.cms.publication.Document</xsp:include>
+    <xsp:include>org.apache.lenya.cms.publication.Publication</xsp:include>
+  </xsp:structure>
+  
+  <menu>
+    <menus>
+      <menu i18n:attr="name" name="File">
+        <block admin="false">
+          <item uc:usecase="create.resource" href="?doctype=resource"><i18n:text>New Resource</i18n:text></item>
+        </block>
+      </menu>
+      <menu i18n:attr="name" name="Edit">
+          <xsp:logic>
+            String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
+            if ("resource".equals(doctype)) {
+              <block info="false">
+                <item wf:event="edit" uc:usecase="upload.resource" href="?"><i18n:text>Upload Resource</i18n:text></item>
+              </block>
+            }
+          </xsp:logic>
+      </menu>
+    </menus>
+  </menu>
+</xsp:page>

Propchange: lenya/trunk/src/modules/resource/config/menus/resource.xsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/CreateResource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/CreateResource.java?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/CreateResource.java (added)
+++ lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/CreateResource.java Fri Jul 21 05:50:59 2006
@@ -0,0 +1,212 @@
+/*
+ * Copyright  1999-2006 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.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site.usecases;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+
+import javax.imageio.ImageIO;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.excalibur.source.ModifiableSource;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.RepositorySource;
+import org.apache.lenya.cms.metadata.MetaData;
+import org.apache.lenya.cms.metadata.MetaDataException;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.usecase.UsecaseException;
+
+public class CreateResource extends CreateDocument {
+    // A media type document is an aggregation of different files.
+
+    /**
+     * Validates the request parameters.
+     * 
+     * @throws UsecaseException if an error occurs.
+     */
+    void validate() throws UsecaseException {
+        String title = getParameterAsString("title");
+
+        if (title.length() == 0) {
+            addErrorMessage("Please enter a title.");
+        }
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
+     */
+    protected void doCheckExecutionConditions() throws Exception {
+        validate();
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
+     */
+    protected void initParameters() {
+        super.initParameters();
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+     */
+    protected void doExecute() throws Exception {
+        super.doExecute();
+        addResource();
+    }
+
+    /**
+     * Adds the ressource. If asset upload is not enabled, an error message is added.
+     * @throws IOException
+     * @throws ServiceException
+     * @throws DocumentException
+     */
+    protected void addResource() throws ServiceException, IOException, DocumentException {
+
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("Assets::addAsset() called");
+
+        Part file = getPart("file");
+
+        if (file.isRejected()) {
+            String[] params = { Integer.toString(file.getSize()) };
+            addErrorMessage("upload-size-exceeded", params);
+        } else {
+            addResource(file);
+        }
+    }
+
+    /**
+     * Adds the ressource.
+     * 
+     * @param file The part.
+     * @throws IOException
+     * @throws ServiceException
+     * @throws DocumentException
+     */
+    protected void addResource(Part file) throws IOException, ServiceException, DocumentException {
+        Document document = getNewDocument();
+        MetaData mediaMeta = null;
+
+        SourceResolver resolver = null;
+        ModifiableSource source = null;
+        OutputStream destOutputStream = null;
+        InputStream inputStream = file.getInputStream();
+        try {
+            mediaMeta = document.getMetaData("http://apache.org/lenya/metadata/media/1.0");
+            addResourceMeta(file, mediaMeta);
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+
+            String destination = getNewDocument().getSourceURI();
+            source = (ModifiableSource) resolver.resolveURI(destination);
+
+            // now that the source is determined, lock involved nodes
+            Node node = getRepositoryNode(destination);
+            node.lock();
+
+            destOutputStream = source.getOutputStream();
+            final ByteArrayOutputStream sourceBos = new ByteArrayOutputStream();
+            IOUtils.copy(inputStream, sourceBos);
+            IOUtils.write(sourceBos.toByteArray(), destOutputStream);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (destOutputStream != null) {
+                destOutputStream.flush();
+                destOutputStream.close();
+            }
+            if (inputStream != null) {
+                inputStream.close();
+            }
+        }
+
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("Resource::addResource() done.");
+    }
+
+    protected String getSourceExtension() {
+        String extension = "";
+
+        Part file = getPart("file");
+        String fileName = file.getFileName();
+        int lastDotIndex = fileName.lastIndexOf(".");
+        if (lastDotIndex > -1) {
+            extension = fileName.substring(lastDotIndex + 1);
+        } else {
+            addErrorMessage("Please upload a file with an extension.");
+        }
+        return extension;
+    }
+
+    protected void addResourceMeta(Part part, MetaData customMeta) throws MetaDataException,
+            IOException {
+        String fileName = part.getFileName();
+        String mimeType = part.getMimeType();
+        int fileSize = part.getSize();
+        if (customMeta != null) {
+            customMeta.setValue("filename", fileName);
+            customMeta.setValue("format", mimeType);
+            customMeta.setValue("extent", Integer.toString(fileSize));
+        }
+        if (canReadMimeType(mimeType)) {
+            BufferedImage input = ImageIO.read(part.getInputStream());
+            String width = Integer.toString(input.getWidth());
+            String height = Integer.toString(input.getHeight());
+            if (customMeta != null) {
+                customMeta.setValue("height", height);
+                customMeta.setValue("width", width);
+            }
+        }
+    }
+
+    public static boolean canReadMimeType(String mimeType) {
+        Iterator iter = ImageIO.getImageReadersByMIMEType(mimeType);
+        return iter.hasNext();
+    } 
+
+    /**
+     * @return The repository node that represents the document identified by the destination
+     *         string.
+     */
+    public Node getRepositoryNode(String destination) {
+        Node node = null;
+        SourceResolver resolver = null;
+        RepositorySource documentSource = null;
+        try {
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+            documentSource = (RepositorySource) resolver.resolveURI(destination);
+            node = documentSource.getNode();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (resolver != null) {
+                if (documentSource != null) {
+                    resolver.release(documentSource);
+                }
+                this.manager.release(resolver);
+            }
+        }
+        return node;
+    }
+}

Propchange: lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/CreateResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/UploadResource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/UploadResource.java?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/UploadResource.java (added)
+++ lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/UploadResource.java Fri Jul 21 05:50:59 2006
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site.usecases;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.excalibur.source.ModifiableSource;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.RepositorySource;
+import org.apache.lenya.cms.metadata.MetaData;
+import org.apache.lenya.cms.metadata.MetaDataException;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.usecase.DocumentUsecase;
+
+/**
+ * Usecase to upload a resource.
+ * 
+ */
+public class UploadResource extends DocumentUsecase {
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
+     */
+    protected void initParameters() {
+        super.initParameters();
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+     */
+    protected void doExecute() throws Exception {
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("Resource::uploadResource() called");
+
+        Part file = getPart("file");
+
+        if (file.isRejected()) {
+            String[] params = { Integer.toString(file.getSize()) };
+            addErrorMessage("upload-size-exceeded", params);
+        } else {
+            saveResource(file);
+        }
+    }
+
+    /**
+     * Adds the ressource.
+     * 
+     * @param file The part.
+     * @throws IOException
+     * @throws ServiceException
+     * @throws DocumentException
+     * @throws MetaDataException
+     */
+    protected void saveResource(Part file) throws IOException, ServiceException, DocumentException,
+            MetaDataException {
+        Document document = getSourceDocument();
+        String destination = document.getSourceURI();
+
+        SourceResolver resolver = null;
+        ModifiableSource source = null;
+        OutputStream destOutputStream = null;
+        InputStream inputStream = file.getInputStream();
+        try {
+
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+            source = (ModifiableSource) resolver.resolveURI(destination);
+
+            // now that the source is determined, lock involved nodes
+            Node node = getRepositoryNode(destination);
+            node.lock();
+
+            destOutputStream = source.getOutputStream();
+            final ByteArrayOutputStream sourceBos = new ByteArrayOutputStream();
+            IOUtils.copy(inputStream, sourceBos);
+            IOUtils.write(sourceBos.toByteArray(), destOutputStream);
+        } catch (RepositoryException e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (destOutputStream != null) {
+                destOutputStream.flush();
+                destOutputStream.close();
+            }
+            if (inputStream != null) {
+                inputStream.close();
+            }
+        }
+
+        MetaData customMeta = document.getMetaData("http://apache.org/lenya/metadata/media/1.0");
+        updateResourceMeta(file, customMeta);
+
+        // update <lenya:extension>
+        MetaData internalMeta = document.getMetaData("http://apache.org/lenya/metadata/document/1.0");
+        internalMeta.setValue("extension", getSourceExtension());
+
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("Resource::addResource() done.");
+    }
+
+    protected String getSourceExtension() {
+        String extension = "";
+
+        Part file = getPart("file");
+        String fileName = file.getFileName();
+        int lastDotIndex = fileName.lastIndexOf(".");
+        if (lastDotIndex > -1) {
+            extension = fileName.substring(lastDotIndex + 1);
+        } else {
+            addErrorMessage("Please upload a file with an extension.");
+        }
+        return extension;
+    }
+
+    protected void updateResourceMeta(Part part, MetaData customMeta) throws MetaDataException,
+            IOException {
+        String fileName = part.getFileName();
+        String mimeType = part.getMimeType();
+        int fileSize = part.getSize();
+        if (customMeta != null) {
+            customMeta.addValue("media-filename", fileName);
+            customMeta.addValue("media-format", mimeType);
+            customMeta.addValue("media-extent", Integer.toString(fileSize));
+        }
+        if (CreateResource.canReadMimeType(mimeType)) {
+            BufferedImage input = ImageIO.read(part.getInputStream());
+            String width = Integer.toString(input.getWidth());
+            String height = Integer.toString(input.getHeight());
+            if (customMeta != null) {
+                customMeta.addValue("media-height", height);
+                customMeta.addValue("media-width", width);
+            }
+        }
+    }
+
+    /**
+     * @return The repository node that represents the document identified by the destination
+     *         string.
+     */
+    public Node getRepositoryNode(String destination) {
+        Node node = null;
+        SourceResolver resolver = null;
+        RepositorySource documentSource = null;
+        try {
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+            documentSource = (RepositorySource) resolver.resolveURI(destination);
+            node = documentSource.getNode();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (resolver != null) {
+                if (documentSource != null) {
+                    resolver.release(documentSource);
+                }
+                this.manager.release(resolver);
+            }
+        }
+        return node;
+    }
+}

Propchange: lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/site/usecases/UploadResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/menus.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/menus.xmap?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/menus.xmap (added)
+++ lenya/trunk/src/modules/resource/menus.xmap Fri Jul 21 05:50:59 2006
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+Copyright 1999-2004 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.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!-- $Id:$ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  
+  <map:pipelines>
+    
+    <map:pipeline>
+      
+      <map:match pattern="**">
+        <map:generate type="serverpages" src="fallback://lenya/modules/resource/config/menus/resource.xsp"/>
+        <map:serialize type="xml"/>
+      </map:match>
+      
+    </map:pipeline>
+    
+  </map:pipelines>
+</map:sitemap>
\ No newline at end of file

Propchange: lenya/trunk/src/modules/resource/menus.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/module.xml?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/module.xml (added)
+++ lenya/trunk/src/modules/resource/module.xml Fri Jul 21 05:50:59 2006
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id: publication.xml 374687 2006-02-03 15:24:55Z michi $ -->
+
+<lenya:module xmlns:lenya="http://apache.org/lenya/module/1.0">
+  <lenya:id>org.wyona.lenya.modules.resource</lenya:id>
+  <lenya:depends module="org.apache.lenya.modules.usecase"/>
+  <lenya:depends module="org.apache.lenya.modules.defaultusecases"/>
+  <lenya:depends module="org.apache.lenya.modules.sitemanagement"/>
+  <lenya:package>org.wyona.lenya.modules</lenya:package>
+  <lenya:version>0.1-dev</lenya:version>
+  <lenya:name>Resource Module</lenya:name>
+  <lenya:lenya-version>@lenya.version@</lenya:lenya-version>
+  <lenya:description>A module to manage arbitrary resources (PDF, GIF, ...)</lenya:description>
+  <lenya:readme>
+    
+    
+    
+See: http://www.idautomation.com/kb/xwindow-error.html
+     http://www.jguru.com/faq/view.jsp?EID=222296
+
+resp. try java.awt.headless=true in the case of Java 1.4 or
+
+running X servere, e.g.
+
+Virtual framebuffer X server:
+
+installation instructions for debian
+
+apt-get install xvfb
+apt-get install xlibs
+apt-get install xfonts-base
+
+nohup Xvfb :0 -screen 0 1024x786x16 &amp;
+export DISPLAY=:0
+
+Also you might want to add "export DISPLAY=:0" in lenya.sh, such that the DISPLAY variable is set during
+startup of Jetty, e.g.
+
+# ----- Verify and Set Required Environment Variables -------------------------
+
+if [ "$DISPLAY" = "" ] ; then
+  export DISPLAY=:0
+  fi
+  </lenya:readme>
+  <lenya:installation>
+<![CDATA[
+
+    add to yourpub/conf/publication.xconf
+    <module name="resource"/>
+    <resource-type name="resource" workflow="fallback://config/workflow/workflow.xml"/>
+    
+    add to yourpub/config/ac/usecase-policies.xml
+    <usecase id="create.resource">
+      <role id="admin"/>
+      <role id="edit"/>
+    </usecase>  
+    <usecase id="upload.resource">
+      <role id="admin"/>
+      <role id="edit"/>
+    </usecase>  
+    
+]]>    
+  </lenya:installation>
+</lenya:module>

Propchange: lenya/trunk/src/modules/resource/module.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/resources/icons/default.gif
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/resources/icons/default.gif?rev=424292&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lenya/trunk/src/modules/resource/resources/icons/default.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lenya/trunk/src/modules/resource/resources/icons/default_med.gif
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/resources/icons/default_med.gif?rev=424292&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lenya/trunk/src/modules/resource/resources/icons/default_med.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lenya/trunk/src/modules/resource/resources/schemas/resource.rng
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/resources/schemas/resource.rng?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/resources/schemas/resource.rng (added)
+++ lenya/trunk/src/modules/resource/resources/schemas/resource.rng Fri Jul 21 05:50:59 2006
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2004 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.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: xhtml.rng 42702 2004-03-13 12:34:18Z gregor $ -->
+
+<!--+
+    | XHTML doctype
+    +-->
+
+<!--+
+    | Namespaces:
+    | lenya namespace is required for embedding assets.
+    +-->
+
+<grammar ns="http://www.w3.org/1999/xhtml"
+    xmlns="http://relaxng.org/ns/structure/1.0"
+    xmlns:xhtml="http://www.w3.org/1999/xhtml"
+    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
+    >
+
+<include href="fallback://lenya/modules/xhtml/resources/schemas/xhtml.rng"/>
+
+</grammar>

Propchange: lenya/trunk/src/modules/resource/resources/schemas/resource.rng
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/samples/resource.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/samples/resource.xml?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/samples/resource.xml (added)
+++ lenya/trunk/src/modules/resource/samples/resource.xml Fri Jul 21 05:50:59 2006
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dummy/>
\ No newline at end of file

Propchange: lenya/trunk/src/modules/resource/samples/resource.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/sitemap.xmap?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/sitemap.xmap (added)
+++ lenya/trunk/src/modules/resource/sitemap.xmap Fri Jul 21 05:50:59 2006
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright 1999-2004 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.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!-- $Id: doctypes.xmap 179488 2005-06-02 02:29:39Z gregor $ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <map:components>
+    <map:generators default="file">
+      <map:generator label="content" logger="sitemap.generator.directory"
+        name="lenyaMetaData" pool-max="16"
+        src="org.apache.lenya.cms.cocoon.generation.LenyaMetaDataGenerator"/>
+    </map:generators>
+    <map:serializers default="xhtml">
+      <map:serializer logger="sitemap.serializer.links" name="links" src="org.apache.lenya.cms.cocoon.serialization.LinkSerializer"/>
+    </map:serializers>
+  </map:components>
+  
+  <map:pipelines>
+    <!-- Generates the lenya metadata to be aggregated for each page -->
+    <map:pipeline>
+      <map:match pattern="lenyametadata.xml">
+        <map:generate type="lenyaMetaData">
+          <map:parameter name="docid" value="{page-envelope:document-id}"/>
+          <map:parameter name="lang" value="{page-envelope:document-language}"/>
+        </map:generate>
+        <map:serialize type="xml"/>
+      </map:match>
+    </map:pipeline>
+    <map:pipeline>
+      
+      <!-- View Revision? -->
+      <map:match pattern="*.xml">
+        <map:match type="step" pattern="view-revision">
+          <map:generate type="serverpages"
+            src="fallback://lenya/content/rc/view.xsp">
+          </map:generate>
+          <map:transform src="fallback://lenya/xslt/rc/toDoc.xsl"/>
+          <map:transform
+          src="fallback://lenya/modules/resource/xslt/resource2xhtml.xsl">
+          <map:parameter name="document-type" value="{page-envelope:document-type}"/>
+          <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
+          <map:parameter name="language"
+            value="{page-envelope:document-language}"/>
+          <map:parameter name="context-prefix"
+                value="{page-envelope:context-prefix}"/>
+          <map:parameter name="title" value="{dublincore:title}"/>
+          <map:parameter name="root" value="{base-url:{page-envelope:publication-id}:{page-envelope:area}}"/>
+        </map:transform>
+          <map:serialize type="xml"/>
+        </map:match>
+      </map:match>
+      
+      <!-- parametrized doctype matcher -->
+      <!-- pattern="{rendertype}" -->
+      <map:match pattern="*.xml">
+        <map:generate src="cocoon:/lenyametadata.xml"/>
+        <map:transform
+          src="fallback://lenya/modules/resource/xslt/resource2xhtml.xsl">
+          <map:parameter name="document-type" value="{page-envelope:document-type}"/>
+          <map:parameter name="nodeId" value="{page-envelope:document-name}"/>
+          <map:parameter name="documentId" value="{page-envelope:document-id}"/>
+          <map:parameter name="documentParent" value="{page-envelope:document-parent}"/>
+          <map:parameter name="language"
+            value="{page-envelope:document-language}"/>
+          <map:parameter name="context-prefix"
+                value="{page-envelope:context-prefix}"/>
+          <map:parameter name="title" value="{dublincore:title}"/>
+          <map:parameter name="root" value="{base-url:{page-envelope:publication-id}:{page-envelope:area}}"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+      <map:match pattern="icons/**.*">
+        <map:act type="resource-exists-enhanced">
+          <map:parameter name="url"
+            value="fallback://lenya/modules/resource/resources/icons/{1}.{2}"/>
+          <map:parameter name="type" value="file"/>
+          <map:read
+            src="fallback://lenya/modules/resource/resources/icons/{1}.{2}"/>
+        </map:act>
+        <map:read
+          src="fallback://lenya/modules/resource/resources/icons/default_med.gif"/>
+      </map:match>
+    </map:pipeline>
+    
+  </map:pipelines>
+</map:sitemap>
\ No newline at end of file

Propchange: lenya/trunk/src/modules/resource/sitemap.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/usecases/create-resource.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/usecases/create-resource.jx?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/usecases/create-resource.jx (added)
+++ lenya/trunk/src/modules/resource/usecases/create-resource.jx Fri Jul 21 05:50:59 2006
@@ -0,0 +1,269 @@
+<?xml version="1.0"?>
+<!--
+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.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!-- $Id: assets.jx 374391 2006-02-02 14:02:17Z andreas $ -->
+
+<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+  
+  <page:body>
+    <div class="lenya-box-title">
+      <i18n:text>New Document of type: Media</i18n:text>
+    </div>
+    <div class="lenya-box-body">
+      <form method="POST" enctype="multipart/form-data" id="form-add_asset">
+        <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+        <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+        <table class="lenya-table-noborder">
+          <tr>
+            <td colspan="2">
+              <jx:import uri="fallback://lenya/usecases/templates/messages.jx"/>
+            </td>
+          </tr>
+          <jx:if test="${!usecase.getParameter('documentIdProvided')}">
+            <tr>
+              <td class="lenya-entry-caption">
+                <i18n:text>Parent ID</i18n:text>:</td>
+              <td>
+                <jx:out value="${usecase.getParameter('parentId')}"/>
+              </td>
+            </tr>
+          </jx:if>
+          <tr>
+            <td class="lenya-entry-caption"><label for="file">
+              <i18n:text>File</i18n:text> *</label></td>
+            <td><input type="file" name="file" class="lenya-form-element"/></td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">
+              <label for="documentId"><i18n:text>Document ID</i18n:text>*:
+              </label></td>
+            <td>
+              <jx:choose>
+                <jx:when test="${usecase.getParameter('documentIdProvided')}">
+                  <jx:out value="${usecase.getParameter('documentId')}"/>
+                </jx:when>
+                <jx:otherwise>
+                  <input class="lenya-form-element" type="text" name="documentId"
+                    value="${usecase.getParameter('documentId')}"/>
+                  <br/> (<i18n:text>No whitespace, no special characters</i18n:text>)
+                </jx:otherwise>
+              </jx:choose>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">
+              <label for="title"><i18n:text>Navigation Title</i18n:text>*:
+              </label></td>
+            <td>
+              <input class="lenya-form-element" type="text" name="title"
+                value="${usecase.getParameter('title')}"/>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">
+              <label for="visibleinnav"><i18n:text>Document visible in
+                Navigation</i18n:text>*:
+              </label></td>
+            <jx:set var="visible" value="yes"/>
+            <jx:if
+              test="${usecase.getParameter('visibleInNav').equals('false')}">
+              <jx:set var="visible" value="no"/>
+            </jx:if>
+            <td>
+              <select class="lenya-form-element" name="visibleInNav">
+                <jx:choose>
+                  <jx:when test="${visible.equals('yes')}">
+                    <option value="true" selected="selected">
+                      <i18n:text>yes</i18n:text></option>
+                    <option value="false"><i18n:text>no</i18n:text></option>
+                  </jx:when>
+                  <jx:otherwise>
+                    <option value="true"><i18n:text>yes</i18n:text></option>
+                    <option value="false" selected="selected">
+                      <i18n:text>no</i18n:text></option>
+                  </jx:otherwise>
+                </jx:choose>
+              </select>
+            </td>
+          </tr>
+          <jx:if test="${!usecase.getParameter('documentIdProvided')}">
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="relation"><i18n:text>Relation</i18n:text>*:
+                </label>
+              </td>
+              <td>
+                <jx:forEach var="relation"
+                  items="${usecase.getParameter('relations')}">
+                  <jx:choose>
+                    <jx:when
+                      test="${relation.equals(usecase.getParameter('relation'))}">
+                      <input type="radio" name="relation" value="${relation}"
+                        checked="checked"/><i18n:text>${relation}</i18n:text>
+                    </jx:when>
+                    <jx:otherwise>
+                      <input type="radio" name="relation" value="${relation}"/>
+                      <i18n:text>${relation}</i18n:text>
+                    </jx:otherwise>
+                  </jx:choose>
+                </jx:forEach>
+              </td>
+            </tr>
+          </jx:if>
+          <jx:set var="languages" value="${usecase.getParameter('languages')}"/>
+          <jx:choose>
+            <jx:when test="${languages.size() &gt; 1}">
+              <tr>
+                <td class="lenya-entry-caption">
+                  <label for="language"><i18n:text>Language</i18n:text>*:
+                  </label></td>
+                <td>
+                  <select class="lenya-form-element" name="language">
+                    <jx:forEach var="language"
+                      items="${usecase.getParameter('languages')}">
+                      <option value="${language}">${language}</option>
+                    </jx:forEach>
+                  </select>
+                </td>
+              </tr>
+            </jx:when>
+            <jx:otherwise>
+              <tr>
+                <td colspan="2">
+                  <jx:set var="language" value="${languages[0]}"/>
+                  <input type="hidden" name="language" value="${language}"/>
+                </td>
+              </tr>
+            </jx:otherwise>
+          </jx:choose>
+          <tr>
+            <td class="lenya-entry-caption">
+              <label for="creator"><i18n:text>Creator</i18n:text>:</label></td>
+            <td>
+              <input class="lenya-form-element" type="text" name="creator"
+                value="${usecase.getParameter('creator')}"/>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">
+              <label for="subject"><i18n:text>Subject</i18n:text>:</label></td>
+            <td>
+              <input class="lenya-form-element" type="text" name="subject"
+                value="${usecase.getParameter('subject')}"/>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">
+              <label for="publisher"><i18n:text>Publisher</i18n:text>:</label>
+            </td>
+            <td>
+              <input class="lenya-form-element" type="text" name="publisher"
+                value="${usecase.getParameter('publisher')}"/>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">
+              <i18n:text>Date</i18n:text>:</td>
+            <td>
+              <jx:out value="${usecase.getParameter('date')}"/>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">
+              <label for="rights"><i18n:text>Rights</i18n:text>:</label></td>
+            <td>
+              <input class="lenya-form-element" type="text" name="rights"
+                value="${usecase.getParameter('rights')}"/>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption"><label for="myMeta"><i18n:text>My
+              custom metadata</i18n:text>:</label></td>
+            <td>
+              <input type="text" id="myMeta" name="meta.custom.myMeta"
+                class="lenya-form-element"
+                value="${usecase.getParameter('meta.custom.myMeta')}"/>
+            </td>
+          </tr>
+          <jx:set var="resourceTypes"
+            value="${usecase.getParameter('resourceTypes')}"/>
+          <jx:if test="${resourceTypes.size()  &gt; 0}">
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="sample"><i18n:text>Resource Type</i18n:text>:</label>
+              </td>
+              <td>
+                <select name="doctype">
+                  <jx:forEach var="item" items="${resourceTypes}">
+                    <jx:choose>
+                      <jx:when
+                        test="${usecase.getParameter('doctype').equals(item)}">
+                        <option value="${item}" selected="selected">
+                          ${item}</option>
+                      </jx:when>
+                      <jx:otherwise>
+                        <option value="${item}">${item}</option>
+                      </jx:otherwise>
+                    </jx:choose>
+                  </jx:forEach>
+                </select>
+              </td>
+            </tr>
+          </jx:if>
+          <jx:set var="samples" value="${usecase.getParameter('samples')}"/>
+          <jx:if test="${samples.size() &gt; 0}">
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="sample"><i18n:text>Page Layout</i18n:text>:</label>
+              </td>
+              <td>
+                <jx:forEach var="item" items="${samples}">
+                  <jx:choose>
+                    <jx:when
+                      test="${usecase.getParameter('sample').equals(item)}">
+                      <input type="radio" name="sample" value="${item}"
+                        checked="checked"/>${item}<br/>
+                    </jx:when>
+                    <jx:otherwise>
+                      <input type="radio" name="sample" value="${item}"/>
+                      ${item}<br/>
+                    </jx:otherwise>
+                  </jx:choose>
+                </jx:forEach>
+              </td>
+            </tr>
+          </jx:if>
+          <tr>
+            <td class="lenya-entry-caption">*
+              <i18n:text>required fields</i18n:text>
+            </td>
+          </tr>
+          <tr>
+            <td/>
+            <td>
+              <input i18n:attr="value" name="submit" type="submit"
+                value="New Asset"/>
+            </td>
+          </tr>
+        </table>
+      </form>
+    </div>
+  </page:body>
+</page:page>
\ No newline at end of file

Added: lenya/trunk/src/modules/resource/usecases/upload-resource.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/usecases/upload-resource.jx?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/usecases/upload-resource.jx (added)
+++ lenya/trunk/src/modules/resource/usecases/upload-resource.jx Fri Jul 21 05:50:59 2006
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+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.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!-- $Id: assets.jx 374391 2006-02-02 14:02:17Z andreas $ -->
+
+<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+  
+  <page:body>
+    <div class="lenya-box-title">
+      <i18n:text>Upload Resource</i18n:text>
+    </div>
+    <div class="lenya-box-body">
+      <form method="POST" enctype="multipart/form-data" id="form-upload">
+        <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+        <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+        <table class="lenya-table-noborder">
+          <tr>
+            <td colspan="2">
+              <jx:import uri="fallback://lenya/usecases/templates/messages.jx"/>
+            </td>
+          </tr>
+          <tr>
+            <td colspan="2">
+              <strong><i18n:text>WARNING:</i18n:text> <i18n:text>The existing document will be overwritten!</i18n:text></strong>
+            </td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption"><label for="file">
+              <i18n:text>File</i18n:text> *</label></td>
+            <td><input type="file" name="file" class="lenya-form-element"/></td>
+          </tr>
+          <tr>
+            <td class="lenya-entry-caption">*
+              <i18n:text>required fields</i18n:text>
+            </td>
+          </tr>
+          <tr>
+            <td/>
+            <td>
+              <input i18n:attr="value" name="submit" type="submit"
+                value="Upload Resource"/>
+            </td>
+          </tr>
+        </table>
+      </form>
+    </div>
+  </page:body>
+</page:page>

Added: lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl (added)
+++ lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl Fri Jul 21 05:50:59 2006
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- $Id: mimetype.xsl 9187 2005-12-22 15:53:21Z josias $ -->
+
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
+    xmlns:xhtml="http://www.w3.org/1999/xhtml"
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:media="http://apache.org/lenya/pubs/default/media/1.0"    
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+    xmlns:dcterms="http://purl.org/dc/terms/"
+    exclude-result-prefixes="xhtml lenya dc">
+    
+  <xsl:template name="icon">
+    <xsl:param name="mimetype"/>
+    <xsl:param name="imageprefix"/>
+    
+    <xsl:choose>
+      <!-- Audio file types -->
+      <xsl:when test="$mimetype = 'audio/x-aiff'">
+        <img src="{$imageprefix}/icons/aif_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'audio/mpeg'">
+        <img src="{$imageprefix}/icons/mp3_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'audio/x-pn-realaudio'">
+        <img src="{$imageprefix}/icons/rm_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'audio/x-wav'">
+        <img src="{$imageprefix}/icons/wav_med.gif" border="0" alt=""/>
+      </xsl:when>
+
+      <!-- Video file types -->
+      <xsl:when test="$mimetype = 'video/x-msvideo'">
+        <img src="{$imageprefix}/icons/avi_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'video/quicktime'">
+        <img src="{$imageprefix}/icons/mov_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'video/mpeg'">
+        <img src="{$imageprefix}/icons/mpg_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'video/x-ms-wmv'">
+        <img src="{$imageprefix}/icons/wmv_med.gif" border="0" alt=""/>
+      </xsl:when>
+
+      <!-- Image file types -->
+      <xsl:when test="$mimetype = 'image/gif'">
+        <img src="{$imageprefix}/icons/gif_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/png'">
+        <img src="{$imageprefix}/icons/png_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/x-png'">
+        <img src="{$imageprefix}/icons/png_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/jpeg'">
+        <img src="{$imageprefix}/icons/jpg_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/pjpeg'">
+        <img src="{$imageprefix}/icons/jpg_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/tiff'">
+        <img src="{$imageprefix}/icons/tif_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/bmp'">
+        <img src="{$imageprefix}/icons/bmp_med.gif" border="0" alt=""/>
+      </xsl:when>
+ 
+      <!-- Compressed file types -->
+      <xsl:when test="$mimetype = 'application/x-bzip2'">
+        <img src="{$imageprefix}/icons/bz2_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/x-gzip'">
+        <img src="{$imageprefix}/icons/gz_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/x-tar'">
+        <img src="{$imageprefix}/icons/tgz_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/zip'">
+        <img src="{$imageprefix}/icons/zip_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/x-zip-compressed'">
+        <img src="{$imageprefix}/icons/zip_med.gif" border="0" alt=""/>
+      </xsl:when>
+
+      <!-- Text file types -->
+      <xsl:when test="$mimetype = 'application/rtf'">
+        <img src="{$imageprefix}/icons/rtf_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/pdf'">
+        <img src="{$imageprefix}/icons/pdf_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/x-pdf'">
+        <img src="{$imageprefix}/icons/pdf_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'text/plain'">
+        <img src="{$imageprefix}/icons/txt_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'text/html'">
+        <img src="{$imageprefix}/icons/html_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'text/xml'">
+        <img src="{$imageprefix}/icons/xml_med.gif" border="0" alt=""/>
+      </xsl:when>
+
+      <!-- Application file types -->
+      <xsl:when test="$mimetype = 'application/octet-stream'">
+        <img src="{$imageprefix}/icons/exe_med.gif" border="0" alt=""/>
+      </xsl:when>
+
+      <!-- Multimedia file types -->
+      <xsl:when test="$mimetype = 'application/x-shockwave-flash'">
+        <img src="{$imageprefix}/icons/swf_med.gif" border="0" alt=""/>
+      </xsl:when>
+
+      <!-- Microsft Office file types -->
+      <xsl:when test="$mimetype = 'application/msword'">
+        <img src="{$imageprefix}/icons/doc_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/vnd.ms-excel'">
+        <img src="{$imageprefix}/icons/xls_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/x-excel'">
+        <img src="{$imageprefix}/icons/xls_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/vnd.ms-powerpoint'">
+        <img src="{$imageprefix}/icons/ppt_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/mspowerpoint'">
+        <img src="{$imageprefix}/icons/ppt_med.gif" border="0" alt=""/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'application/powerpoint'">
+        <img src="{$imageprefix}/icons/ppt_med.gif" border="0" alt=""/>
+      </xsl:when>
+
+      <!-- Unknown file types -->
+      <xsl:otherwise>
+        <img src="{$imageprefix}/icons/default_med.gif" border="0" alt=""/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  
+  <xsl:template name="preview">
+    <xsl:param name="mimetype"/>
+    <xsl:param name="mediaURI"/>
+    
+    <xsl:choose>
+      <xsl:when test="$mimetype = 'image/gif'">
+        <img src="{$mediaURI}" border="1" alt="preview"/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/png'">
+        <img src="{$mediaURI}" border="1" alt="preview"/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/x-png'">
+        <img src="{$mediaURI}" border="1" alt="preview"/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/jpeg'">
+        <img src="{$mediaURI}" border="1" alt="preview"/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/pjpeg'">
+        <img src="{$mediaURI}" border="1" alt="preview"/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/tiff'">
+        <img src="{$mediaURI}" border="1" alt="preview"/>
+      </xsl:when>
+      <xsl:when test="$mimetype = 'image/bmp'">
+        <img src="{$mediaURI}" border="1" alt="preview"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <i><i18n:text>No preview avalable for this resource</i18n:text></i>
+      </xsl:otherwise>
+      
+    </xsl:choose> 
+  </xsl:template>
+</xsl:stylesheet>

Propchange: lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl?rev=424292&view=auto
==============================================================================
--- lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl (added)
+++ lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl Fri Jul 21 05:50:59 2006
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- $Id: xhtml-standard.xsl,v 1.44 2004/12/14 11:00:41 josias Exp $ -->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:meta="http://apache.org/cocoon/lenya/metadata/1.0"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"
+  xmlns:media="http://apache.org/lenya/pubs/default/media/1.0"
+  xmlns:mediameta="http://apache.org/lenya/metadata/media/1.0"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns:dcterms="http://purl.org/dc/terms/"
+  exclude-result-prefixes="xhtml meta dc">
+  
+  <xsl:import href="fallback://lenya/modules/resource/xslt/common/mimetype.xsl"/>
+  <xsl:include href="fallback://lenya/modules/xhtml/xslt/helper-object.xsl"/>
+  <xsl:param name="root"/> <!-- the URL up to (including) the area -->
+  <xsl:param name="documentId"/>
+  <xsl:param name="context-prefix" select="''"/>
+  <xsl:param name="language"/>
+  <xsl:param name="document-type"/>
+  <xsl:param name="documentParent"/>
+  <xsl:param name="title"/>
+  <xsl:variable name="imageprefix"
+    select="concat($context-prefix,'/modules/resource')"/>
+  <xsl:variable name="nodeid"
+    select="concat($context-prefix,$root,$documentParent)"/>
+  
+  <xsl:template match="/">
+    <xhtml:div id="body">
+      <xsl:apply-templates select="//meta:metadata" mode="media"/>
+    </xhtml:div>
+  </xsl:template>
+    
+  <xsl:template match="meta:metadata" mode="media">
+    
+    <xsl:variable name="mediaName" select="concat($documentId, '.', mediameta:elements/mediameta:filename)"/>
+    
+    <xsl:variable name="mediaURI">
+      <xsl:value-of select="$root"/>
+      <xsl:value-of select="$mediaName"/>
+    </xsl:variable>
+    
+    <xsl:variable name="size">
+      <xsl:choose>
+        <xsl:when test="mediameta:elements/mediameta:extent = ''">??</xsl:when>
+        <xsl:otherwise><xsl:value-of
+          select="format-number(mediameta:elements/mediameta:extent div 1024, '#,###.##')"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    
+    <table width="500" cellpadding="2" cellspacing="0" border="0" bgcolor="#f2f2f2"
+      style="border-width:1pt;border-color:#d6d6d6;border-style:line">
+      <tr>
+        <td> <a href="{$mediaURI}" target="_new">
+          <xsl:call-template name="icon">
+            <xsl:with-param name="mimetype"
+              select="mediameta:elements/mediameta:format"/>
+            <xsl:with-param name="imageprefix" select="$imageprefix"/>
+          </xsl:call-template> </a>
+        </td>
+        <td><h1><i18n:text>Resource Document</i18n:text></h1></td>
+      </tr>
+      <tr>
+        <td><i><i18n:text>Title</i18n:text>:</i></td>
+        <td><strong><xsl:value-of select="dc:elements/dc:title"/></strong></td>
+      </tr>
+      <tr>
+        <td><i><i18n:text>Description</i18n:text>:</i></td>
+        <td><xsl:value-of select="dc:elements/dc:description"/></td>
+      </tr>
+      <tr>
+        <td><i><i18n:text>Content</i18n:text>:</i></td>
+        <td><a href="{$mediaURI}" target="_new"><xsl:value-of select="$mediaName"/>
+          </a></td>
+      </tr>
+      <tr>
+        <td><i><i18n:text>Size</i18n:text>:</i></td>
+        <td><xsl:value-of select="$size"/> KB</td>
+      </tr>
+      <tr>
+        <td><i><i18n:text>MimeType</i18n:text>:</i></td>
+        <td><xsl:value-of select="mediameta:elements/mediameta:format"/></td>
+      </tr>
+      <xsl:if test="mediameta:elements/mediameta:width != ''">
+        <tr>
+          <td><i><i18n:text>Dimension</i18n:text>:</i></td>
+          <td><xsl:value-of select="mediameta:elements/mediameta:width"/>x
+            <xsl:value-of select="mediameta:elements/mediameta:height"/></td>
+        </tr>
+      </xsl:if>
+      <tr>
+        <td colspan="2"><i><i18n:text>Preview</i18n:text>:</i><br/><br/>
+        <div align="center">
+          <xsl:call-template name="preview">
+            <xsl:with-param name="mimetype"
+              select="mediameta:elements/mediameta:format"/>
+            <xsl:with-param name="mediaURI" select="$mediaURI"/>
+          </xsl:call-template><br/><br/>
+        </div>
+        </td>
+      </tr>
+    </table>
+
+  </xsl:template>
+  
+  <xsl:template match="@*|node()" priority="-1">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+  
+</xsl:stylesheet>

Propchange: lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl
------------------------------------------------------------------------------
    svn:eol-style = native



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