diff --git a/brouter-server/src/main/java/btools/server/request/ProfileUploadHandler.java b/brouter-server/src/main/java/btools/server/request/ProfileUploadHandler.java index 831c0a5..b6ecfbe 100644 --- a/brouter-server/src/main/java/btools/server/request/ProfileUploadHandler.java +++ b/brouter-server/src/main/java/btools/server/request/ProfileUploadHandler.java @@ -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 { diff --git a/brouter-server/src/main/java/btools/server/request/ServerHandler.java b/brouter-server/src/main/java/btools/server/request/ServerHandler.java index 2ca962a..afa717c 100644 --- a/brouter-server/src/main/java/btools/server/request/ServerHandler.java +++ b/brouter-server/src/main/java/btools/server/request/ServerHandler.java @@ -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 nogoList = readNogoList();