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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/***************************************************************************
* Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.io.CDODataInput;
import org.eclipse.emf.cdo.common.io.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.internal.cdo.net4j.bundle.OM;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* @author Eike Stepper
*/
public class VerifyRevisionRequest extends CDOClientRequest<List<InternalCDORevision>>
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, VerifyRevisionRequest.class);
private Collection<InternalCDORevision> revisions;
public VerifyRevisionRequest(CDOClientProtocol protocol, Collection<InternalCDORevision> revisions)
{
super(protocol, CDOProtocolConstants.SIGNAL_VERIFY_REVISION);
this.revisions = revisions;
}
public VerifyRevisionRequest(CDOClientProtocol protocol, InternalCDORevision revision)
{
this(protocol, Collections.singleton(revision));
}
@Override
protected void requesting(CDODataOutput out) throws IOException
{
if (TRACER.isEnabled())
{
TRACER.format("Writing {0} IDs and versions", revisions.size()); //$NON-NLS-1$
}
out.writeInt(revisions.size());
for (InternalCDORevision revision : revisions)
{
CDOID id = revision.getID();
int version = revision.getVersion();
if (TRACER.isEnabled())
{
TRACER.format("Writing ID and version: {0}v{1}", id, version); //$NON-NLS-1$
}
out.writeCDOID(id);
out.writeInt(version);
}
}
@Override
protected List<InternalCDORevision> confirming(CDODataInput in) throws IOException
{
ArrayList<InternalCDORevision> result = new ArrayList<InternalCDORevision>();
if (TRACER.isEnabled())
{
TRACER.format("Reading {0} timeStamps", revisions.size()); //$NON-NLS-1$
}
for (InternalCDORevision revision : revisions)
{
long revised = in.readLong();
if (TRACER.isEnabled())
{
TRACER.format("Reading timeStamp: {0}", revised); //$NON-NLS-1$
}
if (revised != CDORevision.UNSPECIFIED_DATE)
{
revision.setRevised(revised);
result.add(revision);
}
}
return result;
}
}
|