Changeset 172:c08736afb365
- Timestamp:
- 09/23/08 13:53:58 (5 years ago)
- Branch:
- default
- convert_revision:
- svn:cdcfb263-7567-472c-a848-e2c2df3466e7/trunk@173
- Files:
-
- 1 removed
- 10 modified
-
build-user.xml (deleted)
-
build.xml (modified) (7 diffs)
-
org/w3c/unicorn/index/IndexGenerator.java (modified) (3 diffs)
-
org/w3c/unicorn/request/DirectRequestGET.java (modified) (2 diffs)
-
org/w3c/unicorn/request/DirectRequestPOST.java (modified) (2 diffs)
-
org/w3c/unicorn/request/Request.java (modified) (2 diffs)
-
org/w3c/unicorn/request/URIRequest.java (modified) (2 diffs)
-
org/w3c/unicorn/request/UploadRequest.java (modified) (2 diffs)
-
org/w3c/unicorn/tests/FirstServlet.java (modified) (26 diffs)
-
resources/templates/output/en_xhtml10.vm (modified) (1 diff)
-
resources/templates/output/fr_xhtml10.vm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
build.xml
r169 r172 1 1 <?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 -->7 2 <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"/> 13 11 <property name="username" value="manager"/> 14 12 <property name="password" value="******"/> 15 13 16 14 <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"/> 31 29 <pathelement location="${unicorn.location}/lib/catalina-ant.jar"/> 32 30 <pathelement location="${unicorn.location}/lib/observationresponse.jar"/> … … 42 40 </path> 43 41 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"/> 55 51 56 52 <target name="init"> … … 61 57 </target> 62 58 <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"> 63 67 <echo message="${ant.project.name}: ${ant.file}"/> 64 68 <javac destdir="." debug="on" debuglevel="lines,vars,source"> … … 68 72 </javac> 69 73 </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 75 174 <target name="CallParameter"> 76 175 <java fork="yes" classname="org.w3c.unicorn.contract.methods.CallParameter" failonerror="true"> … … 88 187 </java> 89 188 </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>95 189 <target name="TaskListUnmarshallerBeans"> 96 190 <java fork="yes" classname="org.w3c.unicorn.tasklist.TaskListUnmarshallerBeans" failonerror="true"> … … 98 192 </java> 99 193 </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>105 194 <target name="ListFiles"> 106 195 <java fork="yes" classname="org.w3c.unicorn.util.ListFiles" failonerror="true"> … … 108 197 </java> 109 198 </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 124 200 </project> -
org/w3c/unicorn/index/IndexGenerator.java
r169 r172 1 // $Id: IndexGenerator.java,v 1. 5 2008-09-12 18:01:51jean-gui Exp $1 // $Id: IndexGenerator.java,v 1.6 2008-09-23 13:53:58 jean-gui Exp $ 2 2 // Author: Jean-Guilhem Rouel 3 3 // (c) COPYRIGHT MIT, ERCIM and Keio, 2006. … … 7 7 import java.io.File; 8 8 import java.io.FileNotFoundException; 9 import java.io.FileWriter;10 9 import java.io.IOException; 11 10 import java.net.MalformedURLException; 12 11 import java.net.URL; 13 12 import java.util.Properties; 13 import java.io.OutputStreamWriter; 14 import java.io.FileOutputStream; 14 15 15 16 import org.apache.commons.logging.Log; … … 116 117 .getTemplate(sName, "UTF-8"); 117 118 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"); 121 122 aTemplate.merge(IndexGenerator.aVelocityContext, aFileWriter); 122 123 aFileWriter.close(); -
org/w3c/unicorn/request/DirectRequestGET.java
r168 r172 1 // $Id: DirectRequestGET.java,v 1. 6 2008-09-10 10:10:40jean-gui Exp $1 // $Id: DirectRequestGET.java,v 1.7 2008-09-23 13:53:58 jean-gui Exp $ 2 2 // Author: Damien LEROY. 3 3 // (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. … … 103 103 final URLConnection aURLConnection = aURL.openConnection(); 104 104 aURLConnection.setRequestProperty("Accept-Language", this.sLang); 105 105 106 InputStream is = aURLConnection.getInputStream(); 106 107 -
org/w3c/unicorn/request/DirectRequestPOST.java
r168 r172 1 // $Id: DirectRequestPOST.java,v 1. 8 2008-09-10 10:10:40jean-gui Exp $1 // $Id: DirectRequestPOST.java,v 1.9 2008-09-23 13:53:58 jean-gui Exp $ 2 2 // Author: Damien LEROY. 3 3 // (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. … … 127 127 "multipart/form-data; boundary=" + sBoundary); 128 128 this.aURLConnection.setRequestProperty("Accept-Language", this.sLang); 129 129 130 if (null == this.aOutputStream) { 130 131 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:40jean-gui Exp $1 // $Id: Request.java,v 1.9 2008-09-23 13:53:58 jean-gui Exp $ 2 2 // Author: Damien LEROY. 3 3 // (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. … … 144 144 builder.append(chararray, 0, readLength); 145 145 } 146 146 147 147 Response res = ResponseParserFactory.parse(builder.toString(), 148 148 this.getResponseType()); -
org/w3c/unicorn/request/URIRequest.java
r168 r172 1 // $Id: URIRequest.java,v 1. 7 2008-09-10 10:10:40jean-gui Exp $1 // $Id: URIRequest.java,v 1.8 2008-09-23 13:53:58 jean-gui Exp $ 2 2 // Author: Damien LEROY. 3 3 // (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. … … 120 120 121 121 aURLConnection.setRequestProperty("Accept-Language", this.sLang); 122 123 122 InputStream is = aURLConnection.getInputStream(); 124 125 123 return streamToResponse(is); 126 124 } -
org/w3c/unicorn/request/UploadRequest.java
r168 r172 1 // $Id: UploadRequest.java,v 1. 7 2008-09-10 10:10:40jean-gui Exp $1 // $Id: UploadRequest.java,v 1.8 2008-09-23 13:53:58 jean-gui Exp $ 2 2 // Author: Damien LEROY. 3 3 // (c) COPYRIGHT MIT, ERCIM ant Keio, 2006. … … 108 108 this.aClientHttpRequest = new ClientHttpRequest(sURL); 109 109 UploadRequest.logger.debug("Lang : " + this.sLang + "."); 110 this.aClientHttpRequest.setLang(sLang); // meme place que pour 111 // directpost 110 this.aClientHttpRequest.setLang(sLang); 112 111 this.aClientHttpRequest.setParameter(this.sInputParameterName, 113 112 this.aUploadInputModule.getFileName(), this.aUploadInputModule -
org/w3c/unicorn/tests/FirstServlet.java
r169 r172 1 // $Id: FirstServlet.java,v 1.1 2 2008-09-12 18:01:51jean-gui Exp $1 // $Id: FirstServlet.java,v 1.13 2008-09-23 13:53:58 jean-gui Exp $ 2 2 // Author: Jean-Guilhem Rouel 3 3 // (c) COPYRIGHT MIT, ERCIM and Keio, 2006. … … 51 51 private static final long serialVersionUID = -1375355420965607571L; 52 52 53 private static final DiskFileItemFactory factory = new DiskFileItemFactory(); 54 53 private static final DiskFileItemFactory factory = new DiskFileItemFactory(); 54 55 55 /** 56 56 * Creates a new file upload handler. … … 93 93 protected void doGet ( 94 94 final HttpServletRequest aHttpServletRequest, 95 final HttpServletResponse aHttpServletResponse) 95 final HttpServletResponse aHttpServletResponse) 96 96 throws ServletException, IOException { 97 97 FirstServlet.logger.trace("doGet"); … … 104 104 mapOfOutputParameter.put("charset", "UTF-8"); 105 105 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, 108 108 // based on the Accept-Language header 109 109 final String aLocale = convertEnumerationToString(aHttpServletRequest.getLocales()); 110 final UnicornCall aUnicornCall = new UnicornCall(); 111 110 final UnicornCall aUnicornCall = new UnicornCall(); 111 112 112 // Language of the template 113 113 // ucn_lang is a parameter which is define in xx_index.html.vm. … … 120 120 templateLang = chooseTemplateLang(aLocale); 121 121 } 122 122 123 123 mapOfOutputParameter.put("lang", templateLang); 124 124 125 125 if (null == aLocale) { 126 126 aUnicornCall.setLang(LocalizedString.DEFAULT_LANGUAGE); 127 127 } else { 128 aUnicornCall.setLang(templateLang + "," + aLocale); 129 } 130 128 aUnicornCall.setLang(templateLang + "," + aLocale); 129 } 130 131 131 for ( 132 132 final Enumeration aEnumParamName = aHttpServletRequest.getParameterNames(); … … 134 134 final String sParamName = (String) aEnumParamName.nextElement(); 135 135 final String[] tStringParamValue = aHttpServletRequest.getParameterValues(sParamName); 136 136 137 137 this.addParameter( 138 138 sParamName, 139 139 tStringParamValue, 140 aUnicornCall, 140 aUnicornCall, 141 141 mapOfSpecificParameter, 142 142 mapOfOutputParameter); … … 147 147 this.createError( 148 148 aHttpServletResponse, 149 new NoTaskException(), 150 mapOfSpecificParameter, 151 mapOfOutputParameter); 149 new NoTaskException(), 150 mapOfSpecificParameter, 151 mapOfOutputParameter); 152 152 return; 153 153 } … … 167 167 aHttpServletResponse, 168 168 aException, 169 mapOfSpecificParameter, 170 mapOfOutputParameter); 171 } 172 } 173 169 mapOfSpecificParameter, 170 mapOfOutputParameter); 171 } 172 } 173 174 174 /* (non-Javadoc) 175 175 * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 176 176 */ 177 177 @Override 178 179 178 179 180 180 protected void doPost ( 181 181 final HttpServletRequest aHttpServletRequest, … … 183 183 throws ServletException, IOException { 184 184 FirstServlet.logger.trace("doPost"); 185 185 186 186 // Check that we have a file upload request 187 187 final boolean bIsMultipart = ServletFileUpload.isMultipartContent( 188 188 new ServletRequestContext(aHttpServletRequest)); 189 189 190 190 if (!bIsMultipart) { 191 191 this.doGet(aHttpServletRequest, aHttpServletResponse); 192 192 return; 193 193 } 194 194 195 195 // Parse the request 196 196 final List listOfItem; 197 198 final UnicornCall aUnicornCall = new UnicornCall(); 199 197 198 final UnicornCall aUnicornCall = new UnicornCall(); 199 200 200 // Variables related to the output 201 201 final Map<String, String> mapOfOutputParameter = new Hashtable<String, String>(); … … 204 204 mapOfOutputParameter.put("charset", "UTF-8"); 205 205 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, 208 208 // based on the Accept-Language header 209 209 final String aLocale = convertEnumerationToString(aHttpServletRequest.getLocales()); 210 211 210 211 212 212 // Language of the template 213 213 // ucn_lang is a parameter which is define in xx_index.html.vm. 214 214 // It is an hidden parameter of a form. 215 215 String templateLang = null; 216 216 217 217 FirstServlet.logger.trace("doPost"); 218 219 220 221 218 219 220 221 222 222 final Map<String, String[]> mapOfSpecificParameter = new Hashtable<String, String[]>(); 223 223 224 224 FileItem aFileItemUploaded = null; 225 226 225 226 227 227 try { 228 228 listOfItem = FirstServlet.upload.parseRequest(aHttpServletRequest); 229 230 229 230 231 231 // Process the uploaded items 232 232 for (final Iterator aIterator = listOfItem.iterator(); aIterator.hasNext();) { 233 233 final FileItem aFileItem = (FileItem) aIterator.next(); 234 if (aFileItem.isFormField()) { 235 234 if (aFileItem.isFormField()) { 235 236 236 if(aFileItem.getFieldName().equals("ucn_lang")) { 237 237 templateLang = aFileItem.getString(); 238 238 } 239 240 239 240 241 241 addParameter(aFileItem.getFieldName(), aFileItem.getString(), 242 242 aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter); 243 244 } else if(aFileItem.getFieldName().equals("ucn_file")) { 243 244 } else if(aFileItem.getFieldName().equals("ucn_file")) { 245 245 aFileItemUploaded = aFileItem; 246 246 aUnicornCall.setDocumentName(aFileItemUploaded.getName()); … … 249 249 } 250 250 } 251 251 252 252 if (templateLang == null) 253 253 templateLang = chooseTemplateLang(aLocale); 254 254 255 255 if (null == aLocale) { 256 256 aUnicornCall.setLang(LocalizedString.DEFAULT_LANGUAGE); 257 257 } else { 258 aUnicornCall.setLang(templateLang + "," + aLocale); 258 aUnicornCall.setLang(templateLang + "," + aLocale); 259 259 } 260 260 mapOfOutputParameter.put("lang", templateLang); 261 262 } 263 261 262 } 263 264 264 catch (final FileUploadException aFileUploadException) { 265 265 FirstServlet.logger.error( … … 267 267 aFileUploadException); 268 268 this.createError( 269 aHttpServletResponse, 269 aHttpServletResponse, 270 270 aFileUploadException, 271 mapOfSpecificParameter, 272 mapOfOutputParameter); 273 } 274 271 mapOfSpecificParameter, 272 mapOfOutputParameter); 273 } 274 275 275 try { 276 276 aUnicornCall.doTask(); 277 278 277 278 279 279 this.createOutput( 280 280 aHttpServletResponse, … … 288 288 aHttpServletResponse, 289 289 aException, 290 mapOfSpecificParameter, 290 mapOfSpecificParameter, 291 291 mapOfOutputParameter); 292 292 } … … 303 303 * @param sParamName Name of the parameter. 304 304 * @param sParamValue Value of the parameter. 305 * @param aUnicornCall 305 * @param aUnicornCall 306 306 * @param mapOfSpecificParameter 307 307 * @param mapOfOutputParameter … … 311 311 final String sParamValue, 312 312 final UnicornCall aUnicornCall, 313 final Map<String, String[]> mapOfSpecificParameter, 313 final Map<String, String[]> mapOfSpecificParameter, 314 314 final Map<String, String> mapOfOutputParameter) { 315 315 final String[] tStringValues = {sParamValue}; 316 316 this.addParameter(sParamName, tStringValues, aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter); 317 317 } 318 318 319 319 /** 320 * 320 * 321 321 * @param sParamName 322 322 * @param tStringParamValue … … 329 329 final String[] tStringParamValue, 330 330 final UnicornCall aUnicornCall, 331 final Map<String, String[]> mapOfSpecificParameter, 331 final Map<String, String[]> mapOfSpecificParameter, 332 332 final Map<String, String> mapOfOutputParameter) { 333 333 334 334 if (null == tStringParamValue || 0 == tStringParamValue.length) { 335 335 // no value for this parameter … … 337 337 return; 338 338 } 339 339 340 340 if (!sParamName.startsWith(Property.get("UNICORN_PARAMETER_PREFIX"))) { 341 341 // task parameter … … 343 343 return; 344 344 } 345 345 346 346 // Unicorn parameter 347 347 sParamName = sParamName.substring(4); 348 349 348 349 350 350 // Output specific parameter 351 351 if (sParamName.startsWith(Property.get("UNICORN_PARAMETER_OUTPUT_PREFIX"))) { … … 354 354 return; 355 355 } 356 356 357 357 if (sParamName.equals("lang")) { 358 358 aUnicornCall.addParameter("ucn_lang", tStringParamValue); 359 359 } 360 360 361 361 // Global Unicorn parameter 362 362 if (sParamName.equals("task")) { … … 370 370 } 371 371 else if (sParamName.equals("text")) { 372 aUnicornCall.setEnumInputMethod(EnumInputMethod.DIRECT); 372 aUnicornCall.setEnumInputMethod(EnumInputMethod.DIRECT); 373 373 aUnicornCall.setDocumentName(tStringParamValue[0]); 374 374 aUnicornCall.setInputParameterValue(tStringParamValue[0]); … … 378 378 sParamName.equals("charset") || sParamName.equals("mimetype") || 379 379 sParamName.equals("lang")) { 380 mapOfOutputParameter.put(sParamName, tStringParamValue[0]); 381 } 380 mapOfOutputParameter.put(sParamName, tStringParamValue[0]); 381 } 382 382 else if (sParamName.equals("text_mime")) { 383 383 aUnicornCall.addParameter("ucn_mime", tStringParamValue); … … 386 386 387 387 private void createError ( 388 final HttpServletResponse aHttpServletResponse, 388 final HttpServletResponse aHttpServletResponse, 389 389 final Exception aExceptionError, 390 390 final Map<String, String[]> mapOfSpecificParameter, 391 391 final Map<String, String> mapOfOutputParameter) 392 392 throws IOException { 393 aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype")); 394 try { 393 aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype") + "; charset=" + mapOfOutputParameter.get("charset")); 394 395 try { 395 396 final OutputFormater aOutputFormater = OutputFactory.getOutputFormater( 396 397 mapOfOutputParameter.get("format"), … … 424 425 } 425 426 } 426 427 427 428 private void createOutput ( 428 final HttpServletResponse aHttpServletResponse, 429 final HttpServletResponse aHttpServletResponse, 429 430 final UnicornCall aUnicornCall, 430 431 final Map<String, String[]> mapOfSpecificParameter, 431 432 final Map<String, String> mapOfOutputParameter) 432 433 throws IOException { 433 aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype"));434 aHttpServletResponse.setContentType(mapOfOutputParameter.get("mimetype") + "; charset=" + mapOfOutputParameter.get("charset")); 434 435 try { 435 436 Map<String, Object> mapOfStringObject = new LinkedHashMap<String, Object>(); 436 437 mapOfStringObject.put("unicorncall", aUnicornCall); 438 437 439 final OutputFormater aOutputFormater = OutputFactory.getOutputFormater( 438 440 mapOfOutputParameter.get("format"), … … 447 449 aHttpServletResponse.getWriter()); 448 450 } 451 449 452 catch (final ResourceNotFoundException e) { 450 453 FirstServlet.logger.error("ResourceNotFoundException : "+e.getMessage(), e); … … 466 469 } 467 470 } 468 471 469 472 /** 470 473 * This method returns the first language of the accept language list 471 474 * which is equal to one of available index template language 472 * 475 * 473 476 * @param aLocale 474 477 * @return The selected language or the default language. … … 482 485 return tabLang[i].split("-")[0]; 483 486 } 484 487 485 488 return LocalizedString.DEFAULT_LANGUAGE; 486 489 } 487 488 490 491 489 492 /** 490 493 * 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"?> 2 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 5 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 7 #if($unicorncall.DocumentName) 7 8 <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"?> 2 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 5 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 7 #if($unicorncall.DocumentName) 7 8 <title>Résultat pour $unicorncall.DocumentName</title>
