Merge branch 'master' into bug3612

This commit is contained in:
Axel Uhl committed 2016-08-17 10:50:12 +02:00
commit 5c74e44662
6 files changed
+64 -32

No files matched your search

@@ -32,14 +32,16 @@ public class DeviceConfigurationQRCodeUtils {
return accessToken;
}
}
public static String composeQRContent(String deviceIdentifier, String apkUrl, String accessToken) {
// poor man's uri fragment encoding: ' ' as '%20'
String encodedIdentifier = deviceIdentifier.replaceAll(" ", "%20");
return apkUrl + "#" + deviceIdentifierKey + "=" + encodedIdentifier+"&"+accessTokenKey + "=" + accessToken;
public static interface URLDecoder {
String decode(String encodedURL);
}
public static DeviceConfigurationDetails splitQRContent(String qrCodeContent) {
public static String composeQRContent(String urlEncodedDeviceIdentifier, String apkUrl, String accessToken) {
return apkUrl + "#" + deviceIdentifierKey + "=" + urlEncodedDeviceIdentifier + "&"+accessTokenKey + "=" + accessToken;
}
public static DeviceConfigurationDetails splitQRContent(String qrCodeContent, URLDecoder urlDecoder) {
int fragmentIndex = qrCodeContent.lastIndexOf('#');
if (fragmentIndex == -1 || fragmentIndex == 0 || qrCodeContent.length() == fragmentIndex + 1) {
throw new IllegalArgumentException("There is no server or identifier.");
@@ -50,7 +52,7 @@ public class DeviceConfigurationQRCodeUtils {
for (String param : params) {
final String[] keyValue = param.split("=", 2);
if (keyValue.length == 2) {
paramMap.put(keyValue[0], keyValue[1].replaceAll("%20", " "));
paramMap.put(keyValue[0], urlDecoder.decode(keyValue[1]));
}
}
if (!paramMap.containsKey(deviceIdentifierKey)) {
@@ -2,6 +2,7 @@ package com.sap.sailing.gwt.ui.adminconsole;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
@@ -40,7 +41,7 @@ public class DeviceConfigurationQRIdentifierDialog extends DialogBox {
Window.alert(stringMessages.notCapableOfGeneratingACodeForIdentifier());
} else if (!identifierBox.getValue().isEmpty() && !serverBox.getValue().isEmpty()) {
String apkUrl = getServerUrlWithoutFinalSlash() + rcAppApkPath;
return DeviceConfigurationQRCodeUtils.composeQRContent(identifierBox.getValue(), apkUrl, accessToken);
return DeviceConfigurationQRCodeUtils.composeQRContent(URL.encodeQueryString(identifierBox.getValue()), apkUrl, accessToken);
}
return null;
}
@@ -142,6 +142,12 @@ public abstract class ImageDialog extends DataEntryDialog<ImageDTO> {
tagsListEditor = new StringListInlineEditorComposite(Collections.<String> emptyList(),
new GenericStringListInlineEditorComposite.ExpandedUi<String>(stringMessages, IconResources.INSTANCE.removeIcon(), /* suggestValues */
MediaConstants.imageTagSuggestions, "Enter tags for the image", 30));
tagsListEditor.addValueChangeHandler(new ValueChangeHandler<Iterable<String>>() {
@Override
public void onValueChange(ValueChangeEvent<Iterable<String>> event) {
validate();
}
});
}
@Override
@@ -26,7 +26,5 @@ public class ImageEditDialog extends ImageDialog {
List<String> tags = new ArrayList<String>();
tags.addAll(imageDTO.getTags());
tagsListEditor.setValue(tags);
// image = loadImageFromURL(imageDTO.getSourceRef());
// imageHolder.setWidget(image);
}
}