diff options
author | Pablo Torregrosa Paez | 2016-04-20 07:59:12 +0000 |
---|---|---|
committer | Pablo Torregrosa Paez | 2016-04-20 07:59:12 +0000 |
commit | 8419c234718d1cdd26b42fba5ec79dac704e1c33 (patch) | |
tree | 47612371db7b75a88d7af58e5623b6921298013d /target_explorer/plugins | |
parent | 39c714eb7fed2a856a798c48efe974bbcd25a0fb (diff) | |
download | org.eclipse.tcf-8419c234718d1cdd26b42fba5ec79dac704e1c33.tar.gz org.eclipse.tcf-8419c234718d1cdd26b42fba5ec79dac704e1c33.tar.xz org.eclipse.tcf-8419c234718d1cdd26b42fba5ec79dac704e1c33.zip |
Target Explorer: Fix file download error when name contains spaces II
Change-Id: I45c31900ae70fe94f3d8fc293c2c34e3d3ea99bb
Signed-off-by: Pablo Torregrosa Paez <pablo.torregrosa@windriver.com>
Diffstat (limited to 'target_explorer/plugins')
2 files changed, 8 insertions, 41 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java index d1c7829c9..bf04a9b55 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java @@ -21,7 +21,6 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.net.URLEncoder; import java.util.Arrays; import java.util.Comparator; import java.util.List; @@ -245,10 +244,10 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org } public String getLocation(boolean forceSlashes) { - return getLocation(isWindowsNode() && !forceSlashes ? '\\' : '/', false); + return getLocation(isWindowsNode() && !forceSlashes ? '\\' : '/'); } - private String getLocation(char separator, boolean encodeName) { + private String getLocation(char separator) { String name = getName(); if (fType == Type.ROOT) { if (isWindowsNode() && name.charAt(name.length()-1) != separator) { @@ -260,17 +259,10 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org return name; - String pLoc = fParent.getLocation(separator, encodeName); + String pLoc = fParent.getLocation(separator); if (pLoc.length() == 0) return name; - if (encodeName) { - try { - name = URLEncoder.encode(getName(), "UTF-8"); //$NON-NLS-1$ - } catch (Exception e) { - // Ignore - } - } char lastChar = pLoc.charAt(pLoc.length()-1); if (lastChar != separator) return pLoc + separator + name; @@ -289,22 +281,8 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org */ @Override public URL getLocationURL() { - return getLocationURL(true); - } - - /** - * Get the URL of the file or folder. The URL's format is created in the - * following way: tcf:/<peerName>/remote/path/to/the/resource... See - * {@link TcfURLConnection#TcfURLConnection(URL)} - * @param encodeName whether or not the URL has to be encoded. - * - * @see TcfURLStreamHandlerService#parseURL(URL, String, int, int) - * @see #getLocationURI() - * @return The URL of the file/folder. - */ - public URL getLocationURL(boolean encodeName) { try { - URI uri = getLocationURI(encodeName); + URI uri = getLocationURI(); return uri == null ? null : uri.toURL(); } catch (MalformedURLException e) { CorePlugin.logError("Cannot create tcf url", e); //$NON-NLS-1$ @@ -320,22 +298,11 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org * * @return The URI of the file/folder. */ - @Override + @Override public URI getLocationURI() { - return getLocationURI(true); - } - - /** - * Get the URI of the file or folder. The URI's format is created in the - * following way: tcf:/<peerName>/remote/path/to/the/resource... - * @param encodeName whether or not the URL has to be encoded. - * - * @return The URI of the file/folder. - */ - public URI getLocationURI(boolean encodeName) { try { String name = getPeerNode().getName(); - String path = getLocation('/', encodeName); + String path = getLocation('/'); return new URI(TcfURLConnection.PROTOCOL_SCHEMA, name, addNoSlashMarker(path), null, null); } catch (URISyntaxException e) { CorePlugin.logError("Cannot create tcf uri", e); //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java index 1926cd7d4..22edb0aaf 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2015 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2016 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -86,7 +86,7 @@ public class OpDownload extends AbstractOperation { BufferedInputStream input = null; - TcfURLConnection connection = (TcfURLConnection) source.getLocationURL(false).openConnection(); + TcfURLConnection connection = (TcfURLConnection) source.getLocationURL().openConnection(); try { if (digest != null) { input = new BufferedInputStream(new DigestInputStream(connection.getInputStream(), digest)); |