You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Maciek Kaminski <ma...@tiger.com.pl> on 2005/01/03 18:09:45 UTC

inital document upload [waz document upload]

Here is my first prototype of "initial document uploading".

The most important modification is in config/tasks/targets.xml, where
I've modified target create in to validate uploaded document and
replace with default one. Additionaly when uploaded file seems to be
in OpenOffice writer format it gets converted to xhtml by convert task
based on writer2latex:

    <target name="create">   
    <property name="create.parent-id" value=""/>
    <property name="create.child-id" value=""/>
    <property name="create.child-name" value=""/>
    <property name="create.init-file" value=""/>
    <property name="create.child-type" value=""/>
    <property name="create.doctype" value=""/>
    <property name="create.language" value=""/>
    <property name="create.title" value=""/>
    <property name="create.creator" value=""/>
    <property name="create.description" value=""/>
    <property name="create.subject" value=""/>
    <property name="create.publisher" value=""/>
    <property name="create.date" value=""/>
    <property name="create.rights" value=""/>
    <property name="create.columns" value=""/>
    <property name="create.userid" value=""/>
    <property name="create.ipaddress" value=""/>
    <property name="create.filename" value=""/>

    <echo>create-with-init-file: ${create.filename}</echo>
    <echo>create.doctype: ${create.doctype}</echo>

    <property name="document.file" value=""/>
    <mapdocumentidtofile
        area="${authoring.area}"
        documentid="${create.parent-id}/${create.child-id}"
        language="${create.language}"
        propertyname="document.file"
        />
        <!--
             Here conversion to html and validation takes place.
             I use here if task from ant contrib project
             (http://ant-contrib.sourceforge.net/)
             and convert task based on writer2latex project
             (http://www.hj-gym.dk/~hj/writer2latex/).
        -->
    <if>
        <and>
        <isset property="create.filename"/>
        <not><equals arg1="${create.filename}" arg2=""/></not>
        <equals arg1="${create.doctype}" arg2="xhtml"/>
        </and>
        <then>
        <if>
            <and>
            <contains string="${create.filename}" substring=".sxw"/>
            <equals arg1="${create.doctype}" arg2="xhtml"/>
            </and>
            <then>
                        <tempfile property="temp.file" suffix=".xhtml"/>
            <convertsxw
                inFile="${create.filename}"
                outFile="${temp.file}"
                outputFormat="xhtml"
                configFile="${pub.dir}/config/tasks/cleanxhtml.xml"/>
            <xslt in="${temp.file}"
                  out="${create.filename}"
                  force="true"
                  style="${pub.dir}/xslt/fixw2l.xslt"/>
                        <delete file="${temp.file}"/>
            </then>
            <else>
            <jing 
rngfile="${pub.dir}/config/doctypes/schemas/${create.doctype}.rng">
                <fileset file="{create.filename}"/>
            </jing>
            </else>
        </if>
        </then>
    </if>

    <taskdef name="create" 
classname="org.apache.lenya.cms.ant.DocumentCreatorTask"/>
    <create
        authoringpath="${authoring.dir}"
        area="${authoring.area}"
        parentid="${create.parent-id}"
        childid="${create.child-id}"
        childname="${create.child-name}"
        childtype="${create.child-type}"
        documenttype="${create.doctype}"
        language="${create.language}"/>

    <if>
        <and>
        <isset property="create.filename"/>
        <not><equals arg1="${create.filename}" arg2=""/></not>
        </and>
        <then>
        <move file="${create.filename}" tofile="${document.file}"/>     
        </then>
    </if>
   
    <!-- Init the workflow history -->
    <echo>init the workflow history with document-id: 
${create.parent-id}/${create.child-id}</echo>     
    <echo>with document-type: ${create.doctype}</echo>     
    <echo>with language: ${create.language}</echo>     
    <echo>with user ID: ${create.userid}</echo>     
    <echo>with IP address: ${create.ipaddress}</echo>     
    <init-history
        documentid="${create.parent-id}/${create.child-id}"
        documenttype="${create.doctype}"
        language="${create.language}"
        userid="${create.userid}"
        machineip="${create.ipaddress}"
        />
   
    <tempfile property="temp.file" destDir="work"/>
    <xslt in="${document.file}"
          out="${temp.file}"
          force="true"
          style="${pub.dir}/../../xslt/authoring/addMetaData.xsl">
        <param name="title" expression="${create.title}"/>
        <param name="creator" expression="${create.creator}"/>
        <param name="subject" expression="${create.subject}"/>
        <param name="description" expression="${create.description}"/>
        <param name="language" expression="${create.language}"/>
        <param name="publisher" expression="${create.publisher}"/>
        <param name="date" expression="${create.date}"/>
        <param name="rights" expression="${create.rights}"/>
        <param name="columns" expression="${create.columns}"/>
    </xslt>
    <move file="${temp.file}" tofile="${document.file}"/>
    </target>

To have documents uploaded the lenya/xslt/authoring/create.xsp had to be 
modified:
at line 134:
        <tr>
          <td class="lenya-entry-caption"><i18n:text>File 
Name</i18n:text>:</td><td><input class="lenya-form-element" type="file" 
name="properties.create.filename"/></td>
        </tr>

This prototype works but it is far from optimal solution. Here are the
problems that I need strategic advice on:  
- what idea lays behind puting cms routines into ant tasks?  
- should uploaded document validation and conversion be executed inside
targets.xml? It is rather part of document creation logic, no user 
interface,
 so from that point of view it should go to targets.xml.
But there is no graceful way (at least I don't know of any) to return 
validation
result back to user interface (i.e. sitemap).

Maciej Kaminski

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


Re: inital document upload [waz document upload]

Posted by "Gregor J. Rothfuss" <gr...@apache.org>.
Maciek Kaminski wrote:
> Here is my first prototype of "initial document uploading".


> This prototype works but it is far from optimal solution. Here are the
> problems that I need strategic advice on:  - what idea lays behind 
> puting cms routines into ant tasks? 

there is currently a discussion about this on the dev list. the original 
idea was to make it easy to extend lenya.

- should uploaded document
> validation and conversion be executed inside
> targets.xml? It is rather part of document creation logic, no user 
> interface,
> so from that point of view it should go to targets.xml.
> But there is no graceful way (at least I don't know of any) to return 
> validation
> result back to user interface (i.e. sitemap).

yes, this is indeed one of the problems with ant tasks. i would suggest 
you take a look at the new usecase framework in 1.4 that solves these 
things more elegantly.

i would also suggest to take this discussion over to the dev list.

-- 
Gregor J. Rothfuss
COO, Wyona       Content Management Solutions    http://wyona.com
Apache Lenya                              http://lenya.apache.org
gregor.rothfuss@wyona.com                       gregor@apache.org

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