Skip to content
Snippets Groups Projects
Commit 3f6a3a28 authored by Grégory Mantelet's avatar Grégory Mantelet
Browse files

[UWS] Replace the public static variable for the tmp directory by a class

attribute.

In this way, it is possible to run two different instances of a UWS/TAP service
with a different temporary directory in the same JVM.
parent 3d22e42a
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ package uws.service.file; ...@@ -16,7 +16,7 @@ package uws.service.file;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2018 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
...@@ -53,26 +53,31 @@ import uws.service.log.UWSLog.LogLevel; ...@@ -53,26 +53,31 @@ import uws.service.log.UWSLog.LogLevel;
import uws.service.request.UploadFile; import uws.service.request.UploadFile;
/** /**
* <p>All UWS files are stored in the local machine into the specified directory.</p> * All UWS files are stored in the local machine into the specified directory.
* *
* <p> * <p>
* The name of the log file, the result files and the backup files may be customized by overriding the following functions: * The name of the log file, the result files and the backup files may be
* {@link #getLogFileName(uws.service.log.UWSLog.LogLevel, String)}, {@link #getResultFileName(Result, UWSJob)}, {@link #getBackupFileName(JobOwner)} and {@link #getBackupFileName()}. * customised by overriding the following functions:
* {@link #getLogFileName(uws.service.log.UWSLog.LogLevel, String)},
* {@link #getResultFileName(Result, UWSJob)},
* {@link #getBackupFileName(JobOwner)} and {@link #getBackupFileName()}.
* </p> * </p>
* *
* <p> * <p>
* By default, results and backups are grouped by owner/user and owners/users are grouped thanks to {@link DefaultOwnerGroupIdentifier}. * By default, results and backups are grouped by owner/user and owners/users
* By using the appropriate constructor, you can change these default behaviors. * are grouped thanks to {@link DefaultOwnerGroupIdentifier}. By using the
* appropriate constructor, you can change these default behaviours.
* </p> * </p>
* *
* <p> * <p>
* A log file rotation is set by default so that avoiding a too big log file after several months/years of use. * A log file rotation is set by default so that avoiding a too big log file
* By default the rotation is done every month on the 1st at 6am. This frequency can be changed easily thanks to the function * after several months/years of use. By default the rotation is done every
* {@link #setLogRotationFreq(String)}. * month on the 1st at 6am. This frequency can be changed easily thanks to the
* function {@link #setLogRotationFreq(String)}.
* </p> * </p>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 4.4 (07/2018) * @version 4.4 (08/2018)
*/ */
public class LocalUWSFileManager implements UWSFileManager { public class LocalUWSFileManager implements UWSFileManager {
...@@ -87,6 +92,10 @@ public class LocalUWSFileManager implements UWSFileManager { ...@@ -87,6 +92,10 @@ public class LocalUWSFileManager implements UWSFileManager {
/** Directory in which all files managed by this class will be written and read. */ /** Directory in which all files managed by this class will be written and read. */
protected final File rootDirectory; protected final File rootDirectory;
/** Directory in which temporary files (e.g. uploads) should be stored.
* @since 4.4 */
protected File tmpDirectory = new File(System.getProperty("java.io.tmpdir"));
/** Output toward the service log file. */ /** Output toward the service log file. */
protected PrintWriter logOutput = null; protected PrintWriter logOutput = null;
/** Frequency at which the log file must be "rotated" (the file is renamed with the date of its first write and a new log file is created). /** Frequency at which the log file must be "rotated" (the file is renamed with the date of its first write and a new log file is created).
...@@ -439,6 +448,21 @@ public class LocalUWSFileManager implements UWSFileManager { ...@@ -439,6 +448,21 @@ public class LocalUWSFileManager implements UWSFileManager {
return new File(upload.getLocation()); return new File(upload.getLocation());
} }
@Override
public File getTmpDirectory(){
return tmpDirectory;
}
@Override
public boolean setTmpDirectory(final File newTmpDir){
if (newTmpDir == null || !newTmpDir.exists() || !newTmpDir.isDirectory() || !newTmpDir.canRead() || !newTmpDir.canWrite())
return false;
else{
tmpDirectory = newTmpDir;
return true;
}
}
@Override @Override
public InputStream getUploadInput(final UploadFile upload) throws IOException{ public InputStream getUploadInput(final UploadFile upload) throws IOException{
// Check the source file: // Check the source file:
......
This diff is collapsed.
...@@ -2,21 +2,22 @@ package uws.service.request; ...@@ -2,21 +2,22 @@ package uws.service.request;
/* /*
* This file is part of UWSLibrary. * This file is part of UWSLibrary.
* *
* UWSLibrary is free software: you can redistribute it and/or modify * UWSLibrary is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* UWSLibrary is distributed in the hope that it will be useful, * UWSLibrary is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2014 - Astronomisches Rechen Institut (ARI) * Copyright 2014-2018 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI)
*/ */
import java.io.File; import java.io.File;
...@@ -28,36 +29,40 @@ import java.util.Map; ...@@ -28,36 +29,40 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.oreilly.servlet.MultipartRequest;
import com.oreilly.servlet.multipart.FileRenamePolicy;
import uws.UWSException; import uws.UWSException;
import uws.service.UWS; import uws.service.UWS;
import uws.service.file.UWSFileManager; import uws.service.file.UWSFileManager;
import com.oreilly.servlet.MultipartRequest;
import com.oreilly.servlet.multipart.FileRenamePolicy;
/** /**
* <p>Extract parameters encoded using the Content-type multipart/form-data * Extract parameters encoded using the Content-type multipart/form-data
* in an {@link HttpServletRequest}.</p> * in an {@link HttpServletRequest}.
* *
* <p> * <p>
* The created file(s) is(are) stored in the temporary upload directory ({@link UWSFileManager#TMP_UPLOAD_DIR} ; this attribute can be modified if needed). * The created file(s) is(are) stored in the temporary upload directory
* This directory is supposed to be emptied regularly in case it is forgotten at any moment by the UWS service implementation to delete unused request files. * ({@link UWSFileManager#getTmpDirectory()}. This directory is supposed to be
* emptied regularly in case it is forgotten at any moment by the service
* implementation to delete unused request files.
* </p> * </p>
* *
* <p> * <p>
* The size of the full request body is limited by the static attribute {@link #SIZE_LIMIT} before the creation of the file. * The size of the full request body is limited by the static attribute
* Its default value is: {@link #DEFAULT_SIZE_LIMIT}={@value #DEFAULT_SIZE_LIMIT} bytes. * {@link #SIZE_LIMIT} before the creation of the file. Its default value is:
* {@link #DEFAULT_SIZE_LIMIT}={@value #DEFAULT_SIZE_LIMIT} bytes.
* </p> * </p>
* *
* <p> * <p>
* By default, this {@link RequestParser} overwrite parameter occurrences in the map: that's to say if a parameter is provided several times, * By default, this {@link RequestParser} overwrite parameter occurrences in
* only the last value will be kept. This behavior can be changed by overwriting the function {@link #consumeParameter(String, Object, Map)} * the map: that's to say if a parameter is provided several times, only the
* of this class. * last value will be kept. This behaviour can be changed by overwriting the
* function {@link #consumeParameter(String, Object, Map)} of this class.
* </p> * </p>
* *
* @author Gr&eacute;gory Mantelet (ARI) * @author Gr&eacute;gory Mantelet (ARI;CDS)
* @version 4.1 (12/2014) * @version 4.4 (08/2018)
* @since 4.1 * @since 4.4
*/ */
public class MultipartParser implements RequestParser { public class MultipartParser implements RequestParser {
...@@ -87,7 +92,7 @@ public class MultipartParser implements RequestParser { ...@@ -87,7 +92,7 @@ public class MultipartParser implements RequestParser {
/** /**
* <p>Build a {@link MultipartParser} forbidding uploads (i.e. inline files).</p> * <p>Build a {@link MultipartParser} forbidding uploads (i.e. inline files).</p>
* *
* <p> * <p>
* With this parser, when an upload (i.e. submitted inline files) is detected, an exception is thrown by {@link #parse(HttpServletRequest)} * With this parser, when an upload (i.e. submitted inline files) is detected, an exception is thrown by {@link #parse(HttpServletRequest)}
* which cancels immediately the request. * which cancels immediately the request.
...@@ -99,7 +104,7 @@ public class MultipartParser implements RequestParser { ...@@ -99,7 +104,7 @@ public class MultipartParser implements RequestParser {
/** /**
* Build a {@link MultipartParser} allowing uploads (i.e. inline files). * Build a {@link MultipartParser} allowing uploads (i.e. inline files).
* *
* @param fileManager The file manager to use in order to store any eventual upload. <b>MUST NOT be NULL</b> * @param fileManager The file manager to use in order to store any eventual upload. <b>MUST NOT be NULL</b>
*/ */
public MultipartParser(final UWSFileManager fileManager){ public MultipartParser(final UWSFileManager fileManager){
...@@ -108,12 +113,12 @@ public class MultipartParser implements RequestParser { ...@@ -108,12 +113,12 @@ public class MultipartParser implements RequestParser {
/** /**
* <p>Build a {@link MultipartParser}.</p> * <p>Build a {@link MultipartParser}.</p>
* *
* <p> * <p>
* If the first parameter is <i>false</i>, then when an upload (i.e. submitted inline files) is detected, an exception is thrown * If the first parameter is <i>false</i>, then when an upload (i.e. submitted inline files) is detected, an exception is thrown
* by {@link #parse(HttpServletRequest)} which cancels immediately the request. * by {@link #parse(HttpServletRequest)} which cancels immediately the request.
* </p> * </p>
* *
* @param uploadEnabled <i>true</i> to allow uploads (i.e. inline files), <i>false</i> otherwise. * @param uploadEnabled <i>true</i> to allow uploads (i.e. inline files), <i>false</i> otherwise.
* If <i>false</i>, the two other parameters are useless. * If <i>false</i>, the two other parameters are useless.
* @param fileManager The file manager to use in order to store any eventual upload. <b>MUST NOT be NULL</b> * @param fileManager The file manager to use in order to store any eventual upload. <b>MUST NOT be NULL</b>
...@@ -128,14 +133,14 @@ public class MultipartParser implements RequestParser { ...@@ -128,14 +133,14 @@ public class MultipartParser implements RequestParser {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final Map<String,Object> parse(final HttpServletRequest request) throws UWSException{ public final Map<String, Object> parse(final HttpServletRequest request) throws UWSException{
LinkedHashMap<String,Object> parameters = new LinkedHashMap<String,Object>(); LinkedHashMap<String, Object> parameters = new LinkedHashMap<String, Object>();
MultipartRequest multipart = null; MultipartRequest multipart = null;
try{ try{
// Parse the request body: // Parse the request body:
multipart = new MultipartRequest(request, UWSFileManager.TMP_UPLOAD_DIR.getPath(), (SIZE_LIMIT < 0 ? DEFAULT_SIZE_LIMIT : SIZE_LIMIT), new FileRenamePolicy(){ multipart = new MultipartRequest(request, fileManager.getTmpDirectory().getPath(), (SIZE_LIMIT < 0 ? DEFAULT_SIZE_LIMIT : SIZE_LIMIT), new FileRenamePolicy() {
@Override @Override
public File rename(File file){ public File rename(File file){
Object reqID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID); Object reqID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID);
...@@ -188,7 +193,7 @@ public class MultipartParser implements RequestParser { ...@@ -188,7 +193,7 @@ public class MultipartParser implements RequestParser {
throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, ioe, "Internal Error => Impossible to extract parameters from the Multipart HTTP request!"); throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, ioe, "Internal Error => Impossible to extract parameters from the Multipart HTTP request!");
}catch(IllegalArgumentException iae){ }catch(IllegalArgumentException iae){
String confError = iae.getMessage(); String confError = iae.getMessage();
if (UWSFileManager.TMP_UPLOAD_DIR == null) if (fileManager.getTmpDirectory() == null)
confError = "Missing upload directory!"; confError = "Missing upload directory!";
throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, iae, "Internal Error: Incorrect UPLOAD configuration: " + confError); throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, iae, "Internal Error: Incorrect UPLOAD configuration: " + confError);
} }
...@@ -198,26 +203,27 @@ public class MultipartParser implements RequestParser { ...@@ -198,26 +203,27 @@ public class MultipartParser implements RequestParser {
/** /**
* <p>Consume the specified parameter: add it inside the given map.</p> * <p>Consume the specified parameter: add it inside the given map.</p>
* *
* <p> * <p>
* By default, this function is just putting the given value inside the map. So, if the parameter already exists in the map, * By default, this function is just putting the given value inside the map. So, if the parameter already exists in the map,
* its old value will be overwritten by the given one. * its old value will be overwritten by the given one.
* </p> * </p>
* *
* <p><i>Note: * <p><i>Note:
* If the old value was a file, it will be deleted from the file system before its replacement in the map. * If the old value was a file, it will be deleted from the file system before its replacement in the map.
* </i></p> * </i></p>
* *
* @param name Name of the parameter to consume. * @param name Name of the parameter to consume.
* @param value Its value. * @param value Its value.
* @param allParams The list of all parameters read until now. * @param allParams The list of all parameters read until now.
*/ */
protected void consumeParameter(final String name, final Object value, final Map<String,Object> allParams){ protected void consumeParameter(final String name, final Object value, final Map<String, Object> allParams){
// If the old value was a file, delete it before replacing its value: // If the old value was a file, delete it before replacing its value:
if (allParams.containsKey(name) && allParams.get(name) instanceof UploadFile){ if (allParams.containsKey(name) && allParams.get(name) instanceof UploadFile){
try{ try{
((UploadFile)allParams.get(name)).deleteFile(); ((UploadFile)allParams.get(name)).deleteFile();
}catch(IOException ioe){} }catch(IOException ioe){
}
} }
// Put the given value in the given map: // Put the given value in the given map:
...@@ -225,16 +231,18 @@ public class MultipartParser implements RequestParser { ...@@ -225,16 +231,18 @@ public class MultipartParser implements RequestParser {
} }
/** /**
* <p>Utility method that determines whether the content of the given request is a multipart/form-data.</p> * Utility method that determines whether the content of the given request
* * is a multipart/form-data.
*
* <p><i>Important: * <p><i>Important:
* This function just test the content-type of the request. The HTTP method (e.g. GET, POST, ...) is not tested. * This function just test the content-type of the request. The HTTP method
* (e.g. GET, POST, ...) is not tested.
* </i></p> * </i></p>
* *
* @param request The servlet request to be evaluated. Must be non-null. * @param request The servlet request to be evaluated. Must be non-null.
* *
* @return <i>true</i> if the request is multipart, * @return <code>true</code> if the request is multipart,
* <i>false</i> otherwise. * <code>false</code> otherwise.
*/ */
public static final boolean isMultipartContent(final HttpServletRequest request){ public static final boolean isMultipartContent(final HttpServletRequest request){
// Extract the content type and determine if it is a multipart request (its content type should start by multipart/form-data"): // Extract the content type and determine if it is a multipart request (its content type should start by multipart/form-data"):
......
...@@ -2,20 +2,20 @@ package uws.service.request; ...@@ -2,20 +2,20 @@ package uws.service.request;
/* /*
* This file is part of UWSLibrary. * This file is part of UWSLibrary.
* *
* UWSLibrary is free software: you can redistribute it and/or modify * UWSLibrary is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* UWSLibrary is distributed in the hope that it will be useful, * UWSLibrary is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2014 - Astronomisches Rechen Institut (ARI) * Copyright 2014 - Astronomisches Rechen Institut (ARI)
*/ */
...@@ -37,21 +37,24 @@ import uws.service.UWS; ...@@ -37,21 +37,24 @@ import uws.service.UWS;
import uws.service.file.UWSFileManager; import uws.service.file.UWSFileManager;
/** /**
* <p>This parser merely copies the whole HTTP request content inside a file. * This parser merely copies the whole HTTP request content inside a file.
* It names this file: "JDL" (Job Description Language).</p> * It names this file: "JDL" (Job Description Language).
* *
* <p> * <p>
* The created file is stored in the temporary upload directory ({@link UWSFileManager#TMP_UPLOAD_DIR} ; this attribute can be modified if needed). * The created file is stored in the temporary upload directory
* This directory is supposed to be emptied regularly in case it is forgotten at any moment by the UWS service implementation to delete unused request files. * ({@link UWSFileManager#getTmpDirectory()}. This directory is supposed to be
* emptied regularly in case it is forgotten at any moment by the service
* implementation to delete unused request files.
* </p> * </p>
* *
* <p> * <p>
* The size of the JDL is limited by the static attribute {@link #SIZE_LIMIT} before the creation of the file. * The size of the JDL is limited by the static attribute {@link #SIZE_LIMIT}
* Its default value is: {@link #DEFAULT_SIZE_LIMIT}={@value #DEFAULT_SIZE_LIMIT} bytes. * before the creation of the file. Its default value is:
* {@link #DEFAULT_SIZE_LIMIT}={@value #DEFAULT_SIZE_LIMIT} bytes.
* </p> * </p>
* *
* @author Gr&eacute;gory Mantelet (ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 4.1 (11/2014) * @version 4.4 (08/2018)
* @since 4.1 * @since 4.1
*/ */
public class NoEncodingParser implements RequestParser { public class NoEncodingParser implements RequestParser {
...@@ -76,7 +79,7 @@ public class NoEncodingParser implements RequestParser { ...@@ -76,7 +79,7 @@ public class NoEncodingParser implements RequestParser {
/** /**
* Build the request parser. * Build the request parser.
* *
* @param fileManager A file manager. <b>MUST NOT be NULL</b> * @param fileManager A file manager. <b>MUST NOT be NULL</b>
*/ */
public NoEncodingParser(final UWSFileManager fileManager){ public NoEncodingParser(final UWSFileManager fileManager){
...@@ -86,10 +89,10 @@ public class NoEncodingParser implements RequestParser { ...@@ -86,10 +89,10 @@ public class NoEncodingParser implements RequestParser {
} }
@Override @Override
public Map<String,Object> parse(final HttpServletRequest request) throws UWSException{ public Map<String, Object> parse(final HttpServletRequest request) throws UWSException{
// Check the request size: // Check the request size:
if (request.getContentLength() <= 0) if (request.getContentLength() <= 0)
return new HashMap<String,Object>(); return new HashMap<String, Object>();
else if (request.getContentLength() > (SIZE_LIMIT < 0 ? DEFAULT_SIZE_LIMIT : SIZE_LIMIT)) else if (request.getContentLength() > (SIZE_LIMIT < 0 ? DEFAULT_SIZE_LIMIT : SIZE_LIMIT))
throw new UWSException("JDL too big (>" + SIZE_LIMIT + " bytes) => Request rejected! You should see with the service administrator to extend this limit."); throw new UWSException("JDL too big (>" + SIZE_LIMIT + " bytes) => Request rejected! You should see with the service administrator to extend this limit.");
...@@ -106,7 +109,7 @@ public class NoEncodingParser implements RequestParser { ...@@ -106,7 +109,7 @@ public class NoEncodingParser implements RequestParser {
Object reqID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID); Object reqID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID);
if (reqID == null || !(reqID instanceof String)) if (reqID == null || !(reqID instanceof String))
reqID = (new Date()).getTime(); reqID = (new Date()).getTime();
File f = new File(UWSFileManager.TMP_UPLOAD_DIR, "REQUESTBODY_" + reqID); File f = new File(fileManager.getTmpDirectory(), "REQUESTBODY_" + reqID);
OutputStream output = null; OutputStream output = null;
InputStream input = null; InputStream input = null;
long totalLength = 0; long totalLength = 0;
...@@ -119,13 +122,13 @@ public class NoEncodingParser implements RequestParser { ...@@ -119,13 +122,13 @@ public class NoEncodingParser implements RequestParser {
if (len <= 0){ if (len <= 0){
output.close(); output.close();
f.delete(); f.delete();
HashMap<String,Object> params = new HashMap<String,Object>(1); HashMap<String, Object> params = new HashMap<String, Object>(1);
params.put(paramName, ""); params.put(paramName, "");
return params; return params;
}else if (len <= 2048 && request.getMethod() != null && request.getMethod().equalsIgnoreCase("put") && request.getContentType() != null && request.getContentType().toLowerCase().startsWith("text/plain")){ }else if (len <= 2048 && request.getMethod() != null && request.getMethod().equalsIgnoreCase("put") && request.getContentType() != null && request.getContentType().toLowerCase().startsWith("text/plain")){
output.close(); output.close();
f.delete(); f.delete();
HashMap<String,Object> params = new HashMap<String,Object>(1); HashMap<String, Object> params = new HashMap<String, Object>(1);
params.put(paramName, new String(buffer, 0, len)); params.put(paramName, new String(buffer, 0, len));
return params; return params;
}else{ }else{
...@@ -141,12 +144,14 @@ public class NoEncodingParser implements RequestParser { ...@@ -141,12 +144,14 @@ public class NoEncodingParser implements RequestParser {
if (input != null){ if (input != null){
try{ try{
input.close(); input.close();
}catch(IOException ioe2){} }catch(IOException ioe2){
}
} }
if (output != null){ if (output != null){
try{ try{
output.close(); output.close();
}catch(IOException ioe2){} }catch(IOException ioe2){
}
} }
} }
...@@ -156,7 +161,7 @@ public class NoEncodingParser implements RequestParser { ...@@ -156,7 +161,7 @@ public class NoEncodingParser implements RequestParser {
lob.length = totalLength; lob.length = totalLength;
// Create the parameters map: // Create the parameters map:
HashMap<String,Object> parameters = new HashMap<String,Object>(); HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put(paramName, lob); parameters.put(paramName, lob);
return parameters; return parameters;
......
...@@ -160,7 +160,7 @@ public class XMLRequestParser implements RequestParser { ...@@ -160,7 +160,7 @@ public class XMLRequestParser implements RequestParser {
} }
@Override @Override
public Map<String,Object> parse(final HttpServletRequest request) throws UWSException{ public Map<String, Object> parse(final HttpServletRequest request) throws UWSException{
// Result of the request parsing => a JobInfo containing or pointing toward the sent request content: // Result of the request parsing => a JobInfo containing or pointing toward the sent request content:
XMLJobInfo jobDesc = null; XMLJobInfo jobDesc = null;
...@@ -169,7 +169,7 @@ public class XMLRequestParser implements RequestParser { ...@@ -169,7 +169,7 @@ public class XMLRequestParser implements RequestParser {
Object reqID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID); Object reqID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID);
if (reqID == null || !(reqID instanceof String)) if (reqID == null || !(reqID instanceof String))
reqID = (new Date()).getTime(); reqID = (new Date()).getTime();
File xmlFile = new File(UWSFileManager.TMP_UPLOAD_DIR, "JOB_DESCRIPTION_" + reqID); File xmlFile = new File(fileManager.getTmpDirectory(), "JOB_DESCRIPTION_" + reqID);
OutputStream output = null; OutputStream output = null;
InputStream input = null; InputStream input = null;
...@@ -254,12 +254,14 @@ public class XMLRequestParser implements RequestParser { ...@@ -254,12 +254,14 @@ public class XMLRequestParser implements RequestParser {
if (output != null){ if (output != null){
try{ try{
output.close(); output.close();
}catch(IOException ioe2){} }catch(IOException ioe2){
}
} }
if (input != null){ if (input != null){
try{ try{
input.close(); input.close();
}catch(IOException ioe2){} }catch(IOException ioe2){
}
} }
} }
...@@ -268,7 +270,7 @@ public class XMLRequestParser implements RequestParser { ...@@ -268,7 +270,7 @@ public class XMLRequestParser implements RequestParser {
request.setAttribute(UWS.REQ_ATTRIBUTE_JOB_DESCRIPTION, jobDesc); request.setAttribute(UWS.REQ_ATTRIBUTE_JOB_DESCRIPTION, jobDesc);
// Return an empty map => no parameter has been directly provided: // Return an empty map => no parameter has been directly provided:
return new HashMap<String,Object>(0); return new HashMap<String, Object>(0);
} }
/** /**
...@@ -312,7 +314,8 @@ public class XMLRequestParser implements RequestParser { ...@@ -312,7 +314,8 @@ public class XMLRequestParser implements RequestParser {
if (input != null){ if (input != null){
try{ try{
input.close(); input.close();
}catch(IOException ioe){} }catch(IOException ioe){
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment