Changeset 172:c08736afb365

Show
Ignore:
Timestamp:
09/23/08 13:53:58 (5 years ago)
Author:
jean-gui
Branch:
default
convert_revision:
svn:cdcfb263-7567-472c-a848-e2c2df3466e7/trunk@173
Message:

Fixed encoding issues with Jigsaw + simplified build.xml and added a jigsaw task

Files:
1 removed
10 modified

Legend:

Unmodified
Added
Removed
  • build.xml

    r169 r172  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <!DOCTYPE project [<!ENTITY buildfile SYSTEM "./build-user.xml">]> 
    3 <!-- WARNING: Eclipse autogenerated file.  
    4               Any modifications will be overwritten. 
    5               Please edit build-user.xml instead. 
    6 --> 
    72<project name="unicorn" default="build" basedir="."> 
    8     &buildfile; 
    9     <property name="unicorn.location" value="."/> 
    10  
    11         <!-- Configure properties to access the Manager application --> 
    12         <property name="url"      value="http://flyingman.sophia.w3.org:8180/manager"/> 
     3  <property name="unicorn.location" value="."/> 
     4   
     5  <property name="app.name" value="unicorn"/> 
     6  <property name="jar.file" value="${app.name}.jar"/> 
     7  <property name="war.file" value="${app.name}.war"/> 
     8   
     9  <!-- Configure properties to access the Manager application --> 
     10  <property name="url"      value="http://flyingman.sophia.w3.org:8180/manager"/> 
    1311        <property name="username" value="manager"/> 
    1412        <property name="password" value="******"/> 
    1513         
    1614    <path id="project.classpath"> 
    17         <pathelement location="."/> 
    18         <pathelement location="${unicorn.location}/lib/activation.jar"/> 
    19         <pathelement location="${unicorn.location}/lib/commons-collections-3.1.jar"/> 
    20         <pathelement location="${unicorn.location}/lib/commons-fileupload-1.1.1.jar"/> 
    21         <pathelement location="${unicorn.location}/lib/commons-io-1.2.jar"/> 
    22         <pathelement location="${unicorn.location}/lib/commons-logging-1.1.jar"/> 
    23         <pathelement location="${unicorn.location}/lib/icu4j_3_4.jar"/> 
    24         <pathelement location="${unicorn.location}/lib/iri.jar"/> 
    25         <pathelement location="${unicorn.location}/lib/jena.jar"/> 
    26         <pathelement location="${unicorn.location}/lib/jsr173_1.0_api.jar"/> 
    27         <pathelement location="${unicorn.location}/lib/log4j-1.2.12.jar"/> 
    28         <pathelement location="${unicorn.location}/lib/servlet.jar"/> 
    29         <pathelement location="${unicorn.location}/lib/velocity-1.5-dev.jar"/> 
    30         <pathelement location="${unicorn.location}/lib/xercesImpl.jar"/> 
     15      <pathelement location="."/> 
     16      <pathelement location="${unicorn.location}/lib/activation.jar"/> 
     17      <pathelement location="${unicorn.location}/lib/commons-collections-3.1.jar"/> 
     18      <pathelement location="${unicorn.location}/lib/commons-fileupload-1.1.1.jar"/> 
     19      <pathelement location="${unicorn.location}/lib/commons-io-1.2.jar"/> 
     20      <pathelement location="${unicorn.location}/lib/commons-logging-1.1.jar"/> 
     21      <pathelement location="${unicorn.location}/lib/icu4j_3_4.jar"/> 
     22      <pathelement location="${unicorn.location}/lib/iri.jar"/> 
     23      <pathelement location="${unicorn.location}/lib/jena.jar"/> 
     24      <pathelement location="${unicorn.location}/lib/jsr173_1.0_api.jar"/> 
     25      <pathelement location="${unicorn.location}/lib/log4j-1.2.12.jar"/> 
     26      <pathelement location="${unicorn.location}/lib/servlet.jar"/> 
     27      <pathelement location="${unicorn.location}/lib/velocity-1.5-dev.jar"/> 
     28      <pathelement location="${unicorn.location}/lib/xercesImpl.jar"/> 
    3129        <pathelement location="${unicorn.location}/lib/catalina-ant.jar"/> 
    3230        <pathelement location="${unicorn.location}/lib/observationresponse.jar"/> 
     
    4240    </path> 
    4341         
    44         <!-- Configure the custom Ant tasks for the Manager application --> 
    45         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="deploy" classname="org.apache.catalina.ant.DeployTask"/> 
    46         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="list"      classname="org.apache.catalina.ant.ListTask"/> 
    47         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="reload"    classname="org.apache.catalina.ant.ReloadTask"/> 
    48         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="resources" classname="org.apache.catalina.ant.ResourcesTask"/> 
    49         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="roles"     classname="org.apache.catalina.ant.RolesTask"/> 
    50         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="start"     classname="org.apache.catalina.ant.StartTask"/> 
    51         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="stop"      classname="org.apache.catalina.ant.StopTask"/> 
    52         <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"/> 
    53          
    54          
     42    <!-- Configure the custom Ant tasks for the Manager application --> 
     43    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="deploy" classname="org.apache.catalina.ant.DeployTask"/> 
     44    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="list"      classname="org.apache.catalina.ant.ListTask"/> 
     45    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="reload"    classname="org.apache.catalina.ant.ReloadTask"/> 
     46    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="resources" classname="org.apache.catalina.ant.ResourcesTask"/> 
     47    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="roles"     classname="org.apache.catalina.ant.RolesTask"/> 
     48    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="start"     classname="org.apache.catalina.ant.StartTask"/> 
     49    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="stop"      classname="org.apache.catalina.ant.StopTask"/> 
     50    <taskdef classpath="${unicorn.location}/lib/catalina-ant.jar" name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"/>    
    5551         
    5652    <target name="init"> 
     
    6157    </target> 
    6258    <target name="build" depends="init"> 
     59        <echo message="${ant.project.name}: ${ant.file}"/> 
     60        <javac destdir="build" debug="on" debuglevel="lines,vars,source"> 
     61            <src path="."/> 
     62            <exclude name="lib/"/> 
     63            <classpath refid="project.classpath"/> 
     64        </javac> 
     65    </target> 
     66    <target name="jigsaw"> 
    6367        <echo message="${ant.project.name}: ${ant.file}"/> 
    6468        <javac destdir="." debug="on" debuglevel="lines,vars,source"> 
     
    6872        </javac> 
    6973    </target> 
    70     <target name="Test (1)"> 
    71         <java fork="yes" classname="org.w3c.unicorn.generated.tasklist.Test" failonerror="true"> 
    72             <classpath refid="project.classpath"/> 
    73         </java> 
    74     </target> 
     74    <target name="index"> 
     75        <java fork="yes" classname="org.w3c.unicorn.index.IndexGenerator" failonerror="true"> 
     76            <classpath refid="project.classpath"/> 
     77        </java> 
     78    </target> 
     79 
     80    <target name="help"> 
     81      <echo message="Please run: $ ant -v -projecthelp"/> 
     82    </target> 
     83     
     84    <target name="remoteConfiguration"  depends="build" description="Workspace configuration for remote"> 
     85      <copy file="./org/w3c/unicorn/util/remote-unicorn.properties" 
     86            tofile="./build/org/w3c/unicorn/util/unicorn.properties" 
     87            overwrite="true"/> 
     88      <copy file="./remote_log4j.xml" 
     89            tofile="./build/log4j.xml" 
     90            overwrite="true"/> 
     91      <copy file="./org/w3c/unicorn/extensions.properties" 
     92            tofile="./build/org/w3c/unicorn/extensions.properties"  
     93            overwrite="true"/> 
     94      <copy file="./org/w3c/unicorn/responseParsers.properties" 
     95            tofile="./build/org/w3c/unicorn/responseParsers.properties"  
     96            overwrite="true"/> 
     97      <copy file="./org/w3c/unicorn/output/specialFormaters.properties"  
     98            tofile="./build/org/w3c/unicorn/output/specialFormaters.properties" 
     99            overwrite="true"/> 
     100    </target> 
     101     
     102    <target name="localConfiguration" depends="war" > 
     103      <copy file="./org/w3c/unicorn/util/local-unicorn.properties"  
     104            tofile="./build/org/w3c/unicorn/util/unicorn.properties" 
     105            overwrite="true"/> 
     106      <copy file="./log4j.xml" tofile="./build/log4j.xml" overwrite="true"/> 
     107      <copy file="./org/w3c/unicorn/extensions.properties"  
     108            tofile="./build/org/w3c/unicorn/extensions.properties"  
     109            overwrite="true"/> 
     110      <copy file="./org/w3c/unicorn/responseParsers.properties" 
     111            tofile="./build/org/w3c/unicorn/responseParsers.properties"  
     112            overwrite="true"/> 
     113      <copy file="./org/w3c/unicorn/output/specialFormaters.properties"  
     114            tofile="./build/org/w3c/unicorn/output/specialFormaters.properties"  
     115            overwrite="true"/> 
     116    </target> 
     117     
     118    <target name="make-war" depends="build" description="Creates the webapp module"> 
     119      <delete file="${war.file}"/> 
     120      <war warfile="${war.file}" webxml="web.xml" basedir="." excludes="*,**"> 
     121        <classes dir="build"> 
     122          <include name="org/**"/> 
     123        </classes> 
     124        <classes dir="."> 
     125          <exclude name="build/**"/> 
     126          <include name="build/**/*.properties"/> 
     127        </classes> 
     128        <classes file="./build/log4j.xml"/> 
     129        <webinf dir="."> 
     130          <include name="uploaded-files/**"/> 
     131          <include name="logs/**"/> 
     132        </webinf> 
     133        <lib dir="lib"/> 
     134        <zipfileset dir="images" prefix="images"/> 
     135        <zipfileset dir="style" prefix="style"/> 
     136        <zipfileset dir="resources" prefix="WEB-INF/resources"/> 
     137        <zipfileset dir="tabtastic" prefix="tabtastic"/> 
     138        <zipfileset dir="temporary_files" prefix="temporary_files"/> 
     139      </war> 
     140    </target> 
     141     
     142    <target name="war" depends="remoteConfiguration,make-war" /> 
     143     
     144    <target name="jar" depends="build" description="Creates the unicorn library"> 
     145      <delete file="${jar.file}" /> 
     146      <jar destfile="${jar.file}"> 
     147        <fileset dir="build"> 
     148          <include name="org/**/*.class" /> 
     149          <include name="**/*.properties" /> 
     150          <include name="log4j.xml" /> 
     151        </fileset> 
     152        <fileset dir="."> 
     153          <include name="org/**/*.java" /> 
     154        </fileset> 
     155      </jar> 
     156    </target> 
     157     
     158    <target name="deploy" description="Install web application" depends="war"> 
     159      <deploy url="${url}" username="${username}" password="${password}" path="/unicorn" 
     160              war="unicorn.war"/> 
     161    </target> 
     162     
     163    <target name="reload" description="Reload web application"> 
     164      <reload  url="${url}" username="${username}" password="${password}" path="/unicorn"/> 
     165    </target> 
     166     
     167    <target name="undeploy" description="Remove web application"> 
     168      <undeploy url="${url}" username="${username}" password="${password}" path="/unicorn"/> 
     169    </target>       
     170     
     171 
     172    <!-- Local tests --> 
     173 
    75174    <target name="CallParameter"> 
    76175        <java fork="yes" classname="org.w3c.unicorn.contract.methods.CallParameter" failonerror="true"> 
     
    88187        </java> 
    89188    </target> 
    90     <target name="WADLUnmarshallerXPath (1)"> 
    91         <java fork="yes" classname="org.w3c.unicorn.contract.wadl.WADLUnmarshallerXPath" failonerror="true"> 
    92             <classpath refid="project.classpath"/> 
    93         </java> 
    94     </target> 
    95189    <target name="TaskListUnmarshallerBeans"> 
    96190        <java fork="yes" classname="org.w3c.unicorn.tasklist.TaskListUnmarshallerBeans" failonerror="true"> 
     
    98192        </java> 
    99193    </target> 
    100     <target name="IndexGenerator"> 
    101         <java fork="yes" classname="org.w3c.unicorn.index.IndexGenerator" failonerror="true"> 
    102             <classpath refid="project.classpath"/> 
    103         </java> 
    104     </target> 
    105194    <target name="ListFiles"> 
    106195        <java fork="yes" classname="org.w3c.unicorn.util.ListFiles" failonerror="true"> 
     
    108197        </java> 
    109198    </target> 
    110          
    111     <target name="deploy" description="Install web application" depends="war"> 
    112         <deploy url="${url}" username="${username}" password="${password}" path="/unicorn" 
    113                     war="unicorn.war"/> 
    114     </target> 
    115  
    116         <target name="reload" description="Reload web application"> 
    117                 <reload  url="${url}" username="${username}" password="${password}" path="/unicorn"/> 
    118         </target> 
    119  
    120         <target name="undeploy" description="Remove web application"> 
    121                 <undeploy url="${url}" username="${username}" password="${password}" path="/unicorn"/> 
    122     </target>       
    123          
     199 
    124200</project> 
  • org/w3c/unicorn/index/IndexGenerator.java

    r169 r172  
    1 // $Id: IndexGenerator.java,v 1.5 2008-09-12 18:01:51 jean-gui Exp $ 
     1// $Id: IndexGenerator.java,v 1.6 2008-09-23 13:53:58 jean-gui Exp $ 
    22// Author: Jean-Guilhem Rouel 
    33// (c) COPYRIGHT MIT, ERCIM and Keio, 2006. 
     
    77import java.io.File; 
    88import java.io.FileNotFoundException; 
    9 import java.io.FileWriter; 
    109import java.io.IOException; 
    1110import java.net.MalformedURLException; 
    1211import java.net.URL; 
    1312import java.util.Properties; 
     13import java.io.OutputStreamWriter; 
     14import java.io.FileOutputStream; 
    1415 
    1516import org.apache.commons.logging.Log; 
     
    116117                                        .getTemplate(sName, "UTF-8"); 
    117118 
    118                         final FileWriter aFileWriter = new FileWriter(Property 
    119                                         .get("PATH_TO_INDEX_OUTPUT") 
    120                                         + sOutputName); 
     119      OutputStreamWriter aFileWriter = new OutputStreamWriter(new FileOutputStream(Property.get("PATH_TO_INDEX_OUTPUT")  
     120                                                                                   + sOutputName), 
     121                                                              "UTF-8"); 
    121122                        aTemplate.merge(IndexGenerator.aVelocityContext, aFileWriter); 
    122123                        aFileWriter.close(); 
  • org/w3c/unicorn/request/DirectRequestGET.java

    r168 r172  
    1 // $Id: DirectRequestGET.java,v 1.6 2008-09-10 10:10:40 jean-gui Exp $ 
     1// $Id: DirectRequestGET.java,v 1.7 2008-09-23 13:53:58 jean-gui Exp $ 
    22// Author: Damien LEROY. 
    33// (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. 
     
    103103                final URLConnection aURLConnection = aURL.openConnection(); 
    104104                aURLConnection.setRequestProperty("Accept-Language", this.sLang); 
     105 
    105106                InputStream is = aURLConnection.getInputStream(); 
    106107 
  • org/w3c/unicorn/request/DirectRequestPOST.java

    r168 r172  
    1 // $Id: DirectRequestPOST.java,v 1.8 2008-09-10 10:10:40 jean-gui Exp $ 
     1// $Id: DirectRequestPOST.java,v 1.9 2008-09-23 13:53:58 jean-gui Exp $ 
    22// Author: Damien LEROY. 
    33// (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. 
     
    127127                                "multipart/form-data; boundary=" + sBoundary); 
    128128                this.aURLConnection.setRequestProperty("Accept-Language", this.sLang); 
     129 
    129130                if (null == this.aOutputStream) { 
    130131                        this.aOutputStream = this.aURLConnection.getOutputStream(); 
  • org/w3c/unicorn/request/Request.java

    r168 r172  
    1 // $Id: Request.java,v 1.8 2008-09-10 10:10:40 jean-gui Exp $ 
     1// $Id: Request.java,v 1.9 2008-09-23 13:53:58 jean-gui Exp $ 
    22// Author: Damien LEROY. 
    33// (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. 
     
    144144          builder.append(chararray, 0, readLength); 
    145145      } 
    146        
     146 
    147147      Response res = ResponseParserFactory.parse(builder.toString(),  
    148148                                                 this.getResponseType()); 
  • org/w3c/unicorn/request/URIRequest.java

    r168 r172  
    1 // $Id: URIRequest.java,v 1.7 2008-09-10 10:10:40 jean-gui Exp $ 
     1// $Id: URIRequest.java,v 1.8 2008-09-23 13:53:58 jean-gui Exp $ 
    22// Author: Damien LEROY. 
    33// (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. 
     
    120120 
    121121                aURLConnection.setRequestProperty("Accept-Language", this.sLang); 
    122  
    123122                InputStream is = aURLConnection.getInputStream(); 
    124  
    125123                return streamToResponse(is); 
    126124        } 
  • org/w3c/unicorn/request/UploadRequest.java

    r168 r172  
    1 // $Id: UploadRequest.java,v 1.7 2008-09-10 10:10:40 jean-gui Exp $ 
     1// $Id: UploadRequest.java,v 1.8 2008-09-23 13:53:58 jean-gui Exp $ 
    22// Author: Damien LEROY. 
    33// (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. 
     
    108108                this.aClientHttpRequest = new ClientHttpRequest(sURL); 
    109109                UploadRequest.logger.debug("Lang : " + this.sLang + "."); 
    110                 this.aClientHttpRequest.setLang(sLang); // meme place que pour 
    111                                                                                                 // directpost 
     110                this.aClientHttpRequest.setLang(sLang); 
    112111                this.aClientHttpRequest.setParameter(this.sInputParameterName, 
    113112                                this.aUploadInputModule.getFileName(), this.aUploadInputModule 
  • org/w3c/unicorn/tests/FirstServlet.java

    r169 r172  
    1 // $Id: FirstServlet.java,v 1.12 2008-09-12 18:01:51 jean-gui Exp $ 
     1// $Id: FirstServlet.java,v 1.13 2008-09-23 13:53:58 jean-gui Exp $ 
    22// Author: Jean-Guilhem Rouel 
    33// (c) COPYRIGHT MIT, ERCIM and Keio, 2006. 
     
    5151        private static final long       serialVersionUID        = -1375355420965607571L; 
    5252 
    53         private static final DiskFileItemFactory factory = new DiskFileItemFactory();    
    54          
     53        private static final DiskFileItemFactory factory = new DiskFileItemFactory(); 
     54 
    5555        /** 
    5656         * Creates a new file upload handler. 
     
    9393        protected void doGet ( 
    9494                        final HttpServletRequest aHttpServletRequest, 
    95                         final HttpServletResponse aHttpServletResponse)  
     95                        final HttpServletResponse aHttpServletResponse) 
    9696        throws ServletException, IOException { 
    9797                FirstServlet.logger.trace("doGet"); 
     
    104104                mapOfOutputParameter.put("charset", "UTF-8"); 
    105105                mapOfOutputParameter.put("mimetype", "text/html"); 
    106                  
    107                 // Returns the preferred Locale that the client will accept content in,  
     106 
     107                // Returns the preferred Locale that the client will accept content in, 
    108108                // based on the Accept-Language header 
    109109                final String aLocale = convertEnumerationToString(aHttpServletRequest.getLocales()); 
    110                 final UnicornCall aUnicornCall = new UnicornCall();      
    111                  
     110                final UnicornCall aUnicornCall = new UnicornCall(); 
     111 
    112112                // Language of the template 
    113113                // ucn_lang is a parameter which is define in xx_index.html.vm. 
     
    120120                        templateLang = chooseTemplateLang(aLocale); 
    121121                } 
    122                  
     122 
    123123                mapOfOutputParameter.put("lang", templateLang); 
    124                  
     124 
    125125                if (null == aLocale) { 
    126126                        aUnicornCall.setLang(LocalizedString.DEFAULT_LANGUAGE); 
    127127                } else { 
    128                         aUnicornCall.setLang(templateLang + "," + aLocale);              
    129                 } 
    130          
     128                        aUnicornCall.setLang(templateLang + "," + aLocale); 
     129                } 
     130 
    131131                for ( 
    132132                                final Enumeration aEnumParamName = aHttpServletRequest.getParameterNames(); 
     
    134134                        final String sParamName = (String) aEnumParamName.nextElement(); 
    135135                        final String[] tStringParamValue = aHttpServletRequest.getParameterValues(sParamName); 
    136                          
     136 
    137137                        this.addParameter( 
    138138                                        sParamName, 
    139139                                        tStringParamValue, 
    140                                         aUnicornCall,  
     140                                        aUnicornCall, 
    141141                                        mapOfSpecificParameter, 
    142142                                        mapOfOutputParameter); 
     
    147147                        this.createError( 
    148148                                        aHttpServletResponse, 
    149                                         new NoTaskException(),  
    150                                         mapOfSpecificParameter, 
    151                                         mapOfOutputParameter);                   
     149                                        new NoTaskException(), 
     150                                        mapOfSpecificParameter, 
     151                                        mapOfOutputParameter); 
    152152                        return; 
    153153                } 
     
    167167                                        aHttpServletResponse, 
    168168                                        aException, 
    169                                         mapOfSpecificParameter,  
    170                                         mapOfOutputParameter); 
    171                 } 
    172         } 
    173          
     169                                        mapOfSpecificParameter, 
     170                                        mapOfOutputParameter); 
     171                } 
     172        } 
     173 
    174174        /* (non-Javadoc) 
    175175         * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 
    176176         */ 
    177177        @Override 
    178          
    179          
     178 
     179 
    180180        protected void doPost ( 
    181181                        final HttpServletRequest aHttpServletRequest, 
     
    183183        throws ServletException, IOException { 
    184184                FirstServlet.logger.trace("doPost"); 
    185                  
     185 
    186186                // Check that we have a file upload request 
    187187                final boolean bIsMultipart = ServletFileUpload.isMultipartContent( 
    188188                                new ServletRequestContext(aHttpServletRequest)); 
    189                  
     189 
    190190                if (!bIsMultipart) { 
    191191                        this.doGet(aHttpServletRequest, aHttpServletResponse); 
    192192                        return; 
    193193                } 
    194                  
     194 
    195195                // Parse the request 
    196196                final List listOfItem; 
    197                  
    198                 final UnicornCall aUnicornCall = new UnicornCall();      
    199                  
     197 
     198                final UnicornCall aUnicornCall = new UnicornCall(); 
     199 
    200200                // Variables related to the output 
    201201                final Map<String, String> mapOfOutputParameter = new Hashtable<String, String>(); 
     
    204204                mapOfOutputParameter.put("charset", "UTF-8"); 
    205205                mapOfOutputParameter.put("mimetype", "text/html"); 
    206                  
    207                 // Returns the preferred Locale that the client will accept content in,  
     206 
     207                // Returns the preferred Locale that the client will accept content in, 
    208208                // based on the Accept-Language header 
    209209                final String aLocale = convertEnumerationToString(aHttpServletRequest.getLocales()); 
    210                  
    211                  
     210 
     211 
    212212                // Language of the template 
    213213                // ucn_lang is a parameter which is define in xx_index.html.vm. 
    214214                // It is an hidden parameter of a form. 
    215215                String templateLang = null; 
    216                  
     216 
    217217                FirstServlet.logger.trace("doPost"); 
    218                  
    219                  
    220                  
    221          
     218 
     219 
     220 
     221 
    222222                final Map<String, String[]> mapOfSpecificParameter = new Hashtable<String, String[]>(); 
    223                  
     223 
    224224                FileItem aFileItemUploaded = null; 
    225                  
    226                  
     225 
     226 
    227227                try { 
    228228                        listOfItem = FirstServlet.upload.parseRequest(aHttpServletRequest); 
    229                          
    230                          
     229 
     230 
    231231                        // Process the uploaded items 
    232232                        for (final Iterator aIterator = listOfItem.iterator(); aIterator.hasNext();) { 
    233233                                final FileItem aFileItem = (FileItem) aIterator.next(); 
    234                                 if (aFileItem.isFormField()) {                                   
    235                                          
     234                                if (aFileItem.isFormField()) { 
     235 
    236236                                        if(aFileItem.getFieldName().equals("ucn_lang")) { 
    237237                                                templateLang = aFileItem.getString(); 
    238238                                        } 
    239                                          
    240                                          
     239 
     240 
    241241                                        addParameter(aFileItem.getFieldName(), aFileItem.getString(), 
    242242                                                        aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter); 
    243                                          
    244                                 } else if(aFileItem.getFieldName().equals("ucn_file")) {         
     243 
     244                                } else if(aFileItem.getFieldName().equals("ucn_file")) { 
    245245                                        aFileItemUploaded = aFileItem; 
    246246                                        aUnicornCall.setDocumentName(aFileItemUploaded.getName()); 
     
    249249                                } 
    250250                        } 
    251                          
     251 
    252252                        if (templateLang == null) 
    253253                                templateLang = chooseTemplateLang(aLocale); 
    254                          
     254 
    255255                        if (null == aLocale) { 
    256256                                aUnicornCall.setLang(LocalizedString.DEFAULT_LANGUAGE); 
    257257                        } else { 
    258                                 aUnicornCall.setLang(templateLang + "," + aLocale);              
     258                                aUnicornCall.setLang(templateLang + "," + aLocale); 
    259259                        } 
    260260                        mapOfOutputParameter.put("lang", templateLang); 
    261                          
    262                 } 
    263                  
     261 
     262                } 
     263 
    264264                catch (final FileUploadException aFileUploadException) { 
    265265                        FirstServlet.logger.error( 
     
    267267                                        aFileUploadException); 
    268268                        this.createError( 
    269                                         aHttpServletResponse,  
     269                                        aHttpServletResponse, 
    270270                                        aFileUploadException, 
    271                                         mapOfSpecificParameter,  
    272                                         mapOfOutputParameter); 
    273                 } 
    274                  
     271                                        mapOfSpecificParameter, 
     272                                        mapOfOutputParameter); 
     273                } 
     274 
    275275                try { 
    276276                        aUnicornCall.doTask(); 
    277                          
    278                          
     277 
     278 
    279279                        this.createOutput( 
    280280                                        aHttpServletResponse, 
     
    288288                                        aHttpServletResponse, 
    289289                                        aException, 
    290                                         mapOfSpecificParameter,  
     290                                        mapOfSpecificParameter, 
    291291                                        mapOfOutputParameter); 
    292292                } 
     
    303303         * @param sParamName Name of the parameter. 
    304304         * @param sParamValue Value of the parameter. 
    305          * @param aUnicornCall  
     305         * @param aUnicornCall 
    306306         * @param mapOfSpecificParameter 
    307307         * @param mapOfOutputParameter 
     
    311311                        final String sParamValue, 
    312312                        final UnicornCall aUnicornCall, 
    313                         final Map<String, String[]> mapOfSpecificParameter,  
     313                        final Map<String, String[]> mapOfSpecificParameter, 
    314314                        final Map<String, String> mapOfOutputParameter) { 
    315315                final String[] tStringValues = {sParamValue}; 
    316316                this.addParameter(sParamName, tStringValues, aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter); 
    317317        } 
    318          
     318 
    319319        /** 
    320          *  
     320         * 
    321321         * @param sParamName 
    322322         * @param tStringParamValue 
     
    329329                        final String[] tStringParamValue, 
    330330                        final UnicornCall aUnicornCall, 
    331                         final Map<String, String[]> mapOfSpecificParameter,  
     331                        final Map<String, String[]> mapOfSpecificParameter, 
    332332                        final Map<String, String> mapOfOutputParameter) { 
    333                  
     333 
    334334                if (null == tStringParamValue || 0 == tStringParamValue.length) { 
    335335                        // no value for this parameter 
     
    337337                        return; 
    338338                } 
    339                  
     339 
    340340                if (!sParamName.startsWith(Property.get("UNICORN_PARAMETER_PREFIX"))) { 
    341341                        // task parameter 
     
    343343                        return; 
    344344                } 
    345                  
     345 
    346346                // Unicorn parameter 
    347347                sParamName = sParamName.substring(4); 
    348                  
    349                  
     348 
     349 
    350350                // Output specific parameter 
    351351                if (sParamName.startsWith(Property.get("UNICORN_PARAMETER_OUTPUT_PREFIX"))) { 
     
    354354                        return; 
    355355                } 
    356                  
     356 
    357357                if (sParamName.equals("lang")) { 
    358358                        aUnicornCall.addParameter("ucn_lang", tStringParamValue); 
    359359                } 
    360                  
     360 
    361361                // Global Unicorn parameter 
    362362                if (sParamName.equals("task")) { 
     
    370370                } 
    371371                else if (sParamName.equals("text")) { 
    372                         aUnicornCall.setEnumInputMethod(EnumInputMethod.DIRECT);                         
     372                        aUnicornCall.setEnumInputMethod(EnumInputMethod.DIRECT); 
    373373                        aUnicornCall.setDocumentName(tStringParamValue[0]); 
    374374                        aUnicornCall.setInputParameterValue(tStringParamValue[0]); 
     
    378378                                sParamName.equals("charset") || sParamName.equals("mimetype") || 
    379379                                sParamName.equals("lang")) { 
    380                         mapOfOutputParameter.put(sParamName, tStringParamValue[0]);                      
    381                 }                
     380                        mapOfOutputParameter.put(sParamName, tStringParamValue[0]); 
     381                } 
    382382                else if (sParamName.equals("text_mime")) { 
    383383                        aUnicornCall.addParameter("ucn_mime", tStringParamValue); 
     
    386386 
    387387        private void createError ( 
    388                         final HttpServletResponse aHttpServletResponse,  
     388                        final HttpServletResponse aHttpServletResponse, 
    389389                        final Exception aExceptionError, 
    390390                        final Map<String, String[]> mapOfSpecificParameter, 
    391391                        final Map<String, String> mapOfOutputParameter) 
    392392        throws IOException { 
    393                 aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype")); 
    394                 try {                                            
     393      aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype") + "; charset=" + mapOfOutputParameter.get("charset")); 
     394 
     395                try { 
    395396                        final OutputFormater aOutputFormater = OutputFactory.getOutputFormater( 
    396397                                        mapOfOutputParameter.get("format"), 
     
    424425                } 
    425426        } 
    426          
     427 
    427428        private void createOutput ( 
    428                         final HttpServletResponse aHttpServletResponse,  
     429                        final HttpServletResponse aHttpServletResponse, 
    429430                        final UnicornCall aUnicornCall, 
    430431                        final Map<String, String[]> mapOfSpecificParameter, 
    431432                        final Map<String, String> mapOfOutputParameter) 
    432433        throws IOException { 
    433                 aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype")); 
     434      aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype") + "; charset=" + mapOfOutputParameter.get("charset")); 
    434435                try { 
    435436                        Map<String, Object> mapOfStringObject = new LinkedHashMap<String, Object>(); 
    436437                        mapOfStringObject.put("unicorncall", aUnicornCall); 
     438 
    437439                        final OutputFormater aOutputFormater = OutputFactory.getOutputFormater( 
    438440                                        mapOfOutputParameter.get("format"), 
     
    447449                                        aHttpServletResponse.getWriter()); 
    448450                } 
     451 
    449452                catch (final ResourceNotFoundException e) { 
    450453                        FirstServlet.logger.error("ResourceNotFoundException : "+e.getMessage(), e); 
     
    466469                } 
    467470        } 
    468          
     471 
    469472        /** 
    470473         * This method returns the first language of the accept language list 
    471474         * which is equal to one of available index template language 
    472          *  
     475         * 
    473476         * @param aLocale 
    474477         * @return The selected language or the default language. 
     
    482485                                return tabLang[i].split("-")[0]; 
    483486                } 
    484                  
     487 
    485488                return LocalizedString.DEFAULT_LANGUAGE; 
    486489        } 
    487          
    488          
     490 
     491 
    489492        /** 
    490493         * Converts an Enumeration object to a string, the terms being 
  • resources/templates/output/en_xhtml10.vm

    r162 r172  
    1 <?xml version="1.0"?> 
     1<?xml version="1.0" encoding="UTF-8"?> 
    22<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    33    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    44<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    55  <head> 
     6    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    67    #if($unicorncall.DocumentName) 
    78      <title>Result for $unicorncall.DocumentName</title> 
  • resources/templates/output/fr_xhtml10.vm

    r162 r172  
    1 <?xml version="1.0"?> 
     1<?xml version="1.0" encoding="UTF-8"?> 
    22<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    33    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    44<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    55  <head> 
     6    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    67    #if($unicorncall.DocumentName) 
    78      <title>R&eacute;sultat pour $unicorncall.DocumentName</title>