OtaHtmlGenerator extends VelocityBase<Parameters> { public static URL generateHtmlServiceUrl(URL htmlServiceUrl, Map<String, String> params) throws MalformedURLException { if (params.get(KEY_REFERER) == null) { return new URL(String.format("%s?%s=%s&%s=%s&%s=%s%s%s", htmlServiceUrl.toExternalForm(), KEY_TITLE, LibUtils.urlEncode(params.get(KEY_TITLE)), KEY_BUNDLE_IDENTIFIER, LibUtils.urlEncode(params.get(KEY_BUNDLE_IDENTIFIER)), KEY_BUNDLE_VERSION, LibUtils.urlEncode(params.get(KEY_BUNDLE_VERSION)), (StringUtils.isEmpty(params.get(KEY_IPA_CLASSIFIER)) ? "" : String.format("&%s=%s", KEY_IPA_CLASSIFIER, LibUtils.urlEncode(params.get(KEY_IPA_CLASSIFIER)))), (StringUtils.isEmpty(params.get(KEY_OTA_CLASSIFIER)) ? "" : String.format("&%s=%s", KEY_OTA_CLASSIFIER, LibUtils.urlEncode(params.get(KEY_OTA_CLASSIFIER)))) )); } else { return new URL(String.format("%s?%s=%s&%s=%s&%s=%s&%s=%s%s%s", htmlServiceUrl.toExternalForm(), KEY_REFERER, LibUtils.encode(KEY_REFERER + "=" + params.get(KEY_REFERER)), KEY_TITLE, LibUtils.urlEncode(params.get(KEY_TITLE)), KEY_BUNDLE_IDENTIFIER, LibUtils.urlEncode(params.get(KEY_BUNDLE_IDENTIFIER)), KEY_BUNDLE_VERSION, LibUtils.urlEncode(params.get(KEY_BUNDLE_VERSION)), (StringUtils.isEmpty(params.get(KEY_IPA_CLASSIFIER)) ? "" : String.format("&%s=%s", KEY_IPA_CLASSIFIER, LibUtils.urlEncode(params.get(KEY_IPA_CLASSIFIER)))), (StringUtils.isEmpty(params.get(KEY_OTA_CLASSIFIER)) ? "" : String.format("&%s=%s", KEY_OTA_CLASSIFIER, LibUtils.urlEncode(params.get(KEY_OTA_CLASSIFIER)))) )); } } private  OtaHtmlGenerator(String template); static OtaHtmlGenerator getInstance(); static synchronized OtaHtmlGenerator getInstance(String template); static synchronized OtaHtmlGenerator getInstance(String template, boolean forceNewInstance); static URL generateHtmlServiceUrl(URL htmlServiceUrl, Map<String, String> params);  }
@Test public void testGenerateHtmlServiceUrl() throws MalformedURLException { URL url = new URL("http: assertEquals( "http: "title=MyApp&bundleIdentifier=com.sap.myApp.XYZ&bundleVersion=3.4.5.6&" + "ipaClassifier=ipaClassifier&otaClassifier=otaClassifier", OtaHtmlGenerator.generateHtmlServiceUrl(url, buildMap(KEY_TITLE, "MyApp", KEY_BUNDLE_IDENTIFIER, "com.sap.myApp.XYZ", KEY_BUNDLE_VERSION, "3.4.5.6", KEY_IPA_CLASSIFIER, ipaClassifier, KEY_OTA_CLASSIFIER, otaClassifier)).toExternalForm()); assertEquals( "http: "title=MyApp+With+Special%24_Char%26&bundleIdentifier=com.sap.myApp.XYZ&bundleVersion=3.4.5.6&" + "ipaClassifier=ipaClassifier&otaClassifier=otaClassifier", OtaHtmlGenerator.generateHtmlServiceUrl(url, buildMap(KEY_TITLE, "MyApp With Special$_Char&", KEY_BUNDLE_IDENTIFIER, "com.sap.myApp.XYZ", KEY_BUNDLE_VERSION, "3.4.5.6", KEY_IPA_CLASSIFIER, ipaClassifier, KEY_OTA_CLASSIFIER, otaClassifier)).toExternalForm()); assertEquals( "http: "title=MyApp&bundleIdentifier=com.sap.myApp.XYZ&bundleVersion=3.4.5.6", OtaHtmlGenerator.generateHtmlServiceUrl(url, buildMap(KEY_TITLE, "MyApp", KEY_BUNDLE_IDENTIFIER, "com.sap.myApp.XYZ", KEY_BUNDLE_VERSION, "3.4.5.6")) .toExternalForm()); assertEquals( "http: "title=MyApp&bundleIdentifier=com.sap.myApp.XYZ&bundleVersion=3.4.5.6&otaClassifier=otaClassifier", OtaHtmlGenerator.generateHtmlServiceUrl(url, buildMap(KEY_TITLE, "MyApp", KEY_BUNDLE_IDENTIFIER, "com.sap.myApp.XYZ", KEY_BUNDLE_VERSION, "3.4.5.6", KEY_OTA_CLASSIFIER, otaClassifier)).toExternalForm()); }