summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-28 06:31:00 (EDT)
committerEike Stepper2008-05-28 06:31:00 (EDT)
commit72e71707ac8a5783556b0d2fbd8289915795ca33 (patch)
treedc158e0b9d01d104f5a4251ba7fba9d217834996
parent080d15ce9ee68bbbb0d5f4d553745e94dce1e714 (diff)
downloadcdo-72e71707ac8a5783556b0d2fbd8289915795ca33.zip
cdo-72e71707ac8a5783556b0d2fbd8289915795ca33.tar.gz
cdo-72e71707ac8a5783556b0d2fbd8289915795ca33.tar.bz2
[232648] Provide an HTTPConnector
https://bugs.eclipse.org/bugs/show_bug.cgi?id=232648
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java67
1 files changed, 46 insertions, 21 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
index 93b7f6f..41da4be 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
@@ -16,12 +16,14 @@ import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl;
import org.eclipse.net4j.internal.util.factory.Factory;
import org.eclipse.net4j.signal.failover.IFailOverStrategy;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.emf.common.util.URI;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
/**
* @author Eike Stepper
@@ -32,6 +34,8 @@ public class CDOSessionFactory extends Factory
public static final String TYPE = "cdo";
+ private static final String TRUE = Boolean.TRUE.toString();
+
public CDOSessionFactory()
{
super(PRODUCT_GROUP, TYPE);
@@ -39,25 +43,46 @@ public class CDOSessionFactory extends Factory
public CDOSession create(String description)
{
- return createSession(getRepositoryName(description), isDisableLegacyObjects(description),
- isAutomaticPackageRegistry(description), null);
- }
+ try
+ {
+ URI uri = new URI(description);
+ String query = uri.getQuery();
+ if (StringUtil.isEmpty(query))
+ {
+ throw new IllegalArgumentException("Query is empty: " + description);
+ }
- public static String getRepositoryName(String description)
- {
- URI uri = URI.createURI(description);
- IPath path = new Path(uri.path());
- return path.segment(0);
- }
+ Map<String, String> result = new HashMap<String, String>();
+ StringTokenizer tokenizer = new StringTokenizer(query, "&");
+ while (tokenizer.hasMoreTokens())
+ {
+ String parameter = tokenizer.nextToken();
+ if (!StringUtil.isEmpty(parameter))
+ {
+ int pos = parameter.indexOf('=');
+ if (pos == -1)
+ {
+ String key = parameter.trim();
+ result.put(key, "");
+ }
+ else
+ {
+ String key = parameter.substring(0, pos).trim();
+ String value = parameter.substring(pos);
+ result.put(key, value);
+ }
+ }
+ }
- public boolean isDisableLegacyObjects(String description)
- {
- return description.contains("disableLegacyObjects=true");
- }
-
- public boolean isAutomaticPackageRegistry(String description)
- {
- return description.contains("automaticPackageRegistry=true");
+ String repositoryName = result.get("repositoryName");
+ boolean disableLegacyObjects = TRUE.equals(result.get("disableLegacyObjects"));
+ boolean automaticPackageRegistry = TRUE.equals(result.get("automaticPackageRegistry"));
+ return createSession(repositoryName, disableLegacyObjects, automaticPackageRegistry, null);
+ }
+ catch (URISyntaxException ex)
+ {
+ throw new IllegalArgumentException(ex);
+ }
}
public static CDOSession get(IManagedContainer container, String description)