Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326186 - Provide a URI format that contains connection information
Summary: Provide a URI format that contains connection information
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.0   Edit
Hardware: Other All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard: Appealing to a Broader Community
Keywords: noteworthy
: 291574 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-24 14:27 EDT by Lothar Werzinger CLA
Modified: 2012-06-04 03:54 EDT (History)
5 users (show)

See Also:


Attachments
Patch v1 - for future reference (72.21 KB, patch)
2010-10-09 01:18 EDT, Eike Stepper CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lothar Werzinger CLA 2010-09-24 14:27:51 EDT
Build Identifier: 

Currently one can not access a CDO model with the generic EMF resource framework, as CDO does not (yet) have a URI schema that provides all the necessary information to connect to the CDO server to retrieve the resource.

The new URI could look like this:

cdo.net4j.tcp://user@server:port/repository/MAIN/branch/@HEAD/folder/resource

(got that example URI from Eike)


Reproducible: Always
Comment 1 Eike Stepper CLA 2010-09-24 23:18:58 EDT
> Currently one can not access a CDO model with the generic EMF resource
> framework, as CDO does not (yet) have a URI schema that provides all the
> necessary information to connect to the CDO server to retrieve the resource.

While this bugzilla generally makes sense (i.e. add connection infos to the URI), I'd like to put this right: Of course one can access CDO resources with the generic EMF resource framework.

It just requires to register a CDOViewProvider with CDOViewProviderRegistry.INSTANCE, either programmatically or via the extension point org.eclipse.emf.cdo.viewProviders.
Comment 2 Eike Stepper CLA 2010-10-05 05:57:10 EDT
*** Bug 291574 has been marked as a duplicate of this bug. ***
Comment 3 Eike Stepper CLA 2010-10-05 06:06:33 EDT
Adding password support:

cdo.net4j.tcp://user:password@server:port/repository/MAIN/branch/@HEAD/folder/resource

I'm a bit unsure about the time component, e.g. "@HEAD" in the path of the new URI format. Maybe it's better to make the view/tx target time a query parameter instead to prevent unfolding an indefinite layer in the resulting namespace (tree). opinions?
Comment 4 Eike Stepper CLA 2010-10-05 07:13:33 EDT
(In reply to comment #3)
> I'm a bit unsure about the time component, e.g. "@HEAD" in the path of the new
> URI format. Maybe it's better to make the view/tx target time a query parameter
> instead to prevent unfolding an indefinite layer in the resulting namespace
> (tree). opinions?

On the other hand we need a separator between the branchPath component and the resourcePath component. Currently that is a segment starting with "@", i.e. the timeStamp component
Comment 5 Eike Stepper CLA 2010-10-05 08:05:00 EDT
I tend to make the branchPath component as well as the timeStamp component and possibly a readOnly component query parameters rather than part of the path...
Comment 6 Martin Fluegge CLA 2010-10-05 14:25:17 EDT
>I tend to make the branchPath component as well as the timeStamp component and
>possibly a readOnly component query parameters rather than part of the path...

I don't get the complete meaning of the sentence? Did you miss a word or am I simply to tired? ;)

What I understood is "query". And I think that sounds good. What about the following?

cdo.net4j.tcp://user:password@server:port/repository/folderpath/resource?branch=MAIN&timestamp=HEAD

Eike, did you mean something like this?

The query part would allow us to insert additional and/or new parameters in the future and thus sounds like a flexible solution. 

Or is there someting that speaks against using the query part?
Comment 7 Eike Stepper CLA 2010-10-05 14:50:18 EDT
(In reply to comment #6)
> >I tend to make the branchPath component as well as the timeStamp component and
> >possibly a readOnly component query parameters rather than part of the path...
> 
> I don't get the complete meaning of the sentence? Did you miss a word or am I
> simply to tired? ;)

Too tried :P

> What I understood is "query". And I think that sounds good. What about the
> following?
> 
> cdo.net4j.tcp://user:password@server:port/repository/folderpath/resource?branch=MAIN&timestamp=HEAD

That's exactly what I meant. Possibly and optionally plus "&readOnly=true"
Comment 8 Martin Fluegge CLA 2010-10-05 15:00:52 EDT
> Too tried :P

O.k. Too tired :P

>That's exactly what I meant. Possibly and optionally plus "&readOnly=true"

Sounds good. :)
Comment 9 Eike Stepper CLA 2010-10-09 01:18:13 EDT
Created attachment 180538 [details]
Patch v1 - for future reference
Comment 10 Eike Stepper CLA 2010-10-09 02:24:39 EDT
Committed to HEAD

The new (optional) connection-aware URI format is:

   "cdo.net4j." connector-type "://" [user [":" password] "@"] connector-specific-authority "/" repository-name "/" resource-path ["?" param ("&" param)*]
   
With:

   connector-type: tcp | jvm | http | ...
   
   user/password: to be provided if the repository is configured with an IUserManager and, hence, triggers authentication on the client. NOTE: the password may be stored in resources in clear text!
   
   connector-specific-authority: 
      host [":" port] if the connector-type is "tcp"
      acceptor-name if the connector-type is "jvm"
      
   repository-name: the name of the repository (not the UUID!)
   
   resource-path: the full path of the resource within the repository, segments separated by slashes, no leading slash
   
   param: one of
      "branch=" branch-path, the full path of the branch in the branch tree, segments separated by slashes, no leading slash, defaults to "MAIN"
      "time=" time-spec, the time at which the resource is supposed to be valid, parseable by SimpleDateFormat
      "time=HEAD" indicates a floating view/transaction that always shows the latest state in the chosen branch, the default if no time parameter is specified
      "transactional=true" forces a the resource to be opened in a transaction rather than in a read-only view, can not be combined with a time-spec other than "HEAD"
      
NOTE: With the current design and implementation of connection-aware URI (mainly CDONet4jViewProvider) it is still unclear when and how the allocated "resources" (aka IConnector, CDOSession, CDOView, etc) are supposed to be freed!

---

The canonical URI format is of course also available:

   "cdo://" repository-uuid "/" resource-path
   
URIs in the canonical form to resolve properly require the resource set to be configured externally so that the connection to the correct repository can be established.

NOTE: CDOResources now preserve their original URI, that is not necessarily in canonical format!
Comment 11 Eike Stepper CLA 2010-10-13 02:01:17 EDT
I've fixed a bug in CDOURIData.toString() that produced the first (query-part-less) format.
Comment 12 Eike Stepper CLA 2010-10-18 14:06:09 EDT
The credentials have been removed from serialized URIs. To load a CDOResource through a non-CDO resource if authentication is required an IPassordCredentialsProvider has to be registered in with IPluginContainer.INSTANCE, e.g.:

uri = URI.createURI("cdo.net4j.tcp://www.bar.com/repo1");
provider = new PasswordCredentialsProvider.Delegating(new InteractiveCredentialsProvider());
CDOUtil.setCredentialsProvider(uri, provider);
Comment 13 Alex Lagarde CLA 2010-11-09 06:57:29 EST
As established on EMF Community Forum (http://www.eclipse.org/forums/index.php?t=msg&goto=637142&S=d2575181f9e963b075ed35f97229f38a#msg_637142), it would be nice that users can activate such connection-aware URIs by default. 

For example, by using CDOURIUtil.setURIMode(URIMode.CONNECTION_AWARE) or session.options().setURIMode(), any CDO Object referenced in a local resource will be serialized using connection-aware URIs instead of standard CDO URIs.

For example, if user didn't change the URIMode, a local resource referencing a CDOObject will be serialized as following : 

<referencedElement xmi:type="cars:Garage" href="cdo:/repo1/remoteSemanticResource.xmi#1"/>

Therefore, if the connection to the CDO Repository is closed, there is no way to reconnect to this repository automatically.

if the user has activated the CONNECTION_WARE mode for URIs : 

<referencedElement xmi:type="cars:Garage" href="cdo.net4j.tcp://localhost/repo1/remoteSemanticResource.xmi?transactional=true#1"/>
Reconnection to Repositories will then be transparent to users.

If possible, extension mechanisms should be provided to control how the reconnection is made by CDO (do the created session have to allow legacyMode, what is its PassiveUpdateMode...), so that this reconnection mechanism can be used in all useCases.
Comment 14 Eike Stepper CLA 2011-06-23 03:41:27 EDT
Available in R20110608-1407
Comment 15 Erdal Karaca CLA 2012-06-04 03:54:49 EDT
What do I have to do to make EcoreUti.getURI(eObject) return a connection aware URI? Is there an option or API to turn connection aware URI generation on/off as suggested by Alex in comment 13?