Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-04-27 16:53:25 +0000
committerEike Stepper2015-04-28 06:49:03 +0000
commit78e1c324c06816ca50cb2947c7e582103757bd4d (patch)
treed9da1edc0cdd63d0e9b486a113b53f800dd76b25 /plugins/org.eclipse.emf.cdo.explorer
parentd2c5b0ee9d0634fb6c79d99e6952ee0d7c752dd7 (diff)
downloadcdo-78e1c324c06816ca50cb2947c7e582103757bd4d.tar.gz
cdo-78e1c324c06816ca50cb2947c7e582103757bd4d.tar.xz
cdo-78e1c324c06816ca50cb2947c7e582103757bd4d.zip
[458349] Consolidate UI
Change-Id: Iea0e1cf37bfc35a67f589c265fcb2e9d92e67581 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349 Signed-off-by: Eike Stepper <stepper@esc-net.de>
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.explorer')
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/plugin.xml14
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java28
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryElement.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutViewProvider.java219
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryImpl.java131
8 files changed, 427 insertions, 16 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer/plugin.xml b/plugins/org.eclipse.emf.cdo.explorer/plugin.xml
index 5f00f5691a..d0876257ef 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.explorer/plugin.xml
@@ -42,4 +42,18 @@
class="org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutProperties$Tester"/>
</extension>
+ <extension point="org.eclipse.emf.cdo.viewProviders">
+ <viewProvider
+ class="org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutViewProvider"
+ priority="500"
+ regex="cdo\.checkout://.*"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.emf.ecore.protocol_parser">
+ <parser
+ class="org.eclipse.emf.cdo.eresource.impl.CDOResourceFactoryImpl"
+ protocolName="cdo.checkout"/>
+ </extension>
+
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java
index 0dd267d342..2768da2f61 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/CDOExplorerUtil.java
@@ -15,10 +15,14 @@ import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckoutManager;
import org.eclipse.emf.cdo.explorer.repositories.CDORepositoryManager;
import org.eclipse.emf.cdo.internal.explorer.bundle.OM;
+import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutImpl;
+import org.eclipse.emf.cdo.internal.explorer.checkouts.CDOCheckoutViewProvider;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.util.AdapterUtil;
import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -42,6 +46,18 @@ public final class CDOExplorerUtil
public static CDOCheckout getCheckout(Object object)
{
+ if (object instanceof CDOView)
+ {
+ CDOView view = (CDOView)object;
+ return (CDOCheckout)view.properties().get(CDOCheckoutImpl.CHECKOUT_KEY);
+ }
+
+ if (object instanceof URI)
+ {
+ URI uri = (URI)object;
+ return CDOCheckoutViewProvider.getCheckout(uri);
+ }
+
return walkUp(object, null);
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java
index 8ca4983bdd..39f77945b2 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/checkouts/CDOCheckout.java
@@ -24,6 +24,7 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.util.AdapterUtil;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -105,11 +106,13 @@ public interface CDOCheckout extends CDOExplorerElement, CDOTimeProvider, StateP
public CDOTransaction openTransaction(ResourceSet resourceSet);
+ public URI createResourceURI(String path);
+
public boolean isDirty();
- public String getEditorID(CDOID objectID);
+ public String getEditorOpenerID(CDOID objectID);
- public void setEditorID(CDOID objectID, String editorID);
+ public void setEditorOpenerID(CDOID objectID, String editorOpenerID);
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java
index cf5a6cb53e..4582e6bc3b 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepository.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.explorer.CDOExplorerElement;
import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
+import org.eclipse.emf.cdo.session.CDORepositoryInfo;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionProvider;
import org.eclipse.emf.cdo.transaction.CDOTransactionOpener;
@@ -102,6 +103,21 @@ CDOSessionProvider, CDOViewOpener, CDOTransactionOpener
{
return supportingBranches;
}
+
+ public static VersioningMode from(CDORepositoryInfo repositoryInfo)
+ {
+ if (repositoryInfo.isSupportingBranches())
+ {
+ return VersioningMode.Branching;
+ }
+
+ if (repositoryInfo.isSupportingAudits())
+ {
+ return VersioningMode.Auditing;
+ }
+
+ return VersioningMode.Normal;
+ }
}
/**
@@ -118,10 +134,20 @@ CDOSessionProvider, CDOViewOpener, CDOTransactionOpener
this.location = location;
}
- public final IDGenerationLocation getLocation()
+ public IDGenerationLocation getLocation()
{
return location;
}
+
+ public static IDGeneration from(CDORepositoryInfo repositoryInfo)
+ {
+ if (repositoryInfo.getIDGenerationLocation() == IDGenerationLocation.CLIENT)
+ {
+ return IDGeneration.UUID;
+ }
+
+ return IDGeneration.Counter;
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryElement.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryElement.java
index 8855082ccf..a1ad6d4a7f 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryElement.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/explorer/repositories/CDORepositoryElement.java
@@ -25,7 +25,5 @@ public interface CDORepositoryElement extends CDOTimeProvider
public int getBranchID();
- public long getTimeStamp();
-
public CDOID getObjectID();
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
index 9c99aa6f7d..e282eeb6e4 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutImpl.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
import org.eclipse.emf.cdo.view.CDOViewTargetChangedEvent;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.event.IEvent;
@@ -40,6 +41,7 @@ import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent.Kind;
import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -75,7 +77,7 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
public static final String EDITOR_PROPERTIES = "editor.properties";
- private static final String CHECKOUT_KEY = CDOCheckout.class.getName();
+ public static final String CHECKOUT_KEY = CDOCheckout.class.getName();
private static final CDOBranchPoint[] NO_BRANCH_POINTS = {};
@@ -624,11 +626,29 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
}
});
+ URI from = URI.createURI("cdo://" + view.getSession().getRepositoryInfo().getName() + "/");
+ URI to = URI.createURI("cdo.checkout://" + getID() + "/" + repository.getID() + "/");
+ view.getResourceSet().getURIConverter().getURIMap().put(from, to);
+
addView(view);
return view;
}
- public String getEditorID(CDOID objectID)
+ public URI createResourceURI(String path)
+ {
+ if (StringUtil.isEmpty(path))
+ {
+ path = "";
+ }
+ else if (!path.startsWith("/"))
+ {
+ path = "/" + path;
+ }
+
+ return URI.createURI(CDOCheckoutViewProvider.SCHEME + "://" + getID() + "/" + getRepository().getID() + path);
+ }
+
+ public String getEditorOpenerID(CDOID objectID)
{
synchronized (editorIDs)
{
@@ -649,7 +669,7 @@ public abstract class CDOCheckoutImpl extends AbstractElement implements CDOChec
}
}
- public void setEditorID(CDOID objectID, String editorID)
+ public void setEditorOpenerID(CDOID objectID, String editorID)
{
synchronized (editorIDs)
{
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
new file mode 100644
index 0000000000..54371a1bf3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/checkouts/CDOCheckoutViewProvider.java
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2011-2013 Eike Stepper (Berlin, Germany) 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
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.explorer.checkouts;
+
+import org.eclipse.emf.cdo.explorer.CDOExplorerUtil;
+import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
+import org.eclipse.emf.cdo.view.AbstractCDOViewProvider;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.ref.ReferenceMonitor;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.eclipse.core.runtime.Path;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOCheckoutViewProvider extends AbstractCDOViewProvider
+{
+ public static final String SCHEME = "cdo.checkout";
+
+ // TODO Move to activator and deactivate via stop().
+ private static final ReferenceMonitor<ResourceSet> MONITOR = new ReferenceMonitor<ResourceSet>()
+ {
+ @Override
+ protected void work(ResourceSet resourceSet)
+ {
+ disposeResourceSet(resourceSet);
+ }
+ };
+
+ public CDOCheckoutViewProvider()
+ {
+ this(DEFAULT_PRIORITY);
+ }
+
+ public CDOCheckoutViewProvider(int priority)
+ {
+ super("cdo\\.checkout://.*", priority);
+ }
+
+ public CDOView getView(URI uri, ResourceSet resourceSet)
+ {
+ CDOCheckout checkout = getCheckout(uri);
+ if (checkout != null)
+ {
+ CheckoutViewProviderAdapter adapter = CheckoutViewProviderAdapter.get(resourceSet);
+ if (adapter == null)
+ {
+ adapter = CheckoutViewProviderAdapter.create(resourceSet);
+
+ MONITOR.activate();
+ MONITOR.monitor(resourceSet);
+ }
+
+ return adapter.getView(checkout);
+ }
+
+ return null;
+ }
+
+ @Override
+ public URI getResourceURI(CDOView view, String path)
+ {
+ CDOCheckout checkout = CDOExplorerUtil.getCheckout(view);
+ if (checkout != null)
+ {
+ return checkout.createResourceURI(path);
+ }
+
+ return super.getResourceURI(view, path);
+ }
+
+ @Override
+ public String getPath(URI uri)
+ {
+ return new Path(uri.path()).makeAbsolute().removeFirstSegments(1).toString();
+ }
+
+ public static void disposeResourceSet(ResourceSet resourceSet)
+ {
+ CheckoutViewProviderAdapter adapter = CheckoutViewProviderAdapter.get(resourceSet);
+ if (adapter != null)
+ {
+ adapter.dispose();
+ }
+ }
+
+ public static CDOCheckout getCheckout(URI uri)
+ {
+ if (SCHEME.equals(uri.scheme()))
+ {
+ String checkoutID = uri.authority();
+ return CDOExplorerUtil.getCheckoutManager().getCheckout(checkoutID);
+ }
+
+ return null;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class CheckoutViewProviderAdapter extends AdapterImpl
+ {
+ private final Map<CDOCheckout, CDOView> views = new HashMap<CDOCheckout, CDOView>();
+
+ private CheckoutViewProviderAdapter()
+ {
+ }
+
+ public CDOView getView(final CDOCheckout checkout)
+ {
+ synchronized (views)
+ {
+ CDOView view = views.get(checkout);
+ if (view == null)
+ {
+ ResourceSet resourceSet = getTarget();
+ view = checkout.openView(resourceSet);
+
+ if (view != null)
+ {
+ views.put(checkout, view);
+
+ view.addListener(new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ synchronized (views)
+ {
+ views.remove(checkout);
+ }
+ }
+ });
+ }
+ }
+
+ return view;
+ }
+ }
+
+ @Override
+ public boolean isAdapterForType(Object type)
+ {
+ return type == CheckoutViewProviderAdapter.class;
+ }
+
+ @Override
+ public ResourceSet getTarget()
+ {
+ return (ResourceSet)super.getTarget();
+ }
+
+ public void dispose()
+ {
+ CDOView[] array;
+ synchronized (views)
+ {
+ array = views.values().toArray(new CDOView[views.size()]);
+ views.clear();
+ }
+
+ for (CDOView view : array)
+ {
+ view.close();
+ }
+
+ ResourceSet resourceSet = getTarget();
+ resourceSet.eAdapters().remove(this);
+ }
+
+ public static CheckoutViewProviderAdapter get(ResourceSet resourceSet)
+ {
+ EList<Adapter> adapters = resourceSet.eAdapters();
+
+ CheckoutViewProviderAdapter adapter = (CheckoutViewProviderAdapter)EcoreUtil.getAdapter(adapters,
+ CheckoutViewProviderAdapter.class);
+ if (adapter != null && adapter.getTarget() != resourceSet)
+ {
+ adapters.remove(adapter);
+ adapter = null;
+ }
+
+ return adapter;
+ }
+
+ public static CheckoutViewProviderAdapter create(ResourceSet resourceSet)
+ {
+ CheckoutViewProviderAdapter adapter = get(resourceSet);
+ if (adapter == null)
+ {
+ adapter = new CheckoutViewProviderAdapter();
+ resourceSet.eAdapters().add(adapter);
+ }
+
+ return adapter;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryImpl.java b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryImpl.java
index 1bfa484e57..e30e5b6871 100644
--- a/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryImpl.java
+++ b/plugins/org.eclipse.emf.cdo.explorer/src/org/eclipse/emf/cdo/internal/explorer/repositories/CDORepositoryImpl.java
@@ -18,6 +18,10 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchCreationContext;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.explorer.CDOExplorerManager.ElementsChangedEvent;
import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository;
@@ -29,10 +33,12 @@ import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.util.UUIDGenerator;
import org.eclipse.net4j.util.container.ContainerEvent;
import org.eclipse.net4j.util.container.IContainerEvent;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -43,13 +49,18 @@ import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import java.io.File;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* @author Eike Stepper
@@ -110,9 +121,9 @@ public abstract class CDORepositoryImpl extends AbstractElement implements CDORe
private String name;
- private CDORepository.VersioningMode versioningMode;
+ private VersioningMode versioningMode;
- private CDORepository.IDGeneration idGeneration;
+ private IDGeneration idGeneration;
private String realm;
@@ -148,12 +159,12 @@ public abstract class CDORepositoryImpl extends AbstractElement implements CDORe
return name;
}
- public final CDORepository.VersioningMode getVersioningMode()
+ public final VersioningMode getVersioningMode()
{
return versioningMode;
}
- public final CDORepository.IDGeneration getIDGeneration()
+ public final IDGeneration getIDGeneration()
{
return idGeneration;
}
@@ -505,8 +516,13 @@ public abstract class CDORepositoryImpl extends AbstractElement implements CDORe
{
super.init(folder, type, properties);
name = properties.getProperty(PROP_NAME);
- versioningMode = VersioningMode.valueOf(properties.getProperty(PROP_VERSIONING_MODE));
- idGeneration = IDGeneration.valueOf(properties.getProperty(PROP_ID_GENERATION));
+
+ String versioningModeProperty = properties.getProperty(PROP_VERSIONING_MODE);
+ versioningMode = versioningModeProperty == null ? null : VersioningMode.valueOf(versioningModeProperty);
+
+ String idGenerationProperty = properties.getProperty(PROP_ID_GENERATION);
+ idGeneration = idGenerationProperty == null ? null : IDGeneration.valueOf(idGenerationProperty);
+
realm = properties.getProperty(PROP_REALM);
}
@@ -515,8 +531,16 @@ public abstract class CDORepositoryImpl extends AbstractElement implements CDORe
{
super.collectProperties(properties);
properties.setProperty(PROP_NAME, name);
- properties.setProperty(PROP_VERSIONING_MODE, versioningMode.toString());
- properties.setProperty(PROP_ID_GENERATION, idGeneration.toString());
+
+ if (versioningMode != null)
+ {
+ properties.setProperty(PROP_VERSIONING_MODE, versioningMode.toString());
+ }
+
+ if (idGeneration != null)
+ {
+ properties.setProperty(PROP_ID_GENERATION, idGeneration.toString());
+ }
if (realm != null)
{
@@ -537,6 +561,97 @@ public abstract class CDORepositoryImpl extends AbstractElement implements CDORe
CDONet4jSessionConfiguration config = CDONet4jUtil.createNet4jSessionConfiguration();
config.setConnector(connector);
config.setRepositoryName(name);
+
+ if (Boolean.getBoolean("cdo.explorer.readableIDs"))
+ {
+ config.setIDGenerator(new CDOIDGenerator()
+ {
+ private final UUIDGenerator decoder = new UUIDGenerator();
+
+ private Map<EClass, AtomicInteger> counters;
+
+ private int typeCounter;
+
+ public CDOID generateCDOID(EObject object)
+ {
+ if (counters == null)
+ {
+ counters = new HashMap<EClass, AtomicInteger>();
+ CDOView view = CDOUtil.getView(object);
+ view.getSession().getRevisionManager().handleRevisions(null, null, false, CDOBranchPoint.UNSPECIFIED_DATE,
+ false, new CDORevisionHandler()
+ {
+ public boolean handleRevision(CDORevision revision)
+ {
+ EClass eClass = revision.getEClass();
+ AtomicInteger counter = getCounter(eClass);
+
+ String id = revision.getID().toString();
+ id = id.substring(0, id.length() - "A".length());
+ id = id.substring(id.lastIndexOf('_') + 1);
+
+ int counterValue = Integer.parseInt(id);
+ if (counterValue > counter.get())
+ {
+ counter.set(counterValue);
+ }
+
+ return true;
+ }
+ });
+ }
+
+ EClass eClass = object.eClass();
+
+ String type = eClass.getName();
+ if (type.length() > 16)
+ {
+ String suffix = "_" + (++typeCounter);
+ type = type.substring(0, 16 - suffix.length()) + suffix;
+ System.out.println(eClass.getName() + " --> " + type);
+ }
+
+ type = "_" + type;
+
+ AtomicInteger counter = getCounter(eClass);
+
+ String str = "_" + counter.incrementAndGet();
+ String id = type + "____________________________________".substring(0, 22 - type.length() - str.length())
+ + str + "A";
+
+ if ("_CDOResource_________5A".equals(id))
+ {
+ System.out.println();
+ }
+
+ byte[] value = decoder.decode(id);
+
+ String encoded = decoder.encode(value);
+ if (!encoded.equals(id))
+ {
+ throw new IllegalStateException();
+ }
+
+ return CDOIDUtil.createUUID(value);
+ }
+
+ private AtomicInteger getCounter(EClass eClass)
+ {
+ AtomicInteger counter = counters.get(eClass);
+ if (counter == null)
+ {
+ counter = new AtomicInteger();
+ counters.put(eClass, counter);
+ }
+ return counter;
+ }
+
+ public void reset()
+ {
+ }
+ });
+ }
+
return config;
}

Back to the top