blob: be5e95b5fa4c692cfad8cba96e895c4a8729ef99 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/**
* 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
* Simon McDuff - bug 201266
* Simon McDuff - bug 213402
*/
package org.eclipse.emf.cdo.spi.server;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
/**
* @since 2.0
* @author Eike Stepper
*/
public abstract class LongIDStoreAccessor extends StoreAccessor
{
protected LongIDStoreAccessor(Store store, ISession session)
{
super(store, session);
}
protected LongIDStoreAccessor(Store store, ITransaction transaction)
{
super(store, transaction);
}
/**
* @since 3.0
*/
@Override
protected void addIDMappings(InternalCommitContext commitContext, OMMonitor monitor)
{
try
{
LongIDStore longIDStore = (LongIDStore)getStore();
CDORevision[] newObjects = commitContext.getNewObjects();
monitor.begin(newObjects.length);
for (CDORevision revision : newObjects)
{
CDOID id = revision.getID();
if (id instanceof CDOIDTemp)
{
CDOIDTemp oldID = (CDOIDTemp)id;
CDOID newID = longIDStore.getNextCDOID(revision.getBranch().isLocal());
if (CDOIDUtil.isNull(newID) || newID.isTemporary())
{
throw new IllegalStateException("newID=" + newID); //$NON-NLS-1$
}
commitContext.addIDMapping(oldID, newID);
}
monitor.worked();
}
}
finally
{
monitor.done();
}
}
}
|