Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-10-18 10:07:27 +0000
committerEike Stepper2010-10-18 10:07:27 +0000
commit6e584140d4942669e1bc4a6d9b0684b2a421060e (patch)
tree04745a4c2ad89772bfecffc9e0538bc4179151c7 /plugins/org.eclipse.emf.cdo.location
parent8a60628572ccb8cc0776d7f37b4e60ec4e11d61a (diff)
downloadcdo-6e584140d4942669e1bc4a6d9b0684b2a421060e.tar.gz
cdo-6e584140d4942669e1bc4a6d9b0684b2a421060e.tar.xz
cdo-6e584140d4942669e1bc4a6d9b0684b2a421060e.zip
[327405] Provide an offline CDOWorkspace with Checkout/Update/Commit workflows
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327405
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.location')
-rw-r--r--plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/BranchCheckoutSource.java114
-rw-r--r--plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocation.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocationManager.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/bundle/OM.java32
-rw-r--r--plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/ICheckoutSource.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/IRepositoryLocation.java4
6 files changed, 201 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/BranchCheckoutSource.java b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/BranchCheckoutSource.java
new file mode 100644
index 0000000000..55cd6abafd
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/BranchCheckoutSource.java
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2004 - 2010 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.location;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.location.ICheckoutSource;
+import org.eclipse.emf.cdo.location.IRepositoryLocation;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
+
+import org.eclipse.net4j.util.container.Container;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class BranchCheckoutSource extends Container<BranchCheckoutSource> implements ICheckoutSource
+{
+ private BranchCheckoutSource parent;
+
+ private String name;
+
+ private List<BranchCheckoutSource> subBranches;
+
+ public BranchCheckoutSource(BranchCheckoutSource parent, String name)
+ {
+ this.parent = parent;
+ this.name = name;
+ activate();
+ }
+
+ public IRepositoryLocation getRepositoryLocation()
+ {
+ return parent.getRepositoryLocation();
+ }
+
+ public String getBranchPath()
+ {
+ if (parent != null)
+ {
+ return parent.getBranchPath() + "/" + name;
+ }
+
+ return name;
+ }
+
+ public long getTimeStamp()
+ {
+ return CDOBranchPoint.UNSPECIFIED_DATE;
+ }
+
+ public BranchCheckoutSource[] getElements()
+ {
+ if (subBranches == null)
+ {
+ subBranches = new ArrayList<BranchCheckoutSource>();
+ CDOSessionConfiguration config = getRepositoryLocation().createSessionConfiguration();
+ CDOSession session = config.openSession();
+
+ try
+ {
+ CDOBranch[] branches = session.getBranchManager().getBranch(getBranchPath()).getBranches();
+ for (CDOBranch branch : branches)
+ {
+ subBranches.add(new BranchCheckoutSource(this, branch.getName()));
+ }
+ }
+ finally
+ {
+ IOUtil.close(session);
+ }
+ }
+
+ return subBranches.toArray(new BranchCheckoutSource[subBranches.size()]);
+ }
+
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Main extends BranchCheckoutSource
+ {
+ private IRepositoryLocation location;
+
+ public Main(IRepositoryLocation location)
+ {
+ super(null, CDOBranch.MAIN_BRANCH_NAME);
+ this.location = location;
+ }
+
+ @Override
+ public IRepositoryLocation getRepositoryLocation()
+ {
+ return location;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocation.java b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocation.java
index edb084f02e..251ca96a29 100644
--- a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocation.java
+++ b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocation.java
@@ -10,20 +10,20 @@
*/
package org.eclipse.emf.cdo.internal.location;
+import org.eclipse.emf.cdo.location.ICheckoutSource;
import org.eclipse.emf.cdo.location.IRepositoryLocation;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.container.Container;
import org.eclipse.net4j.util.container.IPluginContainer;
-import java.io.Serializable;
-
/**
* @author Eike Stepper
*/
-public class RepositoryLocation implements IRepositoryLocation, Serializable
+public class RepositoryLocation extends Container<ICheckoutSource> implements IRepositoryLocation
{
private static final long serialVersionUID = 1L;
@@ -35,6 +35,8 @@ public class RepositoryLocation implements IRepositoryLocation, Serializable
private String repositoryName;
+ private ICheckoutSource[] elements = { new BranchCheckoutSource.Main(this) };
+
public RepositoryLocation()
{
}
@@ -46,6 +48,7 @@ public class RepositoryLocation implements IRepositoryLocation, Serializable
this.connectorType = connectorType;
this.connectorDescription = connectorDescription;
this.repositoryName = repositoryName;
+ activate();
}
public RepositoryLocationManager getManager()
@@ -68,6 +71,11 @@ public class RepositoryLocation implements IRepositoryLocation, Serializable
return repositoryName;
}
+ public ICheckoutSource[] getElements()
+ {
+ return elements;
+ }
+
public CDOSessionConfiguration createSessionConfiguration()
{
org.eclipse.emf.cdo.net4j.CDOSessionConfiguration config = CDONet4jUtil.createSessionConfiguration();
diff --git a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocationManager.java b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocationManager.java
index fd6ec8e4dd..4fad33c905 100644
--- a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocationManager.java
+++ b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/RepositoryLocationManager.java
@@ -15,15 +15,13 @@ import org.eclipse.emf.cdo.location.IRepositoryLocationManager;
import org.eclipse.net4j.util.container.Container;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @author Eike Stepper
*/
-public class RepositoryLocationManager extends Container<IRepositoryLocation> implements IRepositoryLocationManager,
- Serializable
+public class RepositoryLocationManager extends Container<IRepositoryLocation> implements IRepositoryLocationManager
{
private static final long serialVersionUID = 1L;
@@ -51,8 +49,8 @@ public class RepositoryLocationManager extends Container<IRepositoryLocation> im
String repositoryName)
{
RepositoryLocation location = new RepositoryLocation(this, connectorType, connectorDescription, repositoryName);
- boolean added;
+ boolean added;
synchronized (repositoryLocations)
{
added = repositoryLocations.add(location);
@@ -79,4 +77,25 @@ public class RepositoryLocationManager extends Container<IRepositoryLocation> im
fireElementRemovedEvent(location);
}
}
+
+ // @Override
+ // protected void doActivate() throws Exception
+ // {
+ // super.doActivate();
+ // for (IRepositoryLocation location : repositoryLocations)
+ // {
+ // LifecycleUtil.activate(location);
+ // }
+ // }
+ //
+ // @Override
+ // protected void doDeactivate() throws Exception
+ // {
+ // for (IRepositoryLocation location : repositoryLocations)
+ // {
+ // LifecycleUtil.deactivate(location);
+ // }
+ //
+ // super.doDeactivate();
+ // }
}
diff --git a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/bundle/OM.java b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/bundle/OM.java
index a4b4a8b1fd..72e89595e9 100644
--- a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/internal/location/bundle/OM.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.internal.location.bundle;
import org.eclipse.emf.cdo.internal.location.RepositoryLocationManager;
+import org.eclipse.emf.cdo.location.IRepositoryLocation;
import org.eclipse.emf.cdo.location.IRepositoryLocationManager;
import org.eclipse.net4j.util.om.OMBundle;
@@ -19,6 +20,9 @@ import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.log.OMLogger;
import org.eclipse.net4j.util.om.trace.OMTracer;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* The <em>Operations & Maintenance</em> class of this bundle.
*
@@ -44,7 +48,7 @@ public abstract class OM
/**
* @author Eike Stepper
*/
- public static final class Activator extends OSGiActivator.WithConfig
+ public static final class Activator extends OSGiActivator.WithState
{
public Activator()
{
@@ -52,15 +56,33 @@ public abstract class OM
}
@Override
- protected void doStartWithConfig(Object config) throws Exception
+ protected void doStartWithState(Object state) throws Exception
{
- repositoryLocationManager = (RepositoryLocationManager)config;
+ @SuppressWarnings("unchecked")
+ List<List<String>> locations = (List<List<String>>)state;
+ if (locations != null)
+ {
+ for (List<String> location : locations)
+ {
+ repositoryLocationManager.addRepositoryLocation(location.get(0), location.get(1), location.get(2));
+ }
+ }
}
@Override
- protected Object doStopWithConfig() throws Exception
+ protected Object doStopWithState() throws Exception
{
- return repositoryLocationManager;
+ List<List<String>> locations = new ArrayList<List<String>>();
+ for (IRepositoryLocation location : repositoryLocationManager.getRepositoryLocations())
+ {
+ List<String> list = new ArrayList<String>();
+ list.add(location.getConnectorType());
+ list.add(location.getConnectorDescription());
+ list.add(location.getRepositoryName());
+ locations.add(list);
+ }
+
+ return locations;
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/ICheckoutSource.java b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/ICheckoutSource.java
new file mode 100644
index 0000000000..63854209a4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/ICheckoutSource.java
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2004 - 2010 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.location;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ICheckoutSource
+{
+ public IRepositoryLocation getRepositoryLocation();
+
+ public String getBranchPath();
+
+ public long getTimeStamp();
+}
diff --git a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/IRepositoryLocation.java b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/IRepositoryLocation.java
index 0c06e5cff0..897ab93160 100644
--- a/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/IRepositoryLocation.java
+++ b/plugins/org.eclipse.emf.cdo.location/src/org/eclipse/emf/cdo/location/IRepositoryLocation.java
@@ -12,11 +12,13 @@ package org.eclipse.emf.cdo.location;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.net4j.util.container.IContainer;
+
/**
* @author Eike Stepper
* @since 4.0
*/
-public interface IRepositoryLocation extends CDOSessionConfigurationFactory
+public interface IRepositoryLocation extends IContainer<ICheckoutSource>, CDOSessionConfigurationFactory
{
public String getConnectorType();

Back to the top