mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
[287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname
This commit is contained in:
parent
31676d2717
commit
2736805097
5 changed files with 108 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2000, 2009 IBM Corporation 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
|
||||
|
@ -24,6 +24,7 @@
|
|||
* Remy Chi Jian Suen (IBM) - [192906][efs] No Error when trying to Create Remote Project when project with name exists
|
||||
* Martin Oberhuber (Wind River) - [182350] Support creating remote project on Windows Drive
|
||||
* Remy Chi Jian Suen (IBM) - [202098][efs][nls] Improve error message when creating a remote project with existing name
|
||||
* David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.efs.ui;
|
||||
|
@ -50,6 +51,7 @@ import org.eclipse.jface.viewers.ISelection;
|
|||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.rse.core.model.IHost;
|
||||
import org.eclipse.rse.internal.efs.Activator;
|
||||
import org.eclipse.rse.internal.efs.RSEFileSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
|
@ -195,9 +197,11 @@ public class CreateRemoteProjectActionDelegate implements IActionDelegate {
|
|||
}
|
||||
|
||||
IProjectDescription description = root.getWorkspace().newProjectDescription(projectName);
|
||||
String hostNameOrAddr = directory.getParentRemoteFileSubSystem().getHost().getHostName();
|
||||
IHost host = directory.getParentRemoteFileSubSystem().getHost();
|
||||
String hostNameOrAddr = host.getHostName();
|
||||
String hostAliasName = host.getAliasName();
|
||||
String absolutePath = directory.getAbsolutePath();
|
||||
URI location = RSEFileSystem.getURIFor(hostNameOrAddr, absolutePath);
|
||||
URI location = RSEFileSystem.getURIFor(hostNameOrAddr, absolutePath, hostAliasName);
|
||||
description.setLocationURI(location);
|
||||
|
||||
editProject.create(description, monitor);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Martin Oberhuber (Wind River) - [189441] fix EFS operations on Windows (Local) systems
|
||||
* David Dykstal (IBM) - [235840] externalizing dialog title
|
||||
* David McKnight (IBM) - [280763] [efs] Cannot pick a file when linking a resource (only folders)
|
||||
* David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
|
@ -55,7 +56,7 @@ public class RSEFileSystemContributor extends FileSystemContributor {
|
|||
|
||||
try {
|
||||
URI uri = new URI(initialPath);
|
||||
IHost host = RSEFileStoreImpl.getConnectionFor(uri.getHost(), null);
|
||||
IHost host = RSEFileStoreImpl.getConnectionFor(uri.getHost(), uri.getQuery(), new NullProgressMonitor());
|
||||
IRemoteFileSubSystem fs = RSEFileStoreImpl.getRemoteFileSubSystem(host);
|
||||
dlg.setInputObject(fs.getRemoteFileObject(uri.getPath(), new NullProgressMonitor()));
|
||||
}
|
||||
|
@ -81,6 +82,7 @@ public class RSEFileSystemContributor extends FileSystemContributor {
|
|||
|
||||
IHost host = dlg.getSelectedConnection();
|
||||
String hostName = host.getHostName();
|
||||
String aliasName = host.getAliasName();
|
||||
|
||||
IRemoteFile file = (IRemoteFile)selected;
|
||||
String path = file.getAbsolutePath();
|
||||
|
@ -89,7 +91,7 @@ public class RSEFileSystemContributor extends FileSystemContributor {
|
|||
}
|
||||
path = fixPathForURI(path);
|
||||
try {
|
||||
return new URI("rse", hostName, path, null); //$NON-NLS-1$
|
||||
return new URI("rse", hostName, path, aliasName, null); //$NON-NLS-1$
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
SystemMessageDialog.displayErrorMessage(SystemMessageDialog.getDefaultShell(), e.getLocalizedMessage());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2009 IBM Corporation 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
|
||||
|
@ -21,6 +21,7 @@
|
|||
* Martin Oberhuber (Wind River) - [191589] fix Rename by adding putInfo() for RSE EFS, and fetch symlink info
|
||||
* Kevin Doyle (IBM) - [210673] [efs][nls] Externalize Strings in RSEFileStore and RSEFileStoreImpl
|
||||
* Timur Shipilov (Xored) - [224538] RSEFileStore.getParent() returns null for element which is not root of filesystem
|
||||
* David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.efs;
|
||||
|
@ -58,6 +59,7 @@ public class RSEFileStore extends FileStore
|
|||
private RSEFileStore _parent;
|
||||
private String _host;
|
||||
private String _name;
|
||||
private String _alias;
|
||||
private IPath _absolutePath;
|
||||
|
||||
//cached IRemoteFile object: an Object to avoid early class loading
|
||||
|
@ -94,6 +96,27 @@ public class RSEFileStore extends FileStore
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to use if the file store is a handle.
|
||||
* @param host the connection name for the file store.
|
||||
* @param absolutePath an absolute path to the file, valid on the remote file system.
|
||||
* @param aliasName the connection alias for the file store
|
||||
*/
|
||||
private RSEFileStore(String host, String absolutePath, String aliasName) {
|
||||
_parent = null;
|
||||
_host = host;
|
||||
_absolutePath = new Path(absolutePath);
|
||||
_alias = aliasName;
|
||||
_name = _absolutePath.lastSegment();
|
||||
if (_name == null) {
|
||||
//Windows Root Drive has no segments but needs a name
|
||||
_name = _absolutePath.getDevice();
|
||||
if (_name == null) {
|
||||
_name = ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Public factory method for obtaining RSEFileStore instances.
|
||||
|
@ -106,7 +129,8 @@ public class RSEFileStore extends FileStore
|
|||
if (store==null) {
|
||||
String path = uri.getPath();
|
||||
String hostName = uri.getHost();
|
||||
store = new RSEFileStore(hostName, path);
|
||||
String aliasName = uri.getQuery();
|
||||
store = new RSEFileStore(hostName, path, aliasName);
|
||||
instanceMap.put(uri, store);
|
||||
}
|
||||
return store;
|
||||
|
@ -139,6 +163,10 @@ public class RSEFileStore extends FileStore
|
|||
//TODO consider computing this instead of storing it
|
||||
return _host;
|
||||
}
|
||||
|
||||
String getAlias() {
|
||||
return _alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an absolute path for this file store.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2009 IBM Corporation 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
|
||||
|
@ -31,6 +31,7 @@
|
|||
* Martin Oberhuber (Wind River) - [233993] Improve EFS error reporting
|
||||
* Martin Oberhuber (Wind River) - [220300] EFS Size Property not properly updated after saving
|
||||
* Martin Oberhuber (Wind River) - [234026] Clarify IFileService#createFolder() Javadocs
|
||||
* David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.efs;
|
||||
|
@ -147,13 +148,14 @@ public class RSEFileStoreImpl extends FileStore
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the best RSE connection object matching the given host name.
|
||||
* Return the best RSE connection object matching the given host name and/or connection alias.
|
||||
*
|
||||
* @param hostNameOrAddr IP address of requested host.
|
||||
* @return RSE connection object matching the given host name, or
|
||||
* @param hostNameOrAddr the host name IP address of requested host.
|
||||
* @param aliasName the connection alias of the requested host
|
||||
* @return RSE connection object matching the given connection alias, host name, or
|
||||
* <code>null</code> if no matching connection object was found.
|
||||
*/
|
||||
public static IHost getConnectionFor(String hostNameOrAddr, IProgressMonitor monitor) {
|
||||
public static IHost getConnectionFor(String hostNameOrAddr, String aliasName, IProgressMonitor monitor) {
|
||||
if (hostNameOrAddr==null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -164,18 +166,36 @@ public class RSEFileStoreImpl extends FileStore
|
|||
IHost[] connections = sr.getHosts();
|
||||
|
||||
IHost unconnected = null;
|
||||
for (int i = 0; i < connections.length; i++) {
|
||||
|
||||
IHost con = connections[i];
|
||||
|
||||
//TODO use more elaborate methods of checking whether two
|
||||
//host names/IP addresses are the same; or, use the host alias
|
||||
if (hostNameOrAddr.equalsIgnoreCase(con.getHostName())) {
|
||||
IRemoteFileSubSystem fss = getRemoteFileSubSystem(con);
|
||||
if (fss!=null && fss.isConnected()) {
|
||||
return con;
|
||||
} else {
|
||||
unconnected = con;
|
||||
|
||||
// first look for connection alias
|
||||
if (aliasName != null){
|
||||
for (int i = 0; i < connections.length; i++) {
|
||||
IHost con = connections[i];
|
||||
|
||||
if (aliasName.equalsIgnoreCase(con.getAliasName())){
|
||||
IRemoteFileSubSystem fss = getRemoteFileSubSystem(con);
|
||||
if (fss!=null && fss.isConnected()) {
|
||||
return con;
|
||||
} else {
|
||||
unconnected = con;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (unconnected == null){
|
||||
// if nothing matches the connection alias, fall back to hostname
|
||||
for (int i = 0; i < connections.length; i++) {
|
||||
IHost con = connections[i];
|
||||
//TODO use more elaborate methods of checking whether two
|
||||
//host names/IP addresses are the same; or, use the host alias
|
||||
if (hostNameOrAddr.equalsIgnoreCase(con.getHostName())) {
|
||||
IRemoteFileSubSystem fss = getRemoteFileSubSystem(con);
|
||||
if (fss!=null && fss.isConnected()) {
|
||||
return con;
|
||||
} else {
|
||||
unconnected = con;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,13 +249,14 @@ public class RSEFileStoreImpl extends FileStore
|
|||
* Returns the best connected file subsystem for this file store.
|
||||
* Never returns <code>null</code>.
|
||||
* @param hostNameOrAddr host name or IP address
|
||||
* @param aliasName the connection alias
|
||||
* @param monitor progress monitor
|
||||
* @return The best connected file subsystem for this file store.
|
||||
* @throws CoreException if no file subsystem could be found or connected.
|
||||
*/
|
||||
public static IRemoteFileSubSystem getConnectedFileSubSystem(String hostNameOrAddr, IProgressMonitor monitor) throws CoreException
|
||||
public static IRemoteFileSubSystem getConnectedFileSubSystem(String hostNameOrAddr, String aliasName, IProgressMonitor monitor) throws CoreException
|
||||
{
|
||||
IHost con = RSEFileStoreImpl.getConnectionFor(hostNameOrAddr, monitor);
|
||||
IHost con = RSEFileStoreImpl.getConnectionFor(hostNameOrAddr, aliasName, monitor);
|
||||
if (con == null) {
|
||||
throw new CoreException(new Status(IStatus.ERROR,
|
||||
Activator.getDefault().getBundle().getSymbolicName(),
|
||||
|
@ -315,7 +336,10 @@ public class RSEFileStoreImpl extends FileStore
|
|||
}
|
||||
} else {
|
||||
//Handle was created with an absolute name
|
||||
IRemoteFileSubSystem subSys = RSEFileStoreImpl.getConnectedFileSubSystem(_store.getHost(), monitor);
|
||||
String aliasName = _store.getAlias();
|
||||
String hostName = _store.getHost();
|
||||
IRemoteFileSubSystem subSys = RSEFileStoreImpl.getConnectedFileSubSystem(hostName, aliasName, monitor);
|
||||
|
||||
try {
|
||||
remoteFile = subSys.getRemoteFileObject(_store.getAbsolutePath(), monitor);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2009 IBM Corporation 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
|
||||
|
@ -19,6 +19,7 @@
|
|||
* - Also remove unnecessary class RSEFileCache and obsolete branding files.
|
||||
* Martin Oberhuber (Wind River) - [188360] renamed from plugin org.eclipse.rse.eclipse.filesystem
|
||||
* Martin Oberhuber (Wind River) - [199587] return attributes of RSEFileSystem
|
||||
* David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.efs;
|
||||
|
@ -108,4 +109,25 @@ public class RSEFileSystem extends FileSystem
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an URI uniquely naming an RSE remote resource.
|
||||
* @param hostNameOrAddr host name or IP address of remote system
|
||||
* @param absolutePath absolute path to resource as valid on the remote system
|
||||
* @param alias the alias name for the connection
|
||||
* @return an URI uniquely naming the remote resource.
|
||||
*/
|
||||
public static URI getURIFor(String hostNameOrAddr, String absolutePath, String alias) {
|
||||
//FIXME backslashes are valid in UNIX file names. This is not correctly handled yet.
|
||||
if (absolutePath.charAt(0) != '/') {
|
||||
absolutePath = "/" + absolutePath.replace('\\', '/'); //$NON-NLS-1$
|
||||
}
|
||||
try {
|
||||
return new URI("rse", hostNameOrAddr, absolutePath, alias, null); //$NON-NLS-1$
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue