Added encode for filename

Fixed logger

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@122560 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-01-27 11:41:36 +00:00
parent 5189be3d57
commit 72b045c748
2 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package org.gcube.datatransfer.resolver;
@ -17,7 +17,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 20, 2015
*/
@ -47,7 +47,7 @@ public class UriResolverRewriteFilter implements Filter{
if (queryString == null) { // IS A /XXXXX
logger.debug("QueryString is null, is It a new SMP public uri by ID?");
int lastSlash = requestURI.lastIndexOf("/");
if ((lastSlash + 1) == requestURI.length()) {
if (lastSlash + 1 == requestURI.length()) {
logger.debug("'/' is last index, doFilter Request");
// req.getRequestDispatcher("/").forward(req, res);
chain.doFilter(req, res);
@ -57,7 +57,7 @@ public class UriResolverRewriteFilter implements Filter{
// String newURI = requestURI.replace(toReplace,
// SERVLET_RESOLVER_BY_ID+"?"+SMP_ID+"="+toReplace);
String newURI = SERVLET_RESOLVER_BY_ID + "?" + SMP_ID + "=" + toStorageID;
logger.debug("forward to: " + requestURI + newURI);
logger.debug("forward to: " + newURI);
req.getRequestDispatcher(newURI).forward(req, res);
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.datatransfer.resolver.http;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@ -147,7 +148,7 @@ public class StorageIDResolver extends HttpServlet {
if(contentType==null || contentType.isEmpty())
contentType = ConstantsHttpResolver.DEFAULT_CONTENTTYPE_UNKNOWN_UNKNOWN;
response.addHeader(ConstantsHttpResolver.CONTENT_DISPOSITION, "attachment; filename=" +fileName);
response.addHeader(ConstantsHttpResolver.CONTENT_DISPOSITION, "attachment; filename=" +URLEncoder.encode(fileName, "UTF-8"));
response.setContentType(contentType);
//CASE VALIDATION