don't pass directory path to client, use prefix instead
This commit is contained in:
parent
6f9cef9b3f
commit
3df98310fb
2 changed files with 16 additions and 4 deletions
|
@ -16,6 +16,9 @@ public class ProfileUploadHandler
|
|||
// maximum number of characters (file size limit for custom profiles)
|
||||
private static final int MAX_LENGTH = 100000;
|
||||
|
||||
// prefix for custom profile id to distinguish from default profiles
|
||||
public static final String CUSTOM_PREFIX = "custom_";
|
||||
|
||||
private ServiceContext serviceContext;
|
||||
|
||||
public ProfileUploadHandler( ServiceContext serviceContext)
|
||||
|
@ -29,8 +32,8 @@ public class ProfileUploadHandler
|
|||
|
||||
try
|
||||
{
|
||||
String id = getOrCreateCustomProfileDir() + "/" + System.currentTimeMillis();
|
||||
File file = new File ( id + ".brf" );
|
||||
String id = "" + System.currentTimeMillis();
|
||||
File file = new File( getOrCreateCustomProfileDir(), id + ".brf" );
|
||||
fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream( file ) ) );
|
||||
//StringWriter sw = new StringWriter(); bw = new BufferedWriter(sw);
|
||||
|
||||
|
@ -40,7 +43,7 @@ public class ProfileUploadHandler
|
|||
fileWriter.flush();
|
||||
//System.out.println("data: |" + sw.toString() + "|");
|
||||
|
||||
response.write("profileid=" + id);
|
||||
response.write("profileid=" + CUSTOM_PREFIX + id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ import btools.router.OsmNodeNamed;
|
|||
import btools.router.OsmTrack;
|
||||
import btools.router.RoutingContext;
|
||||
import btools.server.ServiceContext;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* URL query parameter handler for web and standalone server. Supports all
|
||||
|
@ -38,7 +39,15 @@ public class ServerHandler extends RequestHandler {
|
|||
{
|
||||
RoutingContext rc = new RoutingContext();
|
||||
|
||||
rc.localFunction = params.get( "profile" );
|
||||
String profile = params.get( "profile" );
|
||||
// when custom profile replace prefix with directory path
|
||||
if ( profile.startsWith( ProfileUploadHandler.CUSTOM_PREFIX ) )
|
||||
{
|
||||
String customProfile = profile.substring( ProfileUploadHandler.CUSTOM_PREFIX.length() );
|
||||
profile = new File( serviceContext.customProfileDir, customProfile ).getPath();
|
||||
}
|
||||
rc.localFunction = profile;
|
||||
|
||||
rc.setAlternativeIdx(Integer.parseInt(params.get( "alternativeidx" )));
|
||||
|
||||
List<OsmNodeNamed> nogoList = readNogoList();
|
||||
|
|
Loading…
Reference in a new issue