summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-22 03:49:51 (EDT)
committerEike Stepper2007-07-22 03:49:51 (EDT)
commitadd08bddf5bad96a0bd98b2250380ec898c8cb5a (patch)
tree87b7adda8d56f1ec1a02422b28c8b4519116a044
parentb78adca80f5a350c23d9aeab4ebb1c5920e3db90 (diff)
downloadcdo-add08bddf5bad96a0bd98b2250380ec898c8cb5a.zip
cdo-add08bddf5bad96a0bd98b2250380ec898c8cb5a.tar.gz
cdo-add08bddf5bad96a0bd98b2250380ec898c8cb5a.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenHistoricalViewAction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOAudit.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java45
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionCommittedEvent.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewCommittedEvent.java)2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionDirtyEvent.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewDirtyEvent.java)2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java27
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/ReadOnlyException.java38
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java56
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java27
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java15
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java76
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java121
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java4
22 files changed, 291 insertions, 202 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java
index 5e1498e..bb77e82 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/CreateResourceAction.java
@@ -38,7 +38,7 @@ public final class CreateResourceAction extends ViewAction
@Override
protected void doRun(final IWorkbenchPage page, IProgressMonitor monitor) throws Exception
{
- getView().createResource(resourcePath);
+ getTransaction().createResource(resourcePath);
CDOEditor.open(page, getView(), resourcePath);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenHistoricalViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenHistoricalViewAction.java
index caa006f..43dc4cd 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenHistoricalViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenHistoricalViewAction.java
@@ -22,6 +22,6 @@ public final class OpenHistoricalViewAction extends SessionAction
@Override
protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
{
- getSession().openView(new ResourceSetImpl(), System.currentTimeMillis());
+ getSession().openAudit(new ResourceSetImpl(), System.currentTimeMillis());
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java
index b765c4b..f9b1f50 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java
@@ -22,6 +22,6 @@ public final class OpenReadOnlyViewAction extends SessionAction
@Override
protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
{
- getSession().openView(new ResourceSetImpl(), true);
+ getSession().openView(new ResourceSetImpl());
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
index dbde404..a14917c 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
@@ -22,6 +22,6 @@ public final class OpenViewAction extends SessionAction
@Override
protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
{
- getSession().openView(new ResourceSetImpl());
+ getSession().openTransaction(new ResourceSetImpl());
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java
index 0f75d38..289416e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ViewAction.java
@@ -1,9 +1,12 @@
package org.eclipse.emf.cdo.internal.ui.actions;
+import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.net4j.ui.actions.LongRunningAction;
+import org.eclipse.emf.internal.cdo.CDOViewImpl;
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPage;
@@ -26,4 +29,9 @@ public abstract class ViewAction extends LongRunningAction
{
return view;
}
+
+ public CDOTransaction getTransaction()
+ {
+ return ((CDOViewImpl)view).toTransaction();
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index 4d4f964..65c1762 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -8,9 +8,10 @@ package org.eclipse.emf.cdo.internal.ui.editor;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSessionViewsEvent;
+import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewCommittedEvent;
-import org.eclipse.emf.cdo.CDOViewDirtyEvent;
+import org.eclipse.emf.cdo.CDOTransactionCommittedEvent;
+import org.eclipse.emf.cdo.CDOTransactionDirtyEvent;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.cdo.internal.ui.views.CDOEventHandler;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
@@ -222,7 +223,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
{
public void notifyEvent(IEvent event)
{
- if (event instanceof CDOViewDirtyEvent || event instanceof CDOViewCommittedEvent)
+ if (event instanceof CDOTransactionDirtyEvent || event instanceof CDOTransactionCommittedEvent)
{
try
{
@@ -1539,9 +1540,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@Override
public boolean isDirty()
{
- // return
- // ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
- return view.isDirty();
+ return view instanceof CDOTransaction && ((CDOTransaction)view).isDirty();
}
/**
@@ -2209,7 +2208,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
if (resource != null)
{
- CDOObject object = view.newInstance(cdoClass);
+ CDOObject object = ((CDOTransaction)view).newInstance(cdoClass);
resource.getContents().add(object);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java
index 14ea7f9..98a4b22 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOEventHandler.java
@@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewCommittedEvent;
+import org.eclipse.emf.cdo.CDOTransactionCommittedEvent;
import org.eclipse.emf.cdo.internal.ui.ItemsProcessor;
import org.eclipse.emf.cdo.protocol.CDOID;
@@ -58,9 +58,9 @@ public class CDOEventHandler
{
public void notifyEvent(IEvent event)
{
- if (event instanceof CDOViewCommittedEvent)
+ if (event instanceof CDOTransactionCommittedEvent)
{
- Map<CDOID, CDOID> idMappings = ((CDOViewCommittedEvent)event).getIDMappings();
+ Map<CDOID, CDOID> idMappings = ((CDOTransactionCommittedEvent)event).getIDMappings();
HashSet newOIDs = new HashSet(idMappings.values());
new ItemsProcessor()
{
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index c4e0edb..1634c57 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -12,8 +12,8 @@ package org.eclipse.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewCommittedEvent;
-import org.eclipse.emf.cdo.CDOViewDirtyEvent;
+import org.eclipse.emf.cdo.CDOTransactionCommittedEvent;
+import org.eclipse.emf.cdo.CDOTransactionDirtyEvent;
import org.eclipse.emf.cdo.CDOViewEvent;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.actions.CloseSessionAction;
@@ -57,7 +57,7 @@ public class CDOItemProvider extends ContainerItemProvider
{
public void notifyEvent(IEvent event)
{
- if (event instanceof CDOViewDirtyEvent || event instanceof CDOViewCommittedEvent)
+ if (event instanceof CDOTransactionDirtyEvent || event instanceof CDOTransactionCommittedEvent)
{
try
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOAudit.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOAudit.java
new file mode 100644
index 0000000..fccc704
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOAudit.java
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * Copyright (c) 2004-2007 Eike Stepper, Germany.
+ * 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;
+
+
+/**
+ * @author Eike Stepper
+ */
+public interface CDOAudit extends CDOView
+{
+ public long getTimeStamp();
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
index 6a7b290..3e08a98 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSession.java
@@ -41,17 +41,17 @@ public interface CDOSession extends IContainer<CDOView>
public CDOView[] getViews();
- public CDOView openView(ResourceSet resourceSet, long timeStamp);
+ public CDOTransaction openTransaction(ResourceSet resourceSet);
- public CDOView openView(ResourceSet resourceSet, boolean readOnly);
+ public CDOTransaction openTransaction();
public CDOView openView(ResourceSet resourceSet);
- public CDOView openView(long timeStamp);
+ public CDOView openView();
- public CDOView openView(boolean readOnly);
+ public CDOAudit openAudit(ResourceSet resourceSet, long timeStamp);
- public CDOView openView();
+ public CDOAudit openAudit(long timeStamp);
public void close();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
new file mode 100644
index 0000000..2f313f6
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * Copyright (c) 2004-2007 Eike Stepper, Germany.
+ * 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;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.protocol.model.CDOClass;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * @author Eike Stepper
+ */
+public interface CDOTransaction extends CDOView
+{
+ /**
+ * @see ResourceSet#createResource(URI)
+ */
+ public CDOResource createResource(String path);
+
+ public CDOObject newInstance(EClass eClass);
+
+ public CDOObject newInstance(CDOClass cdoClass);
+
+ public boolean isDirty();
+
+ /**
+ * @see CDOTransaction#commit()
+ */
+ public void commit();
+
+ /**
+ * @see CDOTransaction#rollback()
+ */
+ public void rollback();
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewCommittedEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionCommittedEvent.java
index 1c35c95..fc625d3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewCommittedEvent.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionCommittedEvent.java
@@ -17,7 +17,7 @@ import java.util.Map;
/**
* @author Eike Stepper
*/
-public interface CDOViewCommittedEvent extends CDOViewEvent
+public interface CDOTransactionCommittedEvent extends CDOViewEvent
{
public Map<CDOID, CDOID> getIDMappings();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewDirtyEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionDirtyEvent.java
index 9a48432..89b90f3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOViewDirtyEvent.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionDirtyEvent.java
@@ -13,6 +13,6 @@ package org.eclipse.emf.cdo;
/**
* @author Eike Stepper
*/
-public interface CDOViewDirtyEvent extends CDOViewEvent
+public interface CDOTransactionDirtyEvent extends CDOViewEvent
{
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index 5c42f8a..9f9a0fa 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -12,13 +12,11 @@ package org.eclipse.emf.cdo;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.net4j.util.event.INotifier;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.resource.ResourceSet;
/**
@@ -34,43 +32,18 @@ public interface CDOView extends INotifier
public ResourceSet getResourceSet();
- public long getTimeStamp();
-
public boolean isHistorical();
- public boolean isReadWrite();
-
public boolean isReadOnly();
/**
- * @see ResourceSet#createResource(URI)
- */
- public CDOResource createResource(String path);
-
- /**
* @see ResourceSet#getResource(URI, boolean)
*/
public CDOResource getResource(String path);
- public CDOObject newInstance(EClass eClass);
-
- public CDOObject newInstance(CDOClass cdoClass);
-
public CDOObject lookupInstance(CDOID id);
public CDORevision lookupRevision(CDOID id);
- public boolean isDirty();
-
- /**
- * @see CDOTransaction#commit()
- */
- public void commit();
-
- /**
- * @see CDOTransaction#rollback()
- */
- public void rollback();
-
public void close();
}
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 22a78c5..7b3e145 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
@@ -7,6 +7,7 @@
package org.eclipse.emf.cdo.eresource.impl;
import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -333,7 +334,13 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource
*/
public void save(Map<?, ?> options) throws IOException
{
- view.commit();
+ if (view instanceof CDOTransaction)
+ {
+ CDOTransaction transaction = (CDOTransaction)view;
+ transaction.commit();
+ }
+
+ throw new IOException("CDO view is read only: " + view);
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/ReadOnlyException.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/ReadOnlyException.java
new file mode 100644
index 0000000..591620c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/ReadOnlyException.java
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (c) 2004-2007 Eike Stepper, Germany.
+ * 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.util;
+
+/**
+ * @author Eike Stepper
+ */
+public class ReadOnlyException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public ReadOnlyException()
+ {
+ }
+
+ public ReadOnlyException(String message)
+ {
+ super(message);
+ }
+
+ public ReadOnlyException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ReadOnlyException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
new file mode 100644
index 0000000..5a99cf8
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (c) 2004-2007 Eike Stepper, Germany.
+ * 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.internal.cdo;
+
+import org.eclipse.emf.cdo.CDOAudit;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver;
+
+import java.text.MessageFormat;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOAuditImpl extends CDOViewImpl implements CDOAudit
+{
+ private long timeStamp;
+
+ public CDOAuditImpl(int id, CDOSessionImpl session, long timeStamp)
+ {
+ super(id, session);
+ this.timeStamp = timeStamp;
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ @Override
+ public boolean isHistorical()
+ {
+ return true;
+ }
+
+ @Override
+ public CDORevisionImpl lookupRevision(CDOID id)
+ {
+ CDORevisionResolver revisionManager = getSession().getRevisionManager();
+ return (CDORevisionImpl)revisionManager.getRevision(id, timeStamp);
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOAudit({0})", getID());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 889ee5f..1d1810c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -176,36 +176,37 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
return revisionManager;
}
- public CDOViewImpl openView(ResourceSet resourceSet)
+ public CDOTransactionImpl openTransaction(ResourceSet resourceSet)
{
- return openView(resourceSet, false);
+ prepare(resourceSet);
+ return (CDOTransactionImpl)attach(resourceSet, new CDOTransactionImpl(++lastViewID, this));
}
- public CDOViewImpl openView(ResourceSet resourceSet, boolean readOnly)
+ public CDOTransactionImpl openTransaction()
{
- prepare(resourceSet);
- return attach(resourceSet, new CDOViewImpl(++lastViewID, this, readOnly));
+ return openTransaction(createResourceSet());
}
- public CDOViewImpl openView(ResourceSet resourceSet, long timeStamp)
+ public CDOViewImpl openView(ResourceSet resourceSet)
{
prepare(resourceSet);
- return attach(resourceSet, new CDOViewImpl(++lastViewID, this, timeStamp));
+ return attach(resourceSet, new CDOViewImpl(++lastViewID, this));
}
- public CDOView openView(boolean readOnly)
+ public CDOViewImpl openView()
{
- return openView(createResourceSet(), readOnly);
+ return openView(createResourceSet());
}
- public CDOView openView(long timeStamp)
+ public CDOAuditImpl openAudit(ResourceSet resourceSet, long timeStamp)
{
- return openView(createResourceSet(), timeStamp);
+ prepare(resourceSet);
+ return (CDOAuditImpl)attach(resourceSet, new CDOAuditImpl(++lastViewID, this, timeStamp));
}
- public CDOView openView()
+ public CDOAuditImpl openAudit(long timeStamp)
{
- return openView(createResourceSet());
+ return openAudit(createResourceSet(), timeStamp);
}
public CDOViewImpl[] getViews()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index 0d74a8b..2196020 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -226,17 +226,6 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
return object.cdoState();
}
- private static CDOTransactionImpl getTransaction(CDOViewImpl view)
- {
- CDOTransactionImpl transaction = view.getTransaction();
- if (transaction == null)
- {
- throw new IllegalStateException("transaction == null");
- }
-
- return transaction;
- }
-
/**
* @author Eike Stepper
*/
@@ -255,7 +244,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
{
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, ResourceAndView data)
{
- CDOTransactionImpl transaction = getTransaction(data.view);
+ CDOTransactionImpl transaction = data.view.toTransaction();
// Prepare object
CDOID id = transaction.getNextTemporaryID();
@@ -360,7 +349,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
revision.increaseVersion();
CDOViewImpl view = (CDOViewImpl)object.cdoView();
- CDOTransactionImpl transaction = getTransaction(view);
+ CDOTransactionImpl transaction = view.toTransaction();
transaction.registerDirty(object);
object.cdoInternalSetState(CDOState.DIRTY);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index c1a56bf..ce2d231 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -10,6 +10,9 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.CDOTransactionCommittedEvent;
+import org.eclipse.emf.cdo.CDOTransactionDirtyEvent;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
@@ -25,6 +28,7 @@ import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionRequest;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,7 +36,7 @@ import java.util.Map;
/**
* @author Eike Stepper
*/
-public class CDOTransactionImpl
+public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSCTION, CDOTransactionImpl.class);
@@ -40,8 +44,6 @@ public class CDOTransactionImpl
private transient long nextTemporaryID = INITIAL_TEMPORARY_ID;
- private CDOViewImpl view;
-
private List<CDOPackageImpl> newPackages;
private Map<CDOID, CDOResourceImpl> newResources = new HashMap();
@@ -52,19 +54,20 @@ public class CDOTransactionImpl
private boolean dirty;
- public CDOTransactionImpl(CDOViewImpl view)
+ public CDOTransactionImpl(int id, CDOSessionImpl session)
{
- this.view = view;
+ super(id, session);
}
- public CDOViewImpl getView()
+ public boolean isDirty()
{
- return view;
+ return dirty;
}
- public boolean isDirty()
+ @Override
+ public boolean isReadOnly()
{
- return dirty;
+ return false;
}
public List<CDOPackageImpl> getNewPackages()
@@ -95,8 +98,9 @@ public class CDOTransactionImpl
return CDOIDImpl.create(id);
}
- public CommitTransactionResult commit()
+ public void commit()
{
+ checkWritable();
if (dirty)
{
if (TRACER.isEnabled())
@@ -106,7 +110,7 @@ public class CDOTransactionImpl
try
{
- CDOSessionImpl session = view.getSession();
+ CDOSessionImpl session = getSession();
CDOPackageManagerImpl packageManager = session.getPackageManager();
newPackages = packageManager.getTransientPackages();
@@ -119,7 +123,7 @@ public class CDOTransactionImpl
if (!dirtyObjects.isEmpty())
{
- session.notifyInvalidation(result.getTimeStamp(), dirtyObjects.keySet(), view);
+ session.notifyInvalidation(result.getTimeStamp(), dirtyObjects.keySet(), this);
}
for (CDOPackageImpl newPackage : newPackages)
@@ -133,7 +137,9 @@ public class CDOTransactionImpl
dirtyObjects.clear();
dirty = false;
nextTemporaryID = INITIAL_TEMPORARY_ID;
- return result;
+
+ Map<CDOID, CDOID> idMappings = result.getIdMappings();
+ fireEvent(new CommittedEvent(idMappings));
}
catch (RuntimeException ex)
{
@@ -144,12 +150,12 @@ public class CDOTransactionImpl
throw new TransportException(ex);
}
}
-
- return null;
}
public void rollback()
{
+ checkWritable();
+
try
{
// TODO Implement method CDOTransactionImpl.rollback()
@@ -165,6 +171,12 @@ public class CDOTransactionImpl
}
}
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOTransaction({0})", getID());
+ }
+
public void registerNew(InternalCDOObject object)
{
if (object instanceof CDOResourceImpl)
@@ -208,7 +220,7 @@ public class CDOTransactionImpl
if (!dirty)
{
dirty = true;
- view.fireDirtyEvent();
+ fireEvent(new DirtyEvent());
}
}
@@ -223,6 +235,38 @@ public class CDOTransactionImpl
}
}
+ /**
+ * @author Eike Stepper
+ */
+ private final class DirtyEvent extends Event implements CDOTransactionDirtyEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private DirtyEvent()
+ {
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class CommittedEvent extends Event implements CDOTransactionCommittedEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private Map<CDOID, CDOID> idMappings;
+
+ private CommittedEvent(Map<CDOID, CDOID> idMappings)
+ {
+ this.idMappings = idMappings;
+ }
+
+ public Map<CDOID, CDOID> getIDMappings()
+ {
+ return idMappings;
+ }
+ }
+
// private Collection<CDOPackageImpl> calculateNewPackages()
// {
// CDOSessionImpl session = view.getSession();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 769e525..b06036c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -12,8 +12,6 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewCommittedEvent;
-import org.eclipse.emf.cdo.CDOViewDirtyEvent;
import org.eclipse.emf.cdo.CDOViewEvent;
import org.eclipse.emf.cdo.CDOViewResourcesEvent;
import org.eclipse.emf.cdo.eresource.CDOResource;
@@ -28,6 +26,7 @@ import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver;
import org.eclipse.emf.cdo.protocol.util.ImplementationError;
import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.ReadOnlyException;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -42,12 +41,10 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
import org.eclipse.emf.internal.cdo.protocol.ResourcePathRequest;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import java.text.MessageFormat;
-import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -66,32 +63,16 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
private ResourceSet resourceSet;
- private long timeStamp;
-
- private CDOTransactionImpl transaction;
-
private Map<CDOID, InternalCDOObject> objects = new HashMap();
private CDOID lastLookupID;
private InternalCDOObject lastLookupObject;
- public CDOViewImpl(int id, CDOSessionImpl session, boolean readOnly)
- {
- this.id = id;
- this.session = session;
- timeStamp = UNSPECIFIED_DATE;
- if (!readOnly)
- {
- transaction = new CDOTransactionImpl(this);
- }
- }
-
- public CDOViewImpl(int id, CDOSessionImpl session, long timeStamp)
+ public CDOViewImpl(int id, CDOSessionImpl session)
{
this.id = id;
this.session = session;
- this.timeStamp = timeStamp;
}
public int getID()
@@ -109,29 +90,24 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return session;
}
- public CDOTransactionImpl getTransaction()
- {
- return transaction;
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
public boolean isHistorical()
{
- return timeStamp != CDOView.UNSPECIFIED_DATE;
+ return false;
}
- public boolean isReadWrite()
+ public boolean isReadOnly()
{
- return transaction != null;
+ return true;
}
- public boolean isReadOnly()
+ public CDOTransactionImpl toTransaction()
{
- return transaction == null;
+ if (this instanceof CDOTransactionImpl)
+ {
+ return (CDOTransactionImpl)this;
+ }
+
+ throw new ReadOnlyException("CDO view is read only: " + this);
}
public CDOResource createResource(String path)
@@ -213,12 +189,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
public CDORevisionImpl lookupRevision(CDOID id)
{
CDORevisionResolver revisionManager = session.getRevisionManager();
- if (isReadWrite())
- {
- return (CDORevisionImpl)revisionManager.getRevision(id);
- }
-
- return (CDORevisionImpl)revisionManager.getRevision(id, timeStamp);
+ return (CDORevisionImpl)revisionManager.getRevision(id);
}
public InternalCDOObject lookupInstance(CDOID id)
@@ -459,28 +430,6 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
}
- public boolean isDirty()
- {
- return transaction == null ? false : transaction.isDirty();
- }
-
- public void commit()
- {
- checkWritable();
- CommitTransactionResult result = transaction.commit();
- if (result != null)
- {
- Map<CDOID, CDOID> idMappings = result.getIdMappings();
- fireEvent(new CommittedEvent(idMappings));
- }
- }
-
- public void rollback()
- {
- checkWritable();
- transaction.rollback();
- }
-
public void close()
{
session.viewDetached(this);
@@ -489,8 +438,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
@Override
public String toString()
{
- return MessageFormat.format("CDOView({0})", isHistorical() ? new Date(timeStamp) : isReadOnly() ? "readOnly"
- : "readWrite");
+ return MessageFormat.format("CDOView({0})", id);
}
public boolean isAdapterForType(Object type)
@@ -545,11 +493,6 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
}
- public void fireDirtyEvent()
- {
- fireEvent(new DirtyEvent());
- }
-
public void notifyChanged(Notification msg)
{
switch (msg.getEventType())
@@ -650,7 +593,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
fireEvent(new ResourcesEvent(cdoResource.getPath(), ResourcesEvent.Kind.REMOVED));
}
- private void checkWritable()
+ protected void checkWritable()
{
if (isReadOnly())
{
@@ -693,7 +636,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
/**
* @author Eike Stepper
*/
- private abstract class Event extends org.eclipse.net4j.internal.util.event.Event implements CDOViewEvent
+ protected abstract class Event extends org.eclipse.net4j.internal.util.event.Event implements CDOViewEvent
{
private static final long serialVersionUID = 1L;
@@ -741,36 +684,4 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return MessageFormat.format("CDOViewResourcesEvent[{0}, {1}, {2}]", getView(), resourcePath, kind);
}
}
-
- /**
- * @author Eike Stepper
- */
- private final class DirtyEvent extends Event implements CDOViewDirtyEvent
- {
- private static final long serialVersionUID = 1L;
-
- private DirtyEvent()
- {
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private final class CommittedEvent extends Event implements CDOViewCommittedEvent
- {
- private static final long serialVersionUID = 1L;
-
- private Map<CDOID, CDOID> idMappings;
-
- private CommittedEvent(Map<CDOID, CDOID> idMappings)
- {
- this.idMappings = idMappings;
- }
-
- public Map<CDOID, CDOID> getIDMappings()
- {
- return idMappings;
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index 500bcfe..bb99745 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDOIDProvider;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
@@ -108,13 +107,12 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
private void writeRevisions(ExtendedDataOutputStream out, Collection objects) throws IOException
{
- CDOIDProvider idProvider = transaction.getView();
out.writeInt(objects.size());
for (Iterator it = objects.iterator(); it.hasNext();)
{
InternalCDOObject object = (InternalCDOObject)it.next();
CDORevisionImpl revision = (CDORevisionImpl)object.cdoRevision();
- revision.write(out, idProvider);
+ revision.write(out, transaction);
}
}