CloudStackPrimaryDataStoreLifeCycleImpl: decode path as UTF8 or fallback

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 6ddaef7a489603b058d360280fc7c4d5ec367346)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2015-02-05 15:27:45 +05:30
parent d4663df7c9
commit fabab5460c

View File

@ -18,8 +18,10 @@
*/ */
package org.apache.cloudstack.storage.datastore.lifecycle; package org.apache.cloudstack.storage.datastore.lifecycle;
import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -182,7 +184,14 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
String scheme = uri.getScheme(); String scheme = uri.getScheme();
String storageHost = uri.getHost(); String storageHost = uri.getHost();
String hostPath = uri.getPath(); String hostPath = null;
try {
hostPath = URLDecoder.decode(uri.getPath(), "UTF-8");
} catch (UnsupportedEncodingException e) {
}
if (hostPath == null) { // if decoding fails, use getPath() anyway
hostPath = uri.getPath();
}
Object localStorage = dsInfos.get("localStorage"); Object localStorage = dsInfos.get("localStorage");
if (localStorage != null) { if (localStorage != null) {
hostPath = hostPath.replaceFirst("/", ""); hostPath = hostPath.replaceFirst("/", "");