Bug 195285 - [api][breaking] mountPathMapper extension point should be more general than local
Summary: [api][breaking] mountPathMapper extension point should be more general than l...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 M4   Edit
Assignee: David McKnight CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 245260
  Show dependency tree
 
Reported: 2007-07-03 11:44 EDT by David McKnight CLA
Modified: 2009-03-10 06:21 EDT (History)
2 users (show)

See Also:


Attachments
changes to mount path mapper extension point (15.27 KB, patch)
2007-10-18 11:24 EDT, David McKnight CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David McKnight CLA 2007-07-03 11:44:19 EDT
Currently the mountPathMapper extension point only solves mounted path issues for local.  When a local windows drive points to a remote location, the mapper allows for custom temp file locations such that if the drive letter changes, the mapping will remain the same.  It would make sense to generalize this functionality to include non-local so that custom mappings can be made for all kinds of remote connections.
Comment 1 Martin Oberhuber CLA 2007-07-03 12:01:48 EDT
Would this enhancement require API changes?
Comment 2 David McKnight CLA 2007-07-04 12:57:42 EDT
As far as I can tell, it shouldn't need API changes... but more investigation is required.  I'll put this as 2.0.1 for now.
Comment 3 David McKnight CLA 2007-10-18 10:18:28 EDT
In order for this to work generically, we need to expand the ISystemMountPathMapper API to include user ids.  With user ids, it will allow us to map files from one host differently depending on the user id.  For example, if  there are two different connections to the same FTP host, each using a different user id, the file systems paths may overlap yet not correspond to the same files - so we'd need to use the user id to distinguish how these are mapped.
  
Comment 4 Martin Oberhuber CLA 2007-10-18 10:26:01 EDT
Can't we abstract from adding the userID, and rather allow the mountPathMapper to choose a different kind of mapping based on _any_ kind of property in the host that it's free to choose?

There could be a default implementation mapping based on host and username, but contributed implementations should also be able to map based on other properties (e.g. port, subsystem kind).
Comment 5 David McKnight CLA 2007-10-18 10:44:14 EDT
So Martin, are you suggesting that rather than having the framework pass in userId as an addition arg, like the 3rd arg here:

	/**
	 * Returns the qualified workspace path for a replica of this mounted file.  Since the
	 * system path is not unique for mounted files, this allows a vender to make sure it is unique.
	 * The workspace mapping should always be the remote path on the originating host.
	 * 
	 * @param hostname the remote host
	 * @param remotePath the remote path as seen by the file subsystem
	 * @param userId the user id on the host
     * @return the corresponding workspace replica mapping
	 */
	public String getWorkspaceMappingFor(String hostname, String remotePath, String userId);
	
	
	/**
	 * Returns the system path that can be used for copying the replica back to remote. When null
	 * is returned RSE the file is treated as no longer available and thus remote uploads do not occur.  Vendors
	 * who would like to disable uploads for some period can implement this to return null during that period.
	 * 
	 * @param hostname the remote host
	 * @param remotePath the remote path as seen by the local file subsystem
	 * @param userId the user id on the host
	 * @return the local system path that represents the mounted file
	 */
	public String getMountedMappingFor(String hostname, String remotePath, String userId);


... we should instead use something more general, perhaps the FileSubSystem?

Comment 6 Martin Oberhuber CLA 2007-10-18 10:56:14 EDT
Passing the IFileServiceSubSystem seems like a good idea.
Perhaps even the ISubSystem to make it more general.

From the subsystem, code can get the host, port, username and all 
other properties, right?
Comment 7 David McKnight CLA 2007-10-18 11:08:51 EDT
The IRemoteFileSubSystem probably makes the most sense since it has access to all the stuff we need (host, port, user id, etc).  This mount path stuff is a file-specific thing, so I don't think it helps to generalize to ISubSystem.  

I'm thinking that the only API we need to change is this:

	/**
	 * Returns the qualified workspace path for a replica of this mounted file.  Since the
	 * system path is not unique for mounted files, this allows a vender to make sure it is unique.
	 * The workspace mapping should always be the remote path on the originating host.
	 * 
	 * @param hostname the remote host
	 * @param remotePath the remote path as seen by the file subsystem
	 * @param the remote file subsystem
     * @return the corresponding workspace replica mapping
	 */
	public String getWorkspaceMappingFor(String hostname, String remotePath, IRemoteFileSubSystem subsystem);
	

For download this allows us to customize where the file goes in the temp files.  For upload, we wouldn't need this because we already have the remote path, independent of the temp file location.

Comment 8 Martin Oberhuber CLA 2007-10-18 11:17:19 EDT
sounds good to me.
Comment 9 Martin Oberhuber CLA 2007-10-18 11:17:43 EDT
any chance to make it backward compatible? (I'd guess not)
Comment 10 David McKnight CLA 2007-10-18 11:24:20 EDT
Created attachment 80671 [details]
changes to mount path mapper extension point
Comment 11 David McKnight CLA 2007-10-18 11:27:07 EDT
Martin, can you review this.  Let me know what you think.
Comment 12 David McKnight CLA 2007-10-19 11:00:37 EDT
I've committed the changes to cvs.
Comment 13 David McKnight CLA 2007-10-25 15:20:27 EDT
*** Bug 193858 has been marked as a duplicate of this bug. ***
Comment 14 Martin Oberhuber CLA 2007-11-14 09:22:04 EST
ISystemMountPathMapper#getWorkspaceMappingFor() has been changed to expect an additional parameter of type IRemoteFileSubSystem:

http://dsdp.eclipse.org/help/latest/topic/org.eclipse.rse.doc.isv/reference/api/org/eclipse/rse/files/ui/resources/ISystemMountPathMapper.html
Comment 15 Martin Oberhuber CLA 2007-11-14 16:47:10 EST
I think that the change is not sufficient to be practically usable.

Looking at SystemRemoteEditManager#getMountPathMapperFor(), where the mount path mapper extension is actually used, it appears that when an ISV defines his own mountPathMapper it would never be used when the DefaultMountPathMapper is also active.

It looks like mountPathMappers need a concept of being "more specific" than others, such that the code that gets a mapper iterates by order of priority. 

Also, it looks like it would make sense if 
  ISystemMountPathMapper#handlesMappingFor()
also included the additional IRemoteFileSubSystem parameter.

Finally, the Javadoc in ISystemMountPathMapper does not seem sufficient for me. When reading it, I don't really understand how I would declare the extension correctly in order to satisfy, for instance, the following use cases:
  -) Add username in the mapped path
  -) Add port in the mapped path
  -) Support mapping of invalid characters, e.g. :<>?* on Windows
Comment 16 David McKnight CLA 2007-11-26 12:33:26 EST
(In reply to comment #15)
> I think that the change is not sufficient to be practically usable.
> 
> Looking at SystemRemoteEditManager#getMountPathMapperFor(), where the mount
> path mapper extension is actually used, it appears that when an ISV defines his
> own mountPathMapper it would never be used when the DefaultMountPathMapper is
> also active.

Currently, DefaultMountPathMapper.handlesMappingFor() returns false, so it should never actually be used.  

> 
> It looks like mountPathMappers need a concept of being "more specific" than
> others, such that the code that gets a mapper iterates by order of priority. 
> 

A priority field in the xml wouldn't help make one extension more specific but perhaps we could introduce a new API to ISystemMountPathMapper:

int getPriority(String hostname, String remotePath, IRemoteFileSubSystem subsystem);

It would be nice if the handlesMappingFor could somehow be combined with getPriority().

> Also, it looks like it would make sense if 
>   ISystemMountPathMapper#handlesMappingFor()
> also included the additional IRemoteFileSubSystem parameter.
> 

You're right, it probably makes sense to add the IRemoteFileSubSystem parameter here.


> Finally, the Javadoc in ISystemMountPathMapper does not seem sufficient for me.
> When reading it, I don't really understand how I would declare the extension
> correctly in order to satisfy, for instance, the following use cases:
>   -) Add username in the mapped path
>   -) Add port in the mapped path
>   -) Support mapping of invalid characters, e.g. :<>?* on Windows
> 

I'll take a look at the javadoc.
Comment 17 David McKnight CLA 2007-12-13 11:13:26 EST
I've made changes as suggested.  I've changed handlesMappingFor to:

	public boolean handlesMappingFor(String hostname, String remotePath, IRemoteFileSubSystem subsystem);

I've also added:


int getPriority(String hostname, String remotePath, IRemoteFileSubSystem subsystem);

And I've put in more javadoc to describe the use cases.
Comment 18 Martin Oberhuber CLA 2009-03-10 06:21:31 EDT
Bug 245260 extends on this API, providing a UI for changing the way the DefaultMountPathMapper works.