Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-09-26 06:21:50 +0000
committerEike Stepper2020-09-26 06:21:50 +0000
commit3f0d7aa7197e5570524db131b8508a9a954c975a (patch)
tree7bbd80e5da343342c2a3d744848a4c2f2391e431
parentaee65d3b58a3136a2ece894fbb7e05abfc4841b8 (diff)
downloadcdo-3f0d7aa7197e5570524db131b8508a9a954c975a.tar.gz
cdo-3f0d7aa7197e5570524db131b8508a9a954c975a.tar.xz
cdo-3f0d7aa7197e5570524db131b8508a9a954c975a.zip
[567178] CDOURIHandler.canHandle(URI) is too lax
https://bugs.eclipse.org/bugs/show_bug.cgi?id=567178
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutViewProvider.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jViewProvider.java119
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java70
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF52
-rw-r--r--plugins/org.eclipse.emf.cdo/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java284
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/AbstractCDOViewProvider.java36
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewProvider.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewProviderRegistryImpl.java46
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java53
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java3
16 files changed, 390 insertions, 312 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutViewProvider.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutViewProvider.java
index 8b364b3dec..4b7f1fb734 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutViewProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutViewProvider.java
@@ -88,7 +88,7 @@ public class CDOCheckoutViewProvider extends AbstractCDOViewProvider
return checkout.createResourceURI(path);
}
- return super.getResourceURI(view, path);
+ return null;
}
public static void disposeResourceSet(ResourceSet resourceSet)
diff --git a/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF
index cea0b58387..e354b51c68 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.net4j/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo.net4j; singleton:=true
-Bundle-Version: 4.3.1.qualifier
+Bundle-Version: 4.4.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -10,11 +10,11 @@ Bundle-Activator: org.eclipse.emf.cdo.internal.net4j.bundle.OM$Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.emf.cdo;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.internal.net4j;version="4.3.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.ui,org.eclipse.emf.cdo.examples",
- org.eclipse.emf.cdo.internal.net4j.bundle;version="4.3.1";x-friends:="org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.net4j.messages;version="4.3.1";x-internal:=true,
- org.eclipse.emf.cdo.internal.net4j.protocol;version="4.3.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.ui,org.eclipse.emf.cdo.examples",
- org.eclipse.emf.cdo.internal.net4j.testrecorder;version="4.3.1";x-internal:=true,
- org.eclipse.emf.cdo.net4j;version="4.3.1"
+Export-Package: org.eclipse.emf.cdo.internal.net4j;version="4.4.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.ui,org.eclipse.emf.cdo.examples",
+ org.eclipse.emf.cdo.internal.net4j.bundle;version="4.4.0";x-friends:="org.eclipse.emf.cdo.tests",
+ org.eclipse.emf.cdo.internal.net4j.messages;version="4.4.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.net4j.protocol;version="4.4.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.ui,org.eclipse.emf.cdo.examples",
+ org.eclipse.emf.cdo.internal.net4j.testrecorder;version="4.4.0";x-internal:=true,
+ org.eclipse.emf.cdo.net4j;version="4.4.0"
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.eclipse.emf.cdo.net4j
diff --git a/plugins/org.eclipse.emf.cdo.net4j/pom.xml b/plugins/org.eclipse.emf.cdo.net4j/pom.xml
index bda13d9427..8f83c258b2 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.net4j/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo.net4j</artifactId>
- <version>4.3.1-SNAPSHOT</version>
+ <version>4.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jViewProvider.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jViewProvider.java
index c0403c4072..e3e50818ba 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jViewProvider.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jViewProvider.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.net4j;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.util.CDOURIData;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.util.InvalidURIException;
import org.eclipse.emf.cdo.view.AbstractCDOViewProvider;
import org.eclipse.emf.cdo.view.CDOView;
@@ -34,9 +35,6 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
/**
* A {@link CDOViewProvider view provider} that uses Net4j-specific CDO {@link CDONet4jSession sessions} to open views.
*
@@ -57,12 +55,22 @@ public abstract class CDONet4jViewProvider extends AbstractCDOViewProvider
}
@Override
+ public String getPath(URI uri)
+ {
+ return new Path(uri.path()).makeAbsolute().removeFirstSegments(1).toString();
+ }
+
+ @Override
public CDOView getView(URI uri, ResourceSet resourceSet)
{
CDOURIData data = createURIData(uri);
+ String authority = data.getAuthority();
+ String userName = data.getUserName();
+ String passWord = data.getPassWord();
+ String repositoryName = data.getRepositoryName();
- IConnector connector = getConnector(data.getAuthority());
- CDONet4jSession session = getNet4jSession(connector, data.getUserName(), data.getPassWord(), data.getRepositoryName());
+ IConnector connector = getConnector(authority);
+ CDONet4jSession session = getNet4jSession(connector, userName, passWord, repositoryName);
String viewID = data.getViewID();
if (viewID != null)
@@ -77,58 +85,36 @@ public abstract class CDONet4jViewProvider extends AbstractCDOViewProvider
String branchPath = data.getBranchPath().toPortableString();
CDOBranch branch = session.getBranchManager().getBranch(branchPath);
- long timeStamp = data.getTimeStamp();
if (data.isTransactional())
{
return session.openTransaction(branch, resourceSet);
}
+ long timeStamp = data.getTimeStamp();
return session.openView(branch, timeStamp, resourceSet);
}
@Override
- public String getPath(URI uri)
- {
- return new Path(uri.path()).makeAbsolute().removeFirstSegments(1).toString();
- }
-
- @Override
public URI getViewURI(URI uri)
{
- CDOURIData uriData = createURIData(uri);
- uriData.setResourcePath(null);
- uriData.setExtraParameters(null);
- return uriData.toURI();
+ // Remove all (resource path) segments and leave only the repository name segment.
+ return uri.trimSegments(uri.segmentCount() - 1);
+
+ // CDOURIData uriData = createURIData(uri);
+ // uriData.setResourcePath(null);
+ // uriData.setExtraParameters(null);
+ // return uriData.toURI();
}
@Override
public URI getResourceURI(CDOView view, String path)
{
- StringBuilder builder = new StringBuilder();
- builder.append("cdo.net4j.");
- builder.append(transport);
- builder.append("://");
+ String branchPath = view.getBranch().getPathName();
+ long timeStamp = view.getTimeStamp();
+ boolean readOnly = view.isReadOnly();
CDONet4jSession session = (CDONet4jSession)view.getSession();
-
- // CDOAuthenticator authenticator = ((InternalCDOSession)session).getAuthenticator();
- // IPasswordCredentialsProvider credentialsProvider = authenticator.getCredentialsProvider();
- // if (credentialsProvider != null)
- // {
- // IPasswordCredentials credentials = credentialsProvider.getCredentials();
- // builder.append(credentials.getUserID());
- //
- // char[] password = credentials.getPassword();
- // if (password != null)
- // {
- // builder.append(":");
- // builder.append(password);
- // }
- //
- // builder.append("@");
- // }
-
IChannel channel = session.options().getNet4jProtocol().getChannel();
if (channel == null)
{
@@ -136,47 +122,36 @@ public abstract class CDONet4jViewProvider extends AbstractCDOViewProvider
}
IConnector connector = (IConnector)channel.getMultiplexer();
+ String authority = getURIAuthority(connector);
String repositoryName = session.getRepositoryInfo().getName();
- append(builder, connector, repositoryName);
-
- if (path != null)
- {
- if (!path.startsWith("/"))
- {
- builder.append("/");
- }
- builder.append(path);
- }
+ return getResourceURI(transport, authority, repositoryName, path, branchPath, timeStamp, readOnly);
+ }
- int params = 0;
+ /**
+ * @since 4.4
+ */
+ public URI getResourceURI(String transport, String authority, String repositoryName, String resourcePath, String branchPath, long timeStamp, boolean readOnly)
+ {
+ StringBuilder query = new StringBuilder();
- String branchPath = view.getBranch().getPathName();
if (!CDOBranch.MAIN_BRANCH_NAME.equalsIgnoreCase(branchPath))
{
- builder.append(params++ == 0 ? "?" : "&");
- builder.append(CDOURIData.BRANCH_PARAMETER);
- builder.append("=");
- builder.append(branchPath);
+ CDOURIUtil.appendQueryParameter(query, CDOURIData.BRANCH_PARAMETER, branchPath);
}
- long timeStamp = view.getTimeStamp();
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
{
- builder.append(params++ == 0 ? "?" : "&");
- builder.append(CDOURIData.TIME_PARAMETER);
- builder.append("=");
- builder.append(new SimpleDateFormat().format(new Date(timeStamp)));
+ CDOURIUtil.appendQueryParameter(query, CDOURIData.TIME_PARAMETER, Long.toString(timeStamp));
}
- if (!view.isReadOnly())
+ if (!readOnly)
{
- builder.append(params++ == 0 ? "?" : "&");
- builder.append(CDOURIData.TRANSACTIONAL_PARAMETER);
- builder.append("=true");
+ CDOURIUtil.appendQueryParameter(query, CDOURIData.TRANSACTIONAL_PARAMETER, "true");
}
- return URI.createURI(builder.toString());
+ URI uri = URI.createHierarchicalURI("cdo.net4j." + transport, authority, null, query.toString(), null).appendSegment(repositoryName);
+ return CDOURIUtil.appendResourcePath(uri, resourcePath);
}
/**
@@ -218,9 +193,8 @@ public abstract class CDONet4jViewProvider extends AbstractCDOViewProvider
}
else
{
- StringBuilder builder = new StringBuilder();
- append(builder, connector, repositoryName);
- String resource = builder.toString();
+ String authority = getURIAuthority(connector);
+ String resource = authority + CDOURIUtil.SEGMENT_SEPARATOR + repositoryName;
try
{
@@ -285,15 +259,6 @@ public abstract class CDONet4jViewProvider extends AbstractCDOViewProvider
return authority;
}
- private void append(StringBuilder builder, IConnector connector, String repositoryName)
- {
- String authority = getURIAuthority(connector);
- builder.append(authority);
-
- builder.append("/");
- builder.append(repositoryName);
- }
-
/**
* A JVM-based {@link CDONet4jViewProvider view provider}.
*
@@ -328,7 +293,6 @@ public abstract class CDONet4jViewProvider extends AbstractCDOViewProvider
{
this(DEFAULT_PRIORITY);
}
-
}
/**
@@ -347,7 +311,6 @@ public abstract class CDONet4jViewProvider extends AbstractCDOViewProvider
{
this(DEFAULT_PRIORITY);
}
-
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java
index 74e3530603..d53640abf4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewProviderTest.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.net4j.CDONet4jViewProvider;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
import org.eclipse.emf.cdo.tests.model1.OrderDetail;
@@ -21,6 +22,7 @@ import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
+import org.eclipse.emf.internal.cdo.view.PluginContainerViewProvider;
import org.eclipse.net4j.util.container.IPluginContainer;
@@ -113,6 +115,69 @@ public class ViewProviderTest extends AbstractCDOTest
assertEquals(true, xmi.indexOf(uri.toString()) != -1);
}
+ public void testPluginViewProvider() throws Exception
+ {
+ PluginContainerViewProvider vp = new PluginContainerViewProvider();
+
+ assertEquals("cdo://repo1/", vp.getResourceURI("repo1", null).toString());
+ assertEquals("cdo://repo1/", vp.getResourceURI("repo1", "").toString());
+ assertEquals("cdo://repo1/", vp.getResourceURI("repo1", "/").toString());
+ assertEquals("cdo://repo1/", vp.getResourceURI("repo1", "//").toString());
+ assertEquals("cdo://repo1/a", vp.getResourceURI("repo1", "/a").toString());
+ assertEquals("cdo://repo1/a", vp.getResourceURI("repo1", "//a").toString());
+ assertEquals("cdo://repo1/a", vp.getResourceURI("repo1", "/a/").toString());
+ assertEquals("cdo://repo1/a", vp.getResourceURI("repo1", "a").toString());
+ assertEquals("cdo://repo1/a", vp.getResourceURI("repo1", "a/").toString());
+ assertEquals("cdo://repo1/a/b", vp.getResourceURI("repo1", "a/b").toString());
+ assertEquals("cdo://repo1/a/b", vp.getResourceURI("repo1", "a//b").toString());
+ }
+
+ public void testNet4jViewProvider() throws Exception
+ {
+ CDONet4jViewProvider vp = new CDONet4jViewProvider("xyz", 5000)
+ {
+ };
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", null, "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "/", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "//", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/a?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "/a", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/a?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "//a", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/a?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "/a/", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/a?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "a", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/a?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "a/", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/a/b?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "a/b", "MAIN/branch1", 4711L, true).toString());
+
+ assertEquals("cdo.net4j.xyz://localhost/repo1/a/b?branch=MAIN/branch1&time=4711",
+ vp.getResourceURI("xyz", "localhost", "repo1", "a//b", "MAIN/branch1", 4711L, true).toString());
+
+ // Test getViewURI(URI):
+
+ URI resourceURI = URI.createURI("cdo.net4j.xyz://localhost/repo1/a/b?branch=MAIN/branch1&time=4711");
+ assertEquals("cdo.net4j.xyz://localhost/repo1?branch=MAIN/branch1&time=4711", vp.getViewURI(resourceURI).toString());
+
+ }
+
public void testURIs() throws Exception
{
checkURI("cdo.net4j.tcp://eike:passw@127.0.0.1:2042/repo/folder/resource", true);
@@ -121,17 +186,16 @@ public class ViewProviderTest extends AbstractCDOTest
checkURI("cdo.net4j.tcp://127.0.0.1:2042/repo/resource", true);
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource", true);
checkURI("cdo.net4j.xyz://127.0.0.1/repo/resource", true);
-
+
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1", true);
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=12345678987", true);
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&transactional=true", true);
-
+
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=12345&transactional=false", false);
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&transactional=false", false);
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN/team1&time=HEAD", false);
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN", false);
checkURI("cdo.net4j.tcp://127.0.0.1/repo/resource?branch=MAIN&time=HEAD", false);
-
}
private static void checkURI(String uri, boolean valid)
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java
index e82e77f869..2facdf5bd2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_439337_Test.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.internal.net4j.protocol.LoadRevisionsRequest;
import org.eclipse.emf.cdo.internal.net4j.protocol.LockStateRequest;
import org.eclipse.emf.cdo.internal.net4j.protocol.QueryCancelRequest;
import org.eclipse.emf.cdo.internal.net4j.protocol.QueryRequest;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.Category;
@@ -90,7 +91,7 @@ public class Bugzilla_439337_Test extends AbstractCDOTest
private void testCDOLockState(CDOView view, boolean cdoLockStatePrefetchEnabled)
{
view.getResourceSet().eAdapters().add(new EContentAdapterQueringCDOLockState());
- ISignalProtocol<?> protocol = ((org.eclipse.emf.cdo.net4j.CDONet4jSession)view.getSession()).options().getNet4jProtocol();
+ ISignalProtocol<?> protocol = ((CDONet4jSession)view.getSession()).options().getNet4jProtocol();
SignalCounter signalCounter = new SignalCounter(protocol);
view.getResource(getResourcePath(RESOURCE_NAME + "?" + CDOResource.PREFETCH_PARAMETER + "=" + Boolean.TRUE));
diff --git a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
index 81da15ca18..b1370ba896 100644
--- a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo; singleton:=true
-Bundle-Version: 4.11.1.qualifier
+Bundle-Version: 4.12.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -10,28 +10,28 @@ Bundle-Activator: org.eclipse.emf.internal.cdo.bundle.Activator$Implementation
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
org.eclipse.emf.cdo.common;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo;version="4.11.1",
- org.eclipse.emf.cdo.eresource;version="4.11.1",
- org.eclipse.emf.cdo.eresource.impl;version="4.11.1",
- org.eclipse.emf.cdo.eresource.util;version="4.11.1",
- org.eclipse.emf.cdo.eresource.validation;version="4.11.1",
- org.eclipse.emf.cdo.etypes;version="4.11.1",
- org.eclipse.emf.cdo.etypes.impl;version="4.11.1",
- org.eclipse.emf.cdo.etypes.util;version="4.11.1",
- org.eclipse.emf.cdo.session;version="4.11.1",
- org.eclipse.emf.cdo.session.remote;version="4.11.1",
- org.eclipse.emf.cdo.transaction;version="4.11.1",
- org.eclipse.emf.cdo.util;version="4.11.1",
- org.eclipse.emf.cdo.view;version="4.11.1",
- org.eclipse.emf.internal.cdo;version="4.11.1",
- org.eclipse.emf.internal.cdo.analyzer;version="4.11.1";
+Export-Package: org.eclipse.emf.cdo;version="4.12.0",
+ org.eclipse.emf.cdo.eresource;version="4.12.0",
+ org.eclipse.emf.cdo.eresource.impl;version="4.12.0",
+ org.eclipse.emf.cdo.eresource.util;version="4.12.0",
+ org.eclipse.emf.cdo.eresource.validation;version="4.12.0",
+ org.eclipse.emf.cdo.etypes;version="4.12.0",
+ org.eclipse.emf.cdo.etypes.impl;version="4.12.0",
+ org.eclipse.emf.cdo.etypes.util;version="4.12.0",
+ org.eclipse.emf.cdo.session;version="4.12.0",
+ org.eclipse.emf.cdo.session.remote;version="4.12.0",
+ org.eclipse.emf.cdo.transaction;version="4.12.0",
+ org.eclipse.emf.cdo.util;version="4.12.0",
+ org.eclipse.emf.cdo.view;version="4.12.0",
+ org.eclipse.emf.internal.cdo;version="4.12.0",
+ org.eclipse.emf.internal.cdo.analyzer;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.bundle;version="4.11.1";x-friends:="org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.messages;version="4.11.1";x-internal:=true,
- org.eclipse.emf.internal.cdo.object;version="4.11.1";
+ org.eclipse.emf.internal.cdo.bundle;version="4.12.0";x-friends:="org.eclipse.emf.cdo.ui",
+ org.eclipse.emf.internal.cdo.messages;version="4.12.0";x-internal:=true,
+ org.eclipse.emf.internal.cdo.object;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
@@ -40,12 +40,12 @@ Export-Package: org.eclipse.emf.cdo;version="4.11.1",
org.eclipse.emf.cdo.explorer,
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.edit",
- org.eclipse.emf.internal.cdo.query;version="4.11.1";
+ org.eclipse.emf.internal.cdo.query;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.session;version="4.11.1";
+ org.eclipse.emf.internal.cdo.session;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
@@ -55,23 +55,23 @@ Export-Package: org.eclipse.emf.cdo;version="4.11.1",
org.eclipse.emf.cdo.security.ui,
org.eclipse.emf.cdo.explorer,
org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.internal.cdo.session.remote;version="4.11.1";
+ org.eclipse.emf.internal.cdo.session.remote;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.transaction;version="4.11.1";
+ org.eclipse.emf.internal.cdo.transaction;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.internal.cdo.util;version="4.11.1";
+ org.eclipse.emf.internal.cdo.util;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.view;version="4.11.1";
+ org.eclipse.emf.internal.cdo.view;version="4.12.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
@@ -79,6 +79,6 @@ Export-Package: org.eclipse.emf.cdo;version="4.11.1",
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.explorer,
org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.spi.cdo;version="4.11.1"
+ org.eclipse.emf.spi.cdo;version="4.12.0"
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.eclipse.emf.cdo
diff --git a/plugins/org.eclipse.emf.cdo/pom.xml b/plugins/org.eclipse.emf.cdo/pom.xml
index 584435c934..70057a0690 100644
--- a/plugins/org.eclipse.emf.cdo/pom.xml
+++ b/plugins/org.eclipse.emf.cdo/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo</artifactId>
- <version>4.11.1-SNAPSHOT</version>
+ <version>4.12.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index 062c62acd5..c755ac2b53 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -1230,7 +1230,7 @@ public class CDOResourceImpl extends CDOResourceLeafImpl implements InternalCDOR
if (query != null && query.length() != 0)
{
Map<String, String> parameters = CDOURIUtil.getParameters(query);
- String value = parameters.get(CDOResource.PREFETCH_PARAMETER);
+ String value = parameters.get(PREFETCH_PARAMETER);
if (value != null)
{
boolean prefetch = Boolean.parseBoolean(value);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
index 1977f25cbc..1a3258356a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
@@ -30,7 +30,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -86,32 +86,6 @@ public final class CDOURIUtil
{
}
- /**
- * @deprecated
- */
- @Deprecated
- public static void validateURI(URI uri) throws InvalidURIException
- {
- // if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme()))
- // {
- // throw new InvalidURIException(uri);
- // }
- //
- // if (!uri.isHierarchical())
- // {
- // throw new InvalidURIException(uri);
- // }
- }
-
- /**
- * @deprecated
- */
- @Deprecated
- public static String extractRepositoryUUID(URI uri)
- {
- return PluginContainerViewProvider.getRepositoryUUID(uri);
- }
-
public static String[] extractResourceFolderAndName(URI uri) throws InvalidURIException
{
String path = extractResourcePath(uri);
@@ -154,59 +128,12 @@ public final class CDOURIUtil
return sanitizePath(uri.path());
}
- /**
- * <p>
- * cdo://repositoryUUID/path
- * <p>
- * The path is added at the end of "cdo://repositoryUUID". If path doesn't start with '/', it will be added
- * automatically. <br>
- * e.g.: /resA or resA will give the same result &rarr; cdo://repositoryUUID/resA <br>
- * authority = repositoryUUID <br>
- * path = /resA
- *
- * @deprecated This method is subject to removal in a future release.
- */
- @Deprecated
- public static URI createResourceURI(String repositoryUUID, String path)
- {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(PROTOCOL_NAME);
- stringBuilder.append(":"); //$NON-NLS-1$
-
- if (repositoryUUID != null)
- {
- stringBuilder.append("//"); //$NON-NLS-1$
- stringBuilder.append(repositoryUUID);
- }
-
- if (!SEGMENT_SEPARATOR.equals(path))
- {
- if (path.charAt(0) != SEGMENT_SEPARATOR_CHAR)
- {
- stringBuilder.append(SEGMENT_SEPARATOR_CHAR);
- }
-
- stringBuilder.append(path);
- }
-
- return URI.createURI(stringBuilder.toString());
- }
-
public static URI createResourceURI(CDOView view, String path)
{
return view == null ? null : view.createResourceURI(path);
}
/**
- * @deprecated This method is subject to removal in a future release.
- */
- @Deprecated
- public static URI createResourceURI(CDOSession session, String path)
- {
- return createResourceURI(session == null ? null : session.getRepositoryInfo().getUUID(), path);
- }
-
- /**
* Converting temporary CDOID to External CDOID <br>
* e.g.: <br>
* baseURI = cdo://2a57dfcf-8f97-4d39-8e17-9d99ae5c4b3c/resB#5/2<br>
@@ -222,21 +149,28 @@ public final class CDOURIUtil
return CDOIDUtil.createExternal(baseURI.toString());
}
- public static List<String> analyzePath(URI uri)
- {
- String path = extractResourcePath(uri);
- return analyzeSanitizedPath(path);
- }
-
- public static List<String> analyzePath(String path)
+ /**
+ * @since 4.11
+ */
+ public static String sanitizePath(String path)
{
- return analyzeSanitizedPath(sanitizePath(path));
+ if (path == null || path.length() == 0)
+ {
+ return SEGMENT_SEPARATOR;
+ }
+
+ if (path.charAt(0) != SEGMENT_SEPARATOR_CHAR)
+ {
+ return SEGMENT_SEPARATOR + path;
+ }
+
+ return path;
}
private static List<String> analyzeSanitizedPath(String path)
{
List<String> segments = new ArrayList<>();
- StringTokenizer tokenizer = new StringTokenizer(path, CDOURIUtil.SEGMENT_SEPARATOR);
+ StringTokenizer tokenizer = new StringTokenizer(path, SEGMENT_SEPARATOR);
while (tokenizer.hasMoreTokens())
{
String name = tokenizer.nextToken();
@@ -245,26 +179,19 @@ public final class CDOURIUtil
segments.add(name);
}
}
-
+
return segments;
}
- /**
- * @since 4.11
- */
- public static String sanitizePath(String path)
+ public static List<String> analyzePath(URI uri)
{
- if (path == null || path.length() == 0)
- {
- return SEGMENT_SEPARATOR;
- }
-
- if (path.charAt(0) != SEGMENT_SEPARATOR_CHAR)
- {
- return SEGMENT_SEPARATOR + path;
- }
+ String path = extractResourcePath(uri);
+ return analyzeSanitizedPath(path);
+ }
- return path;
+ public static List<String> analyzePath(String path)
+ {
+ return analyzeSanitizedPath(sanitizePath(path));
}
/**
@@ -272,7 +199,8 @@ public final class CDOURIUtil
*/
public static Map<String, String> getParameters(String query)
{
- Map<String, String> result = new HashMap<>();
+ Map<String, String> parameters = new LinkedHashMap<>();
+
StringTokenizer tokenizer = new StringTokenizer(query, "&"); //$NON-NLS-1$
while (tokenizer.hasMoreTokens())
{
@@ -283,17 +211,169 @@ public final class CDOURIUtil
if (pos == -1)
{
String key = parameter.trim();
- result.put(key, ""); //$NON-NLS-1$
+ parameters.put(key, ""); //$NON-NLS-1$
}
else
{
String key = parameter.substring(0, pos).trim();
String value = parameter.substring(pos + 1);
- result.put(key, value);
+ parameters.put(key, value);
}
}
}
- return result;
+ return parameters;
+ }
+
+ /**
+ * @since 4.12
+ */
+ public static String formatQuery(Map<String, String> parameters)
+ {
+ StringBuilder query = new StringBuilder();
+
+ for (Map.Entry<String, String> entry : parameters.entrySet())
+ {
+ appendQueryParameter(query, entry.getKey(), entry.getValue());
+ }
+
+ if (query.length() == 0)
+ {
+ return null;
+ }
+
+ return query.toString();
+ }
+
+ /**
+ * @since 4.12
+ */
+ public static void appendQueryParameter(StringBuilder query, String parameter, String value)
+ {
+ if (query.length() != 0)
+ {
+ query.append("&");
+ }
+
+ query.append(parameter);
+ query.append("=");
+ query.append(value);
+ }
+
+ /**
+ * @since 4.12
+ */
+ public static URI appendResourcePath(URI uri, String path)
+ {
+ boolean pathIsEmpty = true;
+ if (path != null)
+ {
+ StringTokenizer tokenizer = new StringTokenizer(path, SEGMENT_SEPARATOR);
+ while (tokenizer.hasMoreTokens())
+ {
+ String segment = tokenizer.nextToken();
+ uri = uri.appendSegment(segment);
+ pathIsEmpty = false;
+ }
+ }
+
+ if (pathIsEmpty)
+ {
+ uri = uri.appendSegment("");
+ }
+
+ return uri;
+ }
+
+ /**
+ * @since 4.12
+ */
+ public static URI trimResourceInfos(URI uri)
+ {
+ String query = uri.query();
+ if (query != null && query.length() != 0)
+ {
+ Map<String, String> parameters = getParameters(query);
+ if (parameters.containsKey(CDOResource.PREFETCH_PARAMETER))
+ {
+ parameters.remove(CDOResource.PREFETCH_PARAMETER);
+ query = formatQuery(parameters);
+ }
+ }
+
+ return URI.createHierarchicalURI(uri.scheme(), uri.authority(), uri.device(), query, uri.fragment());
+ }
+
+ /**
+ * @deprecated
+ */
+ @Deprecated
+ public static void validateURI(URI uri) throws InvalidURIException
+ {
+ // if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme()))
+ // {
+ // throw new InvalidURIException(uri);
+ // }
+ //
+ // if (!uri.isHierarchical())
+ // {
+ // throw new InvalidURIException(uri);
+ // }
+ }
+
+ /**
+ * @deprecated
+ */
+ @Deprecated
+ public static String extractRepositoryUUID(URI uri)
+ {
+ return PluginContainerViewProvider.getRepositoryUUID(uri);
+ }
+
+ /**
+ * <p>
+ * cdo://repositoryUUID/path
+ * <p>
+ * The path is added at the end of "cdo://repositoryUUID". If path doesn't start with '/', it will be added
+ * automatically. <br>
+ * e.g.: /resA or resA will give the same result &rarr; cdo://repositoryUUID/resA <br>
+ * authority = repositoryUUID <br>
+ * path = /resA
+ *
+ * @deprecated This method is subject to removal in a future release.
+ */
+ @Deprecated
+ public static URI createResourceURI(String repositoryUUID, String path)
+ {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append(PROTOCOL_NAME);
+ stringBuilder.append(":"); //$NON-NLS-1$
+
+ if (repositoryUUID != null)
+ {
+ stringBuilder.append("//"); //$NON-NLS-1$
+ stringBuilder.append(repositoryUUID);
+ }
+
+ if (!SEGMENT_SEPARATOR.equals(path))
+ {
+ if (path.charAt(0) != SEGMENT_SEPARATOR_CHAR)
+ {
+ stringBuilder.append(SEGMENT_SEPARATOR_CHAR);
+ }
+
+ stringBuilder.append(path);
+ }
+
+ return URI.createURI(stringBuilder.toString());
+ }
+
+ /**
+ * @deprecated This method is subject to removal in a future release.
+ */
+ @Deprecated
+ public static URI createResourceURI(CDOSession session, String path)
+ {
+ return createResourceURI(session == null ? null : session.getRepositoryInfo().getUUID(), path);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/AbstractCDOViewProvider.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/AbstractCDOViewProvider.java
index ad3196a8ef..835958640c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/AbstractCDOViewProvider.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/AbstractCDOViewProvider.java
@@ -11,8 +11,10 @@
*/
package org.eclipse.emf.cdo.view;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.view.CDOViewProvider.CDOViewProvider2;
+import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.emf.common.util.URI;
@@ -92,56 +94,44 @@ public abstract class AbstractCDOViewProvider implements CDOViewProvider2
}
/**
- * Must be overwritten for non-canonical URI formats!
+ * Must be overridden for non-canonical URI formats!
*
* @since 4.0
*/
@Override
public URI getResourceURI(CDOView view, String path)
{
- return null;
+ throw new UnsupportedOperationException("Must be overridden in subclasses!");
}
/**
* @since 4.4
*/
@Override
- public final URI getViewURI(CDOView view)
+ public URI getViewURI(CDOView view)
{
- URI resourceURI = getResourceURI(view, null);
- if (resourceURI != null)
+ URI uri = getResourceURI(view, null);
+ if (uri != null)
{
- if (resourceURI.isHierarchical())
- {
- resourceURI = URI.createHierarchicalURI(resourceURI.scheme(), resourceURI.authority(), null, null, null);
- }
- else
- {
- String string = resourceURI.toString();
- if (string.endsWith("/"))
- {
- string = string.substring(0, string.length() - 1);
- resourceURI = URI.createURI(string);
- }
- }
+ return getViewURI(uri);
}
- return resourceURI;
+ return null;
}
/**
- * Should be overwritten for non-canonical URI formats!
+ * Should be overridden for non-canonical URI formats!
*
* @since 4.4
*/
@Override
public URI getViewURI(URI uri)
{
- return URI.createHierarchicalURI(uri.scheme(), uri.authority(), uri.device(), null, null);
+ return CDOURIUtil.trimResourceInfos(uri);
}
/**
- * Should be overwritten for non-canonical URI formats!
+ * Should be overridden for non-canonical URI formats!
*
* @since 4.4
*/
@@ -154,6 +144,6 @@ public abstract class AbstractCDOViewProvider implements CDOViewProvider2
@Override
public String toString()
{
- return "CDOViewProviderDescriptor[" + getPriority() + " --> " + getRegex() + "]";
+ return "CDOViewProvider[" + getRegex() + " --> " + ReflectUtil.getSimpleClassName(this) + ", " + getPriority() + "]";
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewProvider.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewProvider.java
index 6b6303ce01..5aa2e2e302 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewProvider.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewProvider.java
@@ -26,8 +26,8 @@ public interface CDOViewProvider
public static final int DEFAULT_PRIORITY = 500;
/**
- * Returns the priority of this provider. Usually used to choose between several <code>CDOViewProvider</code> that
- * match the same repository URI.
+ * Returns the priority of this provider. Usually used to choose between several <code>CDOViewProviders</code> that
+ * match the same repository URI. A higher priority value is preferred in that decision.
*/
public int getPriority();
@@ -42,10 +42,7 @@ public interface CDOViewProvider
public boolean matchesRegex(URI uri);
/**
- * Receives a URI and returns an opened <code>CDOView</code> against the repository. The implementer is responsible to
- * do the UUID to physical host map in case necessary.
- *
- * @return a wired-up and opened <code>CDOView</code>
+ * Receives a URI and returns an opened <code>CDOView</code> against the repository.
*/
public CDOView getView(URI uri, ResourceSet resourceSet);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewProviderRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewProviderRegistryImpl.java
index da15659940..1ca3beec92 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewProviderRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewProviderRegistryImpl.java
@@ -58,7 +58,19 @@ public class CDOViewProviderRegistryImpl extends Container<CDOViewProvider> impl
private static final String EXT_POINT = "viewProviders"; //$NON-NLS-1$
- private List<CDOViewProvider> viewProviders = new ArrayList<>();
+ /**
+ * Sort highest priority first.
+ */
+ private static final Comparator<CDOViewProvider> COMPARATOR = new Comparator<CDOViewProvider>()
+ {
+ @Override
+ public int compare(CDOViewProvider vp1, CDOViewProvider vp2)
+ {
+ return -Integer.compare(vp1.getPriority(), vp2.getPriority());
+ }
+ };
+
+ private final List<CDOViewProvider> viewProviders = new ArrayList<>();
public CDOViewProviderRegistryImpl()
{
@@ -73,26 +85,15 @@ public class CDOViewProviderRegistryImpl extends Container<CDOViewProvider> impl
return null;
}
- CDOViewSet viewSet = CDOUtil.getViewSet(resourceSet);
- // if (viewSet != null)
- // {
- // try
- // {
- // String uuid = CDOURIUtil.extractRepositoryUUID(uri);
- // CDOView view = viewSet.resolveView(uuid);
- // if (view != null)
- // {
- // return view;
- // }
- // }
- // catch (Exception ignore)
- // {
- // // Do nothing
- // }
- // }
+ CDOViewSet viewSet = null;
for (CDOViewProvider viewProvider : getViewProviders(uri))
{
+ if (viewSet == null)
+ {
+ viewSet = CDOUtil.getViewSet(resourceSet);
+ }
+
InternalCDOView view = provideView(uri, resourceSet, viewSet, viewProvider);
if (view != null)
{
@@ -197,14 +198,7 @@ public class CDOViewProviderRegistryImpl extends Container<CDOViewProvider> impl
}
// Sort highest priority first
- Collections.sort(result, new Comparator<CDOViewProvider>()
- {
- @Override
- public int compare(CDOViewProvider o1, CDOViewProvider o2)
- {
- return -Integer.valueOf(o1.getPriority()).compareTo(o2.getPriority());
- }
- });
+ Collections.sort(result, COMPARATOR);
return result.toArray(new CDOViewProvider[result.size()]);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java
index 7fd3710455..3cca9865d5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java
@@ -445,7 +445,7 @@ public class CDOViewSetImpl extends NotifierImpl implements InternalCDOViewSet
dirtyResources.addAll(resources);
}
}
-
+
return dirtyResources;
}
@@ -467,7 +467,6 @@ public class CDOViewSetImpl extends NotifierImpl implements InternalCDOViewSet
}
}
- String uuid = view.getSession().getRepositoryInfo().getUUID();
- return URI.createURI(CDOURIUtil.PROTOCOL_NAME + "://" + uuid);
+ return PluginContainerViewProvider.INSTANCE.getViewURI(view);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java
index f23f0a9c48..e8785451a9 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java
@@ -13,14 +13,11 @@ package org.eclipse.emf.internal.cdo.view;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.util.InvalidURIException;
import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.emf.cdo.view.CDOViewProvider;
import org.eclipse.emf.cdo.view.ManagedContainerViewProvider;
import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
-import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
@@ -28,13 +25,15 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
/**
- * Provides <code>CDOView</code> from <code>CDOSession</code> registered in IPluginContainer
+ * Provides views from sessions registered in a {@link #getContainer() managed container}.
+ * <p>
+ * The URI format of this view provider is <code>cdo://{repository-uuid}[/{resource-path}]</code>.
*
* @author Victor Roldan Betancort
*/
public class PluginContainerViewProvider extends ManagedContainerViewProvider
{
- public static final CDOViewProvider INSTANCE = new PluginContainerViewProvider();
+ public static final PluginContainerViewProvider INSTANCE = new PluginContainerViewProvider();
private static final String REGEX = "cdo:.*"; //$NON-NLS-1$
@@ -55,10 +54,16 @@ public class PluginContainerViewProvider extends ManagedContainerViewProvider
}
String repoUUID = getRepositoryUUID(uri);
+ if (repoUUID == null)
+ {
+ return null;
+ }
+
for (Object element : container.getElements(CDOSessionFactory.PRODUCT_GROUP))
{
CDOSession session = (CDOSession)element;
String uuid = session.getRepositoryInfo().getUUID();
+
if (repoUUID.equals(uuid))
{
CDOView view = openView(session, resourceSet);
@@ -75,23 +80,14 @@ public class PluginContainerViewProvider extends ManagedContainerViewProvider
@Override
public URI getResourceURI(CDOView view, String path)
{
- if (StringUtil.isEmpty(path))
- {
- path = "";
- }
- else if (!path.startsWith("/"))
- {
- path = "/" + path;
- }
-
- String authority = view.getSession().getRepositoryInfo().getUUID();
- return URI.createURI(CDOURIUtil.PROTOCOL_NAME + "://" + authority + path);
+ String repositoryUUID = getRepositoryUUID(view);
+ return getResourceURI(repositoryUUID, path);
}
- @Override
- protected IManagedContainer getContainer()
+ public URI getResourceURI(String repositoryUUID, String path)
{
- return IPluginContainer.INSTANCE;
+ URI uri = URI.createHierarchicalURI(CDOURIUtil.PROTOCOL_NAME, repositoryUUID, null, null, null);
+ return CDOURIUtil.appendResourcePath(uri, path);
}
protected CDOView openView(CDOSession session, ResourceSet resourceSet)
@@ -99,20 +95,13 @@ public class PluginContainerViewProvider extends ManagedContainerViewProvider
return session.openTransaction(resourceSet);
}
- public static String getRepositoryUUID(URI uri)
+ public static String getRepositoryUUID(CDOView view)
{
- try
- {
- if (!uri.hasAuthority())
- {
- throw new InvalidURIException(uri);
- }
+ return view.getSession().getRepositoryInfo().getUUID();
+ }
- return uri.authority();
- }
- catch (InvalidURIException ex)
- {
- return null;
- }
+ public static String getRepositoryUUID(URI uri)
+ {
+ return uri.authority();
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
index 50ee4d59b8..20e0416a52 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java
@@ -354,7 +354,8 @@ public final class ReflectUtil
return null;
}
- return getSimpleName(object.getClass());
+ String name = object.getClass().getName();
+ return getSimpleClassName(name);
}
public static String getLabel(Object object)

Back to the top