diff options
Diffstat (limited to 'plugins')
46 files changed, 3893 insertions, 2636 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java index 8f779ac388..2e002d0c9e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java @@ -125,6 +125,12 @@ public interface CDODataOutput extends ExtendedDataOutput public void writeCDORevision(CDORevision revision, int referenceChunk) throws IOException; /** + * @since 4.1 + */ + public void writeCDORevision(CDORevision revision, int referenceChunk, CDOBranchPoint securityContext) + throws IOException; + + /** * @since 4.0 */ public void writeCDORevisable(CDORevisable revisable) throws IOException; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java index d3884bc678..75eb411b21 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java @@ -62,15 +62,9 @@ public interface CDORevision extends CDORevisionKey, CDORevisable */ public static final CDOPermissionProvider PERMISSION_PROVIDER = new CDOPermissionProvider() { - public CDOPermission getPermission(Object protectableObject) + public CDOPermission getPermission(CDORevision revision, CDOBranchPoint securityContext) { - if (protectableObject instanceof CDORevision) - { - CDORevision revision = (CDORevision)protectableObject; - return revision.getPermission(); - } - - return CDOPermission.NONE; + return revision.getPermission(); } }; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/CDOPermissionProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/CDOPermissionProvider.java index 7bdfef532b..6de18eb1d1 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/CDOPermissionProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/CDOPermissionProvider.java @@ -10,6 +10,9 @@ */ package org.eclipse.emf.cdo.common.security; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.revision.CDORevision; + /** * Provides the protection level of protectable objects. * @@ -24,10 +27,10 @@ public interface CDOPermissionProvider public static final CDOPermissionProvider WRITE = new Constant(CDOPermission.WRITE); - public CDOPermission getPermission(Object protectableObject); + public CDOPermission getPermission(CDORevision revision, CDOBranchPoint securityContext); /** - * Provides a constant protection level for all protectable entities. + * Provides a constant protection level for all {@link CDORevision revisions}. * * @author Eike Stepper */ @@ -40,7 +43,7 @@ public interface CDOPermissionProvider this.permission = permission; } - public CDOPermission getPermission(Object protectableObject) + public CDOPermission getPermission(CDORevision revision, CDOBranchPoint securityContext) { return permission; } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java index da29833eab..247f6e5193 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/protocol/CDODataOutputImpl.java @@ -387,10 +387,16 @@ public abstract class CDODataOutputImpl extends ExtendedDataOutput.Delegating im public void writeCDORevision(CDORevision revision, int referenceChunk) throws IOException { + writeCDORevision(revision, referenceChunk, null); + } + + public void writeCDORevision(CDORevision revision, int referenceChunk, CDOBranchPoint securityContext) + throws IOException + { if (revision != null) { writeBoolean(true); - ((InternalCDORevision)revision).write(this, referenceChunk); + ((InternalCDORevision)revision).write(this, referenceChunk, securityContext); } else { diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java index 8853d5e418..f61f97f595 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java @@ -197,6 +197,14 @@ public abstract class BaseCDORevision extends AbstractCDORevision */ public void write(CDODataOutput out, int referenceChunk) throws IOException { + write(out, referenceChunk, null); + } + + /** + * @since 4.1 + */ + public void write(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext) throws IOException + { if (WRITING.isEnabled()) { WRITING.start(this); @@ -205,7 +213,7 @@ public abstract class BaseCDORevision extends AbstractCDORevision writeSystemValues(out); CDOPermissionProvider permissionProvider = out.getPermissionProvider(); - CDOPermission permission = permissionProvider.getPermission(this); + CDOPermission permission = permissionProvider.getPermission(this, securityContext); int bits = flags & TRANSFER_MASK & ~PERMISSION_MASK; bits |= permission.getBits(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java index f743b2bbb1..faee1649e8 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java @@ -310,6 +310,14 @@ public abstract class DelegatingCDORevision implements InternalCDORevision getDelegate().write(out, referenceChunk); } + /** + * @since 4.1 + */ + public void write(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext) throws IOException + { + getDelegate().write(out, referenceChunk, securityContext); + } + public void convertEObjects(CDOIDProvider oidProvider) { getDelegate().convertEObjects(oidProvider); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java index 985b397ec4..1ead2b37ec 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java @@ -103,6 +103,11 @@ public interface InternalCDORevision extends CDORevision, CDORevisionData, CDORe public void write(CDODataOutput out, int referenceChunk) throws IOException; /** + * @since 4.1 + */ + public void write(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext) throws IOException; + + /** * @since 3.0 */ public void convertEObjects(CDOIDProvider oidProvider); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java index 71e6ea8153..60eb9512a9 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java @@ -1,571 +1,616 @@ -/*
- * Copyright (c) 2004 - 2012 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public abstract class RevisionInfo
-{
- private static final int NO_RESULT = 0;
-
- private static final int POINTER_RESULT = 1;
-
- private static final int DETACHED_RESULT = 2;
-
- private static final int NORMAL_RESULT = 3;
-
- private CDOID id;
-
- private CDOBranchPoint requestedBranchPoint;
-
- private InternalCDORevision result;
-
- private SyntheticCDORevision synthetic;
-
- protected RevisionInfo(CDOID id, CDOBranchPoint requestedBranchPoint)
- {
- CheckUtil.checkArg(requestedBranchPoint, "requestedBranchPoint");
- this.id = id;
- this.requestedBranchPoint = requestedBranchPoint;
- }
-
- protected RevisionInfo(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException
- {
- CheckUtil.checkArg(requestedBranchPoint, "requestedBranchPoint");
- id = in.readCDOID();
- this.requestedBranchPoint = requestedBranchPoint;
- }
-
- public abstract Type getType();
-
- public final CDOID getID()
- {
- return id;
- }
-
- public final CDOBranchPoint getRequestedBranchPoint()
- {
- return requestedBranchPoint;
- }
-
- public InternalCDORevision getResult()
- {
- return result;
- }
-
- public void setResult(InternalCDORevision result)
- {
- this.result = result;
- }
-
- public SyntheticCDORevision getSynthetic()
- {
- return synthetic;
- }
-
- public void setSynthetic(SyntheticCDORevision synthetic)
- {
- this.synthetic = synthetic;
- }
-
- public abstract boolean isLoadNeeded();
-
- public void write(CDODataOutput out) throws IOException
- {
- out.writeByte(getType().ordinal());
- out.writeCDOID(getID());
- }
-
- public static RevisionInfo read(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException
- {
- byte ordinal = in.readByte();
- Type type = Type.values()[ordinal];
- switch (type)
- {
- case AVAILABLE_NORMAL:
- return new Available.Normal(in, requestedBranchPoint);
-
- case AVAILABLE_POINTER:
- return new Available.Pointer(in, requestedBranchPoint);
-
- case AVAILABLE_DETACHED:
- return new Available.Detached(in, requestedBranchPoint);
-
- case MISSING:
- return new Missing(in, requestedBranchPoint);
-
- default:
- throw new IOException("Invalid revision info type: " + type);
- }
- }
-
- public void execute(InternalCDORevisionManager revisionManager, int referenceChunk)
- {
- SyntheticCDORevision[] synthetics = new SyntheticCDORevision[1];
- result = revisionManager.getRevision(getID(), requestedBranchPoint, referenceChunk, CDORevision.DEPTH_NONE, true,
- synthetics);
- synthetic = synthetics[0];
- }
-
- public void writeResult(CDODataOutput out, int referenceChunk) throws IOException
- {
- writeRevision(out, referenceChunk);
- writeResult(out, synthetic, referenceChunk);
- }
-
- public void readResult(CDODataInput in) throws IOException
- {
- readRevision(in);
- synthetic = (SyntheticCDORevision)readResult(in, getID(), requestedBranchPoint.getBranch());
- }
-
- public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results,
- SyntheticCDORevision[] synthetics, int i)
- {
- if (result instanceof DetachedCDORevision)
- {
- results.add(null);
- }
- else
- {
- results.add(result);
- }
-
- if (result != null)
- {
- revisionManager.addRevision(result);
- }
-
- if (synthetic != null)
- {
- revisionManager.addRevision(synthetic);
- if (synthetic instanceof PointerCDORevision)
- {
- PointerCDORevision pointer = (PointerCDORevision)synthetic;
- CDOBranchVersion target = pointer.getTarget();
- if (target != result && target instanceof InternalCDORevision)
- {
- revisionManager.addRevision((CDORevision)target);
- }
- }
-
- if (synthetics != null)
- {
- synthetics[i] = synthetic;
- }
- }
- }
-
- protected void writeRevision(CDODataOutput out, int referenceChunk) throws IOException
- {
- out.writeCDORevision(result, referenceChunk);
- }
-
- protected void readRevision(CDODataInput in) throws IOException
- {
- result = (InternalCDORevision)in.readCDORevision();
- }
-
- /**
- * @since 4.0
- */
- public static void writeResult(CDODataOutput out, InternalCDORevision revision, int referenceChunk)
- throws IOException
- {
- if (revision == null)
- {
- out.writeByte(NO_RESULT);
- }
- else if (revision instanceof PointerCDORevision)
- {
- PointerCDORevision pointer = (PointerCDORevision)revision;
- out.writeByte(POINTER_RESULT);
- out.writeCDOClassifierRef(pointer.getEClass());
- out.writeLong(pointer.getRevised());
-
- CDOBranchVersion target = pointer.getTarget();
- if (target instanceof InternalCDORevision)
- {
- writeResult(out, (InternalCDORevision)target, referenceChunk);
- }
- else
- {
- out.writeByte(NO_RESULT);
- }
- }
- else if (revision instanceof DetachedCDORevision)
- {
- DetachedCDORevision detached = (DetachedCDORevision)revision;
- out.writeByte(DETACHED_RESULT);
- out.writeCDOClassifierRef(detached.getEClass());
- out.writeLong(detached.getTimeStamp());
- out.writeLong(detached.getRevised());
- out.writeInt(detached.getVersion());
- }
- else
- {
- out.writeByte(NORMAL_RESULT);
- out.writeCDORevision(revision, referenceChunk);
- }
- }
-
- /**
- * @since 4.0
- */
- public static InternalCDORevision readResult(CDODataInput in, CDOID id, CDOBranch branch) throws IOException
- {
- byte type = in.readByte();
- switch (type)
- {
- case NO_RESULT:
- return null;
-
- case POINTER_RESULT:
- {
- EClassifier classifier = in.readCDOClassifierRefAndResolve();
- long revised = in.readLong();
- InternalCDORevision target = readResult(in, id, branch);
- return new PointerCDORevision((EClass)classifier, id, branch, revised, target);
- }
-
- case DETACHED_RESULT:
- {
- EClassifier classifier = in.readCDOClassifierRefAndResolve();
- long timeStamp = in.readLong();
- long revised = in.readLong();
- int version = in.readInt();
- return new DetachedCDORevision((EClass)classifier, id, branch, version, timeStamp, revised);
- }
-
- case NORMAL_RESULT:
- return (InternalCDORevision)in.readCDORevision();
-
- default:
- throw new IllegalStateException("Invalid synthetic type: " + type);
- }
- }
-
- protected void doWriteResult(CDODataOutput out, InternalCDORevision revision, int referenceChunk) throws IOException
- {
- writeResult(out, revision, referenceChunk);
- }
-
- protected InternalCDORevision doReadResult(CDODataInput in) throws IOException
- {
- return readResult(in, id, requestedBranchPoint.getBranch());
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static enum Type
- {
- AVAILABLE_NORMAL, AVAILABLE_POINTER, AVAILABLE_DETACHED, MISSING
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static abstract class Available extends RevisionInfo
- {
- private CDOBranchVersion availableBranchVersion;
-
- protected Available(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion)
- {
- super(id, requestedBranchPoint);
- this.availableBranchVersion = availableBranchVersion;
- }
-
- protected Available(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException
- {
- super(in, requestedBranchPoint);
- availableBranchVersion = in.readCDOBranchVersion();
- }
-
- public CDOBranchVersion getAvailableBranchVersion()
- {
- return availableBranchVersion;
- }
-
- public boolean isDirect()
- {
- return ObjectUtil.equals(availableBranchVersion.getBranch(), getRequestedBranchPoint().getBranch());
- }
-
- @Override
- public boolean isLoadNeeded()
- {
- return !isDirect();
- }
-
- @Override
- public void write(CDODataOutput out) throws IOException
- {
- super.write(out);
- out.writeCDOBranchVersion(availableBranchVersion);
- }
-
- @Override
- protected void writeRevision(CDODataOutput out, int referenceChunk) throws IOException
- {
- InternalCDORevision result = getResult();
- if (result != null && ObjectUtil.equals(result.getBranch(), availableBranchVersion.getBranch()))
- {
- // Use available
- out.writeBoolean(true);
- }
- else
- {
- out.writeBoolean(false);
- super.writeRevision(out, referenceChunk);
- }
- }
-
- @Override
- protected void readRevision(CDODataInput in) throws IOException
- {
- boolean useAvailable = in.readBoolean();
- if (useAvailable)
- {
- setResult((InternalCDORevision)availableBranchVersion);
- }
- else
- {
- super.readRevision(in);
- }
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static class Normal extends Available
- {
- public Normal(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion)
- {
- super(id, requestedBranchPoint, availableBranchVersion);
- }
-
- private Normal(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException
- {
- super(in, requestedBranchPoint);
- }
-
- @Override
- public Type getType()
- {
- return Type.AVAILABLE_NORMAL;
- }
-
- @Override
- public InternalCDORevision getResult()
- {
- if (isDirect())
- {
- CDOBranchVersion branchVersion = getAvailableBranchVersion();
- if (branchVersion instanceof InternalCDORevision)
- {
- return (InternalCDORevision)branchVersion;
- }
- }
-
- return super.getResult();
- }
-
- @Override
- public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results,
- SyntheticCDORevision[] synthetics, int i)
- {
- if (!isLoadNeeded())
- {
- setResult((InternalCDORevision)getAvailableBranchVersion());
- }
-
- super.processResult(revisionManager, results, synthetics, i);
- }
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static class Pointer extends Available
- {
- private CDOBranchVersion targetBranchVersion;
-
- private boolean hasTarget;
-
- public Pointer(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion,
- CDOBranchVersion targetBranchVersion)
- {
- super(id, requestedBranchPoint, availableBranchVersion);
- this.targetBranchVersion = targetBranchVersion;
- hasTarget = targetBranchVersion instanceof InternalCDORevision;
- }
-
- private Pointer(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException
- {
- super(in, requestedBranchPoint);
- if (in.readBoolean())
- {
- targetBranchVersion = in.readCDOBranchVersion();
- hasTarget = in.readBoolean();
- }
- }
-
- public CDOBranchVersion getTargetBranchVersion()
- {
- return targetBranchVersion;
- }
-
- @Override
- public Type getType()
- {
- return Type.AVAILABLE_POINTER;
- }
-
- public boolean hasTarget()
- {
- return hasTarget;
- }
-
- @Override
- public boolean isLoadNeeded()
- {
- if (getRequestedBranchPoint().getBranch().isMainBranch())
- {
- return false;
- }
-
- return !isDirect() || !hasTarget();
- }
-
- @Override
- public void write(CDODataOutput out) throws IOException
- {
- super.write(out);
- if (targetBranchVersion != null)
- {
- out.writeBoolean(true);
- out.writeCDOBranchVersion(targetBranchVersion);
- out.writeBoolean(hasTarget);
- }
- else
- {
- out.writeBoolean(false);
- }
- }
-
- @Override
- public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results,
- SyntheticCDORevision[] synthetics, int i)
- {
- if (!isLoadNeeded())
- {
- CDOBranchVersion target = getTargetBranchVersion();
- if (target instanceof InternalCDORevision)
- {
- setResult((InternalCDORevision)target);
- }
-
- setSynthetic((PointerCDORevision)getAvailableBranchVersion());
- }
-
- super.processResult(revisionManager, results, synthetics, i);
- }
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static class Detached extends Available
- {
- public Detached(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion)
- {
- super(id, requestedBranchPoint, availableBranchVersion);
- }
-
- private Detached(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException
- {
- super(in, requestedBranchPoint);
- }
-
- @Override
- public Type getType()
- {
- return Type.AVAILABLE_DETACHED;
- }
-
- @Override
- public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results,
- SyntheticCDORevision[] synthetics, int i)
- {
- if (!isLoadNeeded())
- {
- setSynthetic((DetachedCDORevision)getAvailableBranchVersion());
- }
-
- super.processResult(revisionManager, results, synthetics, i);
- }
- }
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static class Missing extends RevisionInfo
- {
- public Missing(CDOID id, CDOBranchPoint requestedBranchPoint)
- {
- super(id, requestedBranchPoint);
- }
-
- private Missing(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException
- {
- super(in, requestedBranchPoint);
- }
-
- @Override
- public Type getType()
- {
- return Type.MISSING;
- }
-
- @Override
- public boolean isLoadNeeded()
- {
- return true;
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDORevision; + +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.ObjectUtil; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; + +import java.io.IOException; +import java.util.List; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public abstract class RevisionInfo +{ + private static final int NO_RESULT = 0; + + private static final int POINTER_RESULT = 1; + + private static final int DETACHED_RESULT = 2; + + private static final int NORMAL_RESULT = 3; + + private CDOID id; + + private CDOBranchPoint requestedBranchPoint; + + private InternalCDORevision result; + + private SyntheticCDORevision synthetic; + + protected RevisionInfo(CDOID id, CDOBranchPoint requestedBranchPoint) + { + CheckUtil.checkArg(requestedBranchPoint, "requestedBranchPoint"); + this.id = id; + this.requestedBranchPoint = requestedBranchPoint; + } + + protected RevisionInfo(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException + { + CheckUtil.checkArg(requestedBranchPoint, "requestedBranchPoint"); + id = in.readCDOID(); + this.requestedBranchPoint = requestedBranchPoint; + } + + public abstract Type getType(); + + public final CDOID getID() + { + return id; + } + + public final CDOBranchPoint getRequestedBranchPoint() + { + return requestedBranchPoint; + } + + public InternalCDORevision getResult() + { + return result; + } + + public void setResult(InternalCDORevision result) + { + this.result = result; + } + + public SyntheticCDORevision getSynthetic() + { + return synthetic; + } + + public void setSynthetic(SyntheticCDORevision synthetic) + { + this.synthetic = synthetic; + } + + public abstract boolean isLoadNeeded(); + + public void write(CDODataOutput out) throws IOException + { + out.writeByte(getType().ordinal()); + out.writeCDOID(getID()); + } + + public static RevisionInfo read(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException + { + byte ordinal = in.readByte(); + Type type = Type.values()[ordinal]; + switch (type) + { + case AVAILABLE_NORMAL: + return new Available.Normal(in, requestedBranchPoint); + + case AVAILABLE_POINTER: + return new Available.Pointer(in, requestedBranchPoint); + + case AVAILABLE_DETACHED: + return new Available.Detached(in, requestedBranchPoint); + + case MISSING: + return new Missing(in, requestedBranchPoint); + + default: + throw new IOException("Invalid revision info type: " + type); + } + } + + public void execute(InternalCDORevisionManager revisionManager, int referenceChunk) + { + SyntheticCDORevision[] synthetics = new SyntheticCDORevision[1]; + result = revisionManager.getRevision(getID(), requestedBranchPoint, referenceChunk, CDORevision.DEPTH_NONE, true, + synthetics); + synthetic = synthetics[0]; + } + + /** + * @deprecated Not called anymore by the framework + */ + @Deprecated + public void writeResult(CDODataOutput out, int referenceChunk) throws IOException + { + writeResult(out, referenceChunk, null); + } + + /** + * @since 4.1 + */ + public void writeResult(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext) throws IOException + { + writeRevision(out, referenceChunk, securityContext); + writeResult(out, synthetic, referenceChunk, securityContext); + } + + public void readResult(CDODataInput in) throws IOException + { + readRevision(in); + synthetic = (SyntheticCDORevision)readResult(in, getID(), requestedBranchPoint.getBranch()); + } + + public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results, + SyntheticCDORevision[] synthetics, int i) + { + if (result instanceof DetachedCDORevision) + { + results.add(null); + } + else + { + results.add(result); + } + + if (result != null) + { + revisionManager.addRevision(result); + } + + if (synthetic != null) + { + revisionManager.addRevision(synthetic); + if (synthetic instanceof PointerCDORevision) + { + PointerCDORevision pointer = (PointerCDORevision)synthetic; + CDOBranchVersion target = pointer.getTarget(); + if (target != result && target instanceof InternalCDORevision) + { + revisionManager.addRevision((CDORevision)target); + } + } + + if (synthetics != null) + { + synthetics[i] = synthetic; + } + } + } + + /** + * @deprecated Not called anymore by the framework + */ + @Deprecated + protected void writeRevision(CDODataOutput out, int referenceChunk) throws IOException + { + writeRevision(out, referenceChunk, null); + } + + /** + * @since 4.1 + */ + protected void writeRevision(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext) + throws IOException + { + out.writeCDORevision(result, referenceChunk, securityContext); + } + + protected void readRevision(CDODataInput in) throws IOException + { + result = (InternalCDORevision)in.readCDORevision(); + } + + /** + * @since 4.0 + * @deprecated Call {@link #writeResult(CDODataOutput, InternalCDORevision, int, CDOBranchPoint)} + */ + @Deprecated + public static void writeResult(CDODataOutput out, InternalCDORevision revision, int referenceChunk) + throws IOException + { + writeResult(out, revision, referenceChunk, null); + } + + /** + * @since 4.1 + */ + public static void writeResult(CDODataOutput out, InternalCDORevision revision, int referenceChunk, + CDOBranchPoint securityContext) throws IOException + { + if (revision == null) + { + out.writeByte(NO_RESULT); + } + else if (revision instanceof PointerCDORevision) + { + PointerCDORevision pointer = (PointerCDORevision)revision; + out.writeByte(POINTER_RESULT); + out.writeCDOClassifierRef(pointer.getEClass()); + out.writeLong(pointer.getRevised()); + + CDOBranchVersion target = pointer.getTarget(); + if (target instanceof InternalCDORevision) + { + writeResult(out, (InternalCDORevision)target, referenceChunk, securityContext); + } + else + { + out.writeByte(NO_RESULT); + } + } + else if (revision instanceof DetachedCDORevision) + { + DetachedCDORevision detached = (DetachedCDORevision)revision; + out.writeByte(DETACHED_RESULT); + out.writeCDOClassifierRef(detached.getEClass()); + out.writeLong(detached.getTimeStamp()); + out.writeLong(detached.getRevised()); + out.writeInt(detached.getVersion()); + } + else + { + out.writeByte(NORMAL_RESULT); + out.writeCDORevision(revision, referenceChunk, securityContext); + } + } + + /** + * @since 4.0 + */ + public static InternalCDORevision readResult(CDODataInput in, CDOID id, CDOBranch branch) throws IOException + { + byte type = in.readByte(); + switch (type) + { + case NO_RESULT: + return null; + + case POINTER_RESULT: + { + EClassifier classifier = in.readCDOClassifierRefAndResolve(); + long revised = in.readLong(); + InternalCDORevision target = readResult(in, id, branch); + return new PointerCDORevision((EClass)classifier, id, branch, revised, target); + } + + case DETACHED_RESULT: + { + EClassifier classifier = in.readCDOClassifierRefAndResolve(); + long timeStamp = in.readLong(); + long revised = in.readLong(); + int version = in.readInt(); + return new DetachedCDORevision((EClass)classifier, id, branch, version, timeStamp, revised); + } + + case NORMAL_RESULT: + return (InternalCDORevision)in.readCDORevision(); + + default: + throw new IllegalStateException("Invalid synthetic type: " + type); + } + } + + /** + * @deprecated Not called anymore by the framework + */ + @Deprecated + protected void doWriteResult(CDODataOutput out, InternalCDORevision revision, int referenceChunk) throws IOException + { + throw new UnsupportedOperationException(); + } + + /** + * @deprecated Not called anymore by the framework + */ + @Deprecated + protected InternalCDORevision doReadResult(CDODataInput in) throws IOException + { + throw new UnsupportedOperationException(); + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static enum Type + { + AVAILABLE_NORMAL, AVAILABLE_POINTER, AVAILABLE_DETACHED, MISSING + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static abstract class Available extends RevisionInfo + { + private CDOBranchVersion availableBranchVersion; + + protected Available(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion) + { + super(id, requestedBranchPoint); + this.availableBranchVersion = availableBranchVersion; + } + + protected Available(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException + { + super(in, requestedBranchPoint); + availableBranchVersion = in.readCDOBranchVersion(); + } + + public CDOBranchVersion getAvailableBranchVersion() + { + return availableBranchVersion; + } + + public boolean isDirect() + { + return ObjectUtil.equals(availableBranchVersion.getBranch(), getRequestedBranchPoint().getBranch()); + } + + @Override + public boolean isLoadNeeded() + { + return !isDirect(); + } + + @Override + public void write(CDODataOutput out) throws IOException + { + super.write(out); + out.writeCDOBranchVersion(availableBranchVersion); + } + + @Override + protected void writeRevision(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext) + throws IOException + { + InternalCDORevision result = getResult(); + if (result != null && ObjectUtil.equals(result.getBranch(), availableBranchVersion.getBranch())) + { + // Use available + out.writeBoolean(true); + } + else + { + out.writeBoolean(false); + super.writeRevision(out, referenceChunk, securityContext); + } + } + + @Override + protected void readRevision(CDODataInput in) throws IOException + { + boolean useAvailable = in.readBoolean(); + if (useAvailable) + { + setResult((InternalCDORevision)availableBranchVersion); + } + else + { + super.readRevision(in); + } + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static class Normal extends Available + { + public Normal(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion) + { + super(id, requestedBranchPoint, availableBranchVersion); + } + + private Normal(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException + { + super(in, requestedBranchPoint); + } + + @Override + public Type getType() + { + return Type.AVAILABLE_NORMAL; + } + + @Override + public InternalCDORevision getResult() + { + if (isDirect()) + { + CDOBranchVersion branchVersion = getAvailableBranchVersion(); + if (branchVersion instanceof InternalCDORevision) + { + return (InternalCDORevision)branchVersion; + } + } + + return super.getResult(); + } + + @Override + public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results, + SyntheticCDORevision[] synthetics, int i) + { + if (!isLoadNeeded()) + { + setResult((InternalCDORevision)getAvailableBranchVersion()); + } + + super.processResult(revisionManager, results, synthetics, i); + } + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static class Pointer extends Available + { + private CDOBranchVersion targetBranchVersion; + + private boolean hasTarget; + + public Pointer(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion, + CDOBranchVersion targetBranchVersion) + { + super(id, requestedBranchPoint, availableBranchVersion); + this.targetBranchVersion = targetBranchVersion; + hasTarget = targetBranchVersion instanceof InternalCDORevision; + } + + private Pointer(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException + { + super(in, requestedBranchPoint); + if (in.readBoolean()) + { + targetBranchVersion = in.readCDOBranchVersion(); + hasTarget = in.readBoolean(); + } + } + + public CDOBranchVersion getTargetBranchVersion() + { + return targetBranchVersion; + } + + @Override + public Type getType() + { + return Type.AVAILABLE_POINTER; + } + + public boolean hasTarget() + { + return hasTarget; + } + + @Override + public boolean isLoadNeeded() + { + if (getRequestedBranchPoint().getBranch().isMainBranch()) + { + return false; + } + + return !isDirect() || !hasTarget(); + } + + @Override + public void write(CDODataOutput out) throws IOException + { + super.write(out); + if (targetBranchVersion != null) + { + out.writeBoolean(true); + out.writeCDOBranchVersion(targetBranchVersion); + out.writeBoolean(hasTarget); + } + else + { + out.writeBoolean(false); + } + } + + @Override + public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results, + SyntheticCDORevision[] synthetics, int i) + { + if (!isLoadNeeded()) + { + CDOBranchVersion target = getTargetBranchVersion(); + if (target instanceof InternalCDORevision) + { + setResult((InternalCDORevision)target); + } + + setSynthetic((PointerCDORevision)getAvailableBranchVersion()); + } + + super.processResult(revisionManager, results, synthetics, i); + } + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static class Detached extends Available + { + public Detached(CDOID id, CDOBranchPoint requestedBranchPoint, CDOBranchVersion availableBranchVersion) + { + super(id, requestedBranchPoint, availableBranchVersion); + } + + private Detached(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException + { + super(in, requestedBranchPoint); + } + + @Override + public Type getType() + { + return Type.AVAILABLE_DETACHED; + } + + @Override + public void processResult(InternalCDORevisionManager revisionManager, List<CDORevision> results, + SyntheticCDORevision[] synthetics, int i) + { + if (!isLoadNeeded()) + { + setSynthetic((DetachedCDORevision)getAvailableBranchVersion()); + } + + super.processResult(revisionManager, results, synthetics, i); + } + } + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static class Missing extends RevisionInfo + { + public Missing(CDOID id, CDOBranchPoint requestedBranchPoint) + { + super(id, requestedBranchPoint); + } + + private Missing(CDODataInput in, CDOBranchPoint requestedBranchPoint) throws IOException + { + super(in, requestedBranchPoint); + } + + @Override + public Type getType() + { + return Type.MISSING; + } + + @Override + public boolean isLoadNeeded() + { + return true; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java index 7fa13aab4d..b2eb6e3e5e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java @@ -142,6 +142,14 @@ public class StubCDORevision extends AbstractCDORevision throw new UnsupportedOperationException(getExceptionMessage()); } + /** + * @since 4.1 + */ + public void write(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext) throws IOException + { + throw new UnsupportedOperationException(getExceptionMessage()); + } + public void convertEObjects(CDOIDProvider oidProvider) { throw new UnsupportedOperationException(getExceptionMessage()); diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionsRequest.java index 26cfc4bd48..214e370118 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionsRequest.java @@ -1,173 +1,173 @@ -/*
- * Copyright (c) 2004 - 2012 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.util.CDOFetchRule;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-import org.eclipse.emf.cdo.view.CDOFetchRuleManager;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class LoadRevisionsRequest extends CDOClientRequest<List<InternalCDORevision>>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionsRequest.class);
-
- private List<RevisionInfo> infos;
-
- private CDOBranchPoint branchPoint;
-
- private int referenceChunk;
-
- private int prefetchDepth;
-
- public LoadRevisionsRequest(CDOClientProtocol protocol, List<RevisionInfo> infos, CDOBranchPoint branchPoint,
- int referenceChunk, int prefetchDepth)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISIONS);
- this.infos = infos;
- this.branchPoint = branchPoint;
- this.referenceChunk = referenceChunk;
- this.prefetchDepth = prefetchDepth;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing branchPoint: {0}", branchPoint); //$NON-NLS-1$
- }
-
- out.writeCDOBranchPoint(branchPoint);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing referenceChunk: {0}", referenceChunk); //$NON-NLS-1$
- }
-
- out.writeInt(referenceChunk);
- int size = infos.size();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} infos", size); //$NON-NLS-1$
- }
-
- if (prefetchDepth == 0)
- {
- out.writeInt(size);
- }
- else
- {
- out.writeInt(-size);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing prefetchDepth: {0}", prefetchDepth); //$NON-NLS-1$
- }
-
- out.writeInt(prefetchDepth);
- }
-
- Collection<CDOID> ids = new ArrayList<CDOID>(size);
- for (RevisionInfo info : infos)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing info: {0}", info); //$NON-NLS-1$
- }
-
- info.write(out);
- ids.add(info.getID());
- }
-
- CDOFetchRuleManager ruleManager = getSession().getFetchRuleManager();
- CDOCollectionLoadingPolicy collectionLoadingPolicy = ruleManager.getCollectionLoadingPolicy();
- List<CDOFetchRule> fetchRules = ruleManager.getFetchRules(ids);
- if (fetchRules == null || fetchRules.size() <= 0)
- {
- out.writeInt(0);
- }
- else
- {
- // At this point, fetch size is more than one.
- int fetchSize = fetchRules.size();
- CDOID contextID = ruleManager.getContext();
-
- out.writeInt(fetchSize);
- out.writeInt(collectionLoadingPolicy != null ? collectionLoadingPolicy.getInitialChunkSize()
- : CDORevision.UNCHUNKED);
- out.writeCDOID(contextID);
-
- for (CDOFetchRule fetchRule : fetchRules)
- {
- fetchRule.write(out);
- }
- }
- }
-
- @Override
- protected List<InternalCDORevision> confirming(CDODataInput in) throws IOException
- {
- int size = infos.size();
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} revisions", size); //$NON-NLS-1$
- }
-
- for (RevisionInfo info : infos)
- {
- info.readResult(in);
- }
-
- List<InternalCDORevision> additionalRevisions = null;
- int additionalSize = in.readInt();
- if (additionalSize != 0)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} additional revisions", additionalSize); //$NON-NLS-1$
- }
-
- additionalRevisions = new ArrayList<InternalCDORevision>(additionalSize);
- for (int i = 0; i < additionalSize; i++)
- {
- InternalCDORevision revision = (InternalCDORevision)in.readCDORevision();
- additionalRevisions.add(revision);
- }
- }
-
- return additionalRevisions;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format(
- "LoadRevisionsRequest(infos={0}, branchPoint={1}, referenceChunk={2}, prefetchDepth={3})", infos, branchPoint,
- referenceChunk, prefetchDepth);
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.util.CDOFetchRule; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo; +import org.eclipse.emf.cdo.view.CDOFetchRuleManager; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class LoadRevisionsRequest extends CDOClientRequest<List<InternalCDORevision>> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionsRequest.class); + + private List<RevisionInfo> infos; + + private CDOBranchPoint branchPoint; + + private int referenceChunk; + + private int prefetchDepth; + + public LoadRevisionsRequest(CDOClientProtocol protocol, List<RevisionInfo> infos, CDOBranchPoint branchPoint, + int referenceChunk, int prefetchDepth) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISIONS); + this.infos = infos; + this.branchPoint = branchPoint; + this.referenceChunk = referenceChunk; + this.prefetchDepth = prefetchDepth; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.format("Writing branchPoint: {0}", branchPoint); //$NON-NLS-1$ + } + + out.writeCDOBranchPoint(branchPoint); + if (TRACER.isEnabled()) + { + TRACER.format("Writing referenceChunk: {0}", referenceChunk); //$NON-NLS-1$ + } + + out.writeInt(referenceChunk); + int size = infos.size(); + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} infos", size); //$NON-NLS-1$ + } + + if (prefetchDepth == 0) + { + out.writeInt(size); + } + else + { + out.writeInt(-size); + if (TRACER.isEnabled()) + { + TRACER.format("Writing prefetchDepth: {0}", prefetchDepth); //$NON-NLS-1$ + } + + out.writeInt(prefetchDepth); + } + + Collection<CDOID> ids = new ArrayList<CDOID>(size); + for (RevisionInfo info : infos) + { + if (TRACER.isEnabled()) + { + TRACER.format("Writing info: {0}", info); //$NON-NLS-1$ + } + + info.write(out); + ids.add(info.getID()); + } + + CDOFetchRuleManager ruleManager = getSession().getFetchRuleManager(); + CDOCollectionLoadingPolicy collectionLoadingPolicy = ruleManager.getCollectionLoadingPolicy(); + List<CDOFetchRule> fetchRules = ruleManager.getFetchRules(ids); + if (fetchRules == null || fetchRules.size() <= 0) + { + out.writeInt(0); + } + else + { + // At this point, fetch size is more than one. + int fetchSize = fetchRules.size(); + CDOID contextID = ruleManager.getContext(); + + out.writeInt(fetchSize); + out.writeInt(collectionLoadingPolicy != null ? collectionLoadingPolicy.getInitialChunkSize() + : CDORevision.UNCHUNKED); + out.writeCDOID(contextID); + + for (CDOFetchRule fetchRule : fetchRules) + { + fetchRule.write(out); + } + } + } + + @Override + protected List<InternalCDORevision> confirming(CDODataInput in) throws IOException + { + int size = infos.size(); + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} revisions", size); //$NON-NLS-1$ + } + + for (RevisionInfo info : infos) + { + info.readResult(in); + } + + List<InternalCDORevision> additionalRevisions = null; + int additionalSize = in.readInt(); + if (additionalSize != 0) + { + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} additional revisions", additionalSize); //$NON-NLS-1$ + } + + additionalRevisions = new ArrayList<InternalCDORevision>(additionalSize); + for (int i = 0; i < additionalSize; i++) + { + InternalCDORevision revision = (InternalCDORevision)in.readCDORevision(); + additionalRevisions.add(revision); + } + } + + return additionalRevisions; + } + + @Override + public String toString() + { + return MessageFormat.format( + "LoadRevisionsRequest(infos={0}, branchPoint={1}, referenceChunk={2}, prefetchDepth={3})", infos, branchPoint, + referenceChunk, prefetchDepth); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryRequest.java index 9e7e5d4eb9..59fde5d9bc 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryRequest.java @@ -1,113 +1,113 @@ -/*
- * Copyright (c) 2004 - 2012 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.id.CDOIDReference;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.util.CDOQueryQueue;
-import org.eclipse.emf.cdo.internal.common.CDOQueryInfoImpl;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.object.CDOObjectReferenceImpl;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class QueryRequest extends CDOClientRequest<Boolean>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryRequest.class);
-
- private CDOView view;
-
- private AbstractQueryIterator<?> queryResult;
-
- public QueryRequest(CDOClientProtocol protocol, CDOView view, AbstractQueryIterator<?> queryResult)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_QUERY);
- this.view = view;
- this.queryResult = queryResult;
- }
-
- @Override
- protected CDOIDProvider getIDProvider()
- {
- return (InternalCDOView)view;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(view.getViewID());
- ((CDOQueryInfoImpl)queryResult.getQueryInfo()).write(out);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- int queryID = in.readInt();
- queryResult.setQueryID(queryID);
- CDOQueryQueue<Object> resultQueue = queryResult.getQueue();
-
- boolean xrefs = queryResult.getQueryInfo().getQueryLanguage().equals(CDOProtocolConstants.QUERY_LANGUAGE_XREFS);
-
- try
- {
- int numberOfObjectsReceived = 0;
- while (in.readBoolean())
- {
- Object element;
- if (xrefs)
- {
- CDOIDReference delegate = in.readCDOIDReference();
- element = new CDOObjectReferenceImpl(view, delegate);
- }
- else
- {
- element = in.readCDORevisionOrPrimitive();
- }
-
- resultQueue.add(element);
- numberOfObjectsReceived++;
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Query executed [{0} elements received]", numberOfObjectsReceived); //$NON-NLS-1$
- }
- }
- catch (RuntimeException ex)
- {
- resultQueue.setException(ex);
- }
- catch (Throwable throwable)
- {
- resultQueue.setException(new RuntimeException(throwable.getMessage(), throwable));
- }
- finally
- {
- resultQueue.close();
- }
-
- return true;
- }
-}
+/* + * Copyright (c) 2004 - 2012 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.id.CDOIDReference; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.util.CDOQueryQueue; +import org.eclipse.emf.cdo.internal.common.CDOQueryInfoImpl; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.internal.cdo.object.CDOObjectReferenceImpl; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.spi.cdo.AbstractQueryIterator; +import org.eclipse.emf.spi.cdo.InternalCDOView; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class QueryRequest extends CDOClientRequest<Boolean> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryRequest.class); + + private CDOView view; + + private AbstractQueryIterator<?> queryResult; + + public QueryRequest(CDOClientProtocol protocol, CDOView view, AbstractQueryIterator<?> queryResult) + { + super(protocol, CDOProtocolConstants.SIGNAL_QUERY); + this.view = view; + this.queryResult = queryResult; + } + + @Override + protected CDOIDProvider getIDProvider() + { + return (InternalCDOView)view; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(view.getViewID()); + ((CDOQueryInfoImpl)queryResult.getQueryInfo()).write(out); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + int queryID = in.readInt(); + queryResult.setQueryID(queryID); + CDOQueryQueue<Object> resultQueue = queryResult.getQueue(); + + boolean xrefs = queryResult.getQueryInfo().getQueryLanguage().equals(CDOProtocolConstants.QUERY_LANGUAGE_XREFS); + + try + { + int numberOfObjectsReceived = 0; + while (in.readBoolean()) + { + Object element; + if (xrefs) + { + CDOIDReference delegate = in.readCDOIDReference(); + element = new CDOObjectReferenceImpl(view, delegate); + } + else + { + element = in.readCDORevisionOrPrimitive(); + } + + resultQueue.add(element); + numberOfObjectsReceived++; + } + + if (TRACER.isEnabled()) + { + TRACER.format("Query executed [{0} elements received]", numberOfObjectsReceived); //$NON-NLS-1$ + } + } + catch (RuntimeException ex) + { + resultQueue.setException(ex); + } + catch (Throwable throwable) + { + resultQueue.setException(new RuntimeException(throwable.getMessage(), throwable)); + } + finally + { + resultQueue.close(); + } + + return true; + } +} diff --git a/plugins/org.eclipse.emf.cdo.security/build.properties b/plugins/org.eclipse.emf.cdo.security/build.properties index 7113f16d6d..e99fa8da5c 100644 --- a/plugins/org.eclipse.emf.cdo.security/build.properties +++ b/plugins/org.eclipse.emf.cdo.security/build.properties @@ -6,7 +6,8 @@ bin.includes = .,\ plugin.xml,\ plugin.properties,\ about.html,\ - copyright.txt + copyright.txt,\ + .options jars.compile.order = . source.. = src/ output.. = bin/ diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/RealmUtil.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/RealmUtil.java new file mode 100644 index 0000000000..71adfd8190 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/RealmUtil.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2004 - 2012 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.security; + +import org.eclipse.net4j.util.ObjectUtil; + +import org.eclipse.emf.common.util.EList; + +/** + * Various static helper methods for dealing with {@link Realm realms}. + * + * @author Eike Stepper + */ +public final class RealmUtil +{ + private RealmUtil() + { + } + + public static User findUser(EList<SecurityItem> items, String userID) + { + for (SecurityItem item : items) + { + if (item instanceof User) + { + User user = (User)item; + if (ObjectUtil.equals(user.getId(), userID)) + { + return user; + } + } + else if (item instanceof Directory) + { + Directory directory = (Directory)item; + User user = findUser(directory.getItems(), userID); + if (user != null) + { + return user; + } + } + } + + return null; + } + + public static Group findGroup(EList<SecurityItem> items, String groupID) + { + for (SecurityItem item : items) + { + if (item instanceof Group) + { + Group group = (Group)item; + if (ObjectUtil.equals(group.getId(), groupID)) + { + return group; + } + } + else if (item instanceof Directory) + { + Directory directory = (Directory)item; + Group group = findGroup(directory.getItems(), groupID); + if (group != null) + { + return group; + } + } + } + + return null; + } + + public static Role findRole(EList<SecurityItem> items, String roleID) + { + for (SecurityItem item : items) + { + if (item instanceof Role) + { + Role role = (Role)item; + if (ObjectUtil.equals(role.getId(), roleID)) + { + return role; + } + } + else if (item instanceof Directory) + { + Directory directory = (Directory)item; + Role role = findRole(directory.getItems(), roleID); + if (role != null) + { + return role; + } + } + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java index 1483022dec..c25c590013 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java @@ -1,39 +1,39 @@ -/*
- * Copyright (c) 2004 - 2012 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 233490
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class CommitNotificationRequest extends CDOServerRequest
-{
- private CDOCommitInfo commitInfo;
-
- public CommitNotificationRequest(CDOServerProtocol serverProtocol, CDOCommitInfo commitInfo)
- {
- super(serverProtocol, CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION);
- this.commitInfo = commitInfo;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeCDOCommitInfo(commitInfo);
- }
-}
+/* + * Copyright (c) 2004 - 2012 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 233490 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class CommitNotificationRequest extends CDOServerRequest +{ + private CDOCommitInfo commitInfo; + + public CommitNotificationRequest(CDOServerProtocol serverProtocol, CDOCommitInfo commitInfo) + { + super(serverProtocol, CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION); + this.commitInfo = commitInfo; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeCDOCommitInfo(commitInfo); // Exposes revision to client side + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/HandleRevisionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/HandleRevisionsIndication.java index c780c56ee6..8b17fc836c 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/HandleRevisionsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/HandleRevisionsIndication.java @@ -1,132 +1,132 @@ -/*
- * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class HandleRevisionsIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, HandleRevisionsIndication.class);
-
- private EClass eClass;
-
- private CDOBranch branch;
-
- private boolean exactBranch;
-
- private long timeStamp;
-
- private boolean exactTime;
-
- public HandleRevisionsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_HANDLE_REVISIONS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- if (in.readBoolean())
- {
- eClass = (EClass)in.readCDOClassifierRefAndResolve();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read eClass: {0}", eClass); //$NON-NLS-1$
- }
- }
-
- if (in.readBoolean())
- {
- branch = in.readCDOBranch();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read branch: {0}", branch); //$NON-NLS-1$
- }
-
- exactBranch = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read exactBranch: {0}", exactBranch); //$NON-NLS-1$
- }
- }
-
- timeStamp = in.readLong();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read timeStamp: {0}", CDOCommonUtil.formatTimeStamp(timeStamp)); //$NON-NLS-1$
- }
-
- exactTime = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read exactTime: {0}", exactTime); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void responding(final CDODataOutput out) throws IOException
- {
- final IOException[] ioException = { null };
- final RuntimeException[] runtimeException = { null };
-
- getRepository().handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime,
- new CDORevisionHandler.Filtered.Undetached(new CDORevisionHandler()
- {
- public boolean handleRevision(CDORevision revision)
- {
- try
- {
- out.writeBoolean(true);
- out.writeCDORevision(revision, CDORevision.UNCHUNKED);
- return true;
- }
- catch (IOException ex)
- {
- ioException[0] = ex;
- }
- catch (RuntimeException ex)
- {
- runtimeException[0] = ex;
- }
-
- return false;
- }
- }));
-
- if (ioException[0] != null)
- {
- throw ioException[0];
- }
-
- if (runtimeException[0] != null)
- {
- throw runtimeException[0];
- }
-
- out.writeBoolean(false);
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class HandleRevisionsIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, HandleRevisionsIndication.class); + + private EClass eClass; + + private CDOBranch branch; + + private boolean exactBranch; + + private long timeStamp; + + private boolean exactTime; + + public HandleRevisionsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_HANDLE_REVISIONS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + if (in.readBoolean()) + { + eClass = (EClass)in.readCDOClassifierRefAndResolve(); + if (TRACER.isEnabled()) + { + TRACER.format("Read eClass: {0}", eClass); //$NON-NLS-1$ + } + } + + if (in.readBoolean()) + { + branch = in.readCDOBranch(); + if (TRACER.isEnabled()) + { + TRACER.format("Read branch: {0}", branch); //$NON-NLS-1$ + } + + exactBranch = in.readBoolean(); + if (TRACER.isEnabled()) + { + TRACER.format("Read exactBranch: {0}", exactBranch); //$NON-NLS-1$ + } + } + + timeStamp = in.readLong(); + if (TRACER.isEnabled()) + { + TRACER.format("Read timeStamp: {0}", CDOCommonUtil.formatTimeStamp(timeStamp)); //$NON-NLS-1$ + } + + exactTime = in.readBoolean(); + if (TRACER.isEnabled()) + { + TRACER.format("Read exactTime: {0}", exactTime); //$NON-NLS-1$ + } + } + + @Override + protected void responding(final CDODataOutput out) throws IOException + { + final IOException[] ioException = { null }; + final RuntimeException[] runtimeException = { null }; + + getRepository().handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, + new CDORevisionHandler.Filtered.Undetached(new CDORevisionHandler() + { + public boolean handleRevision(CDORevision revision) + { + try + { + out.writeBoolean(true); + out.writeCDORevision(revision, CDORevision.UNCHUNKED); // Exposes revision to client side + return true; + } + catch (IOException ex) + { + ioException[0] = ex; + } + catch (RuntimeException ex) + { + runtimeException[0] = ex; + } + + return false; + } + })); + + if (ioException[0] != null) + { + throw ioException[0]; + } + + if (runtimeException[0] != null) + { + throw runtimeException[0]; + } + + out.writeBoolean(false); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChangeSetsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChangeSetsIndication.java index 4f357b42c1..decf5cfe86 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChangeSetsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChangeSetsIndication.java @@ -1,61 +1,61 @@ -/*
- * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadChangeSetsIndication extends CDOServerReadIndication
-{
- private CDOBranchPointRange[] ranges;
-
- public LoadChangeSetsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHANGE_SETS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int size = in.readInt();
- ranges = new CDOBranchPointRange[size];
- for (int i = 0; i < ranges.length; i++)
- {
- CDOBranchPoint startPoint = in.readCDOBranchPoint();
- CDOBranchPoint endPoint = in.readCDOBranchPoint();
- ranges[i] = CDOBranchUtil.createRange(startPoint, endPoint);
- }
- }
-
- @Override
- protected void responding(final CDODataOutput out) throws IOException
- {
- InternalRepository repository = getRepository();
- for (CDOBranchPointRange range : ranges)
- {
- CDOBranchPoint startPoint = range.getStartPoint();
- CDOBranchPoint endPoint = range.getEndPoint();
- CDOChangeSetData data = repository.getChangeSet(startPoint, endPoint);
- out.writeCDOChangeSetData(data);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadChangeSetsIndication extends CDOServerReadIndication +{ + private CDOBranchPointRange[] ranges; + + public LoadChangeSetsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHANGE_SETS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int size = in.readInt(); + ranges = new CDOBranchPointRange[size]; + for (int i = 0; i < ranges.length; i++) + { + CDOBranchPoint startPoint = in.readCDOBranchPoint(); + CDOBranchPoint endPoint = in.readCDOBranchPoint(); + ranges[i] = CDOBranchUtil.createRange(startPoint, endPoint); + } + } + + @Override + protected void responding(final CDODataOutput out) throws IOException + { + InternalRepository repository = getRepository(); + for (CDOBranchPointRange range : ranges) + { + CDOBranchPoint startPoint = range.getStartPoint(); + CDOBranchPoint endPoint = range.getEndPoint(); + CDOChangeSetData data = repository.getChangeSet(startPoint, endPoint); + out.writeCDOChangeSetData(data); // Exposes revision to client side + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitDataIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitDataIndication.java index b9d9a679c5..d9ce7afcdb 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitDataIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitDataIndication.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadCommitDataIndication extends CDOServerReadIndication
-{
- private long timeStamp;
-
- public LoadCommitDataIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_DATA);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- timeStamp = in.readLong();
- }
-
- @Override
- protected void responding(final CDODataOutput out) throws IOException
- {
- CDOCommitData commitData = getRepository().loadCommitData(timeStamp);
- out.writeCDOCommitData(commitData);
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.commit.CDOCommitData; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadCommitDataIndication extends CDOServerReadIndication +{ + private long timeStamp; + + public LoadCommitDataIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_DATA); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + timeStamp = in.readLong(); + } + + @Override + protected void responding(final CDODataOutput out) throws IOException + { + CDOCommitData commitData = getRepository().loadCommitData(timeStamp); + out.writeCDOCommitData(commitData); // Exposes revision to client side + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadMergeDataIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadMergeDataIndication.java index a1c43571e5..77cdc3c5a4 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadMergeDataIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadMergeDataIndication.java @@ -1,184 +1,184 @@ -/*
- * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class LoadMergeDataIndication extends CDOServerReadIndicationWithMonitoring
-{
- private int infos;
-
- private CDORevisionAvailabilityInfo targetInfo;
-
- private CDORevisionAvailabilityInfo sourceInfo;
-
- private CDORevisionAvailabilityInfo targetBaseInfo;
-
- private CDORevisionAvailabilityInfo sourceBaseInfo;
-
- public LoadMergeDataIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_MERGE_DATA);
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
- {
- infos = in.readInt();
- monitor.begin(infos);
-
- try
- {
- targetInfo = readRevisionAvailabilityInfo(in, monitor.fork());
- sourceInfo = readRevisionAvailabilityInfo(in, monitor.fork());
-
- if (infos > 2)
- {
- targetBaseInfo = readRevisionAvailabilityInfo(in, monitor.fork());
- }
-
- if (infos > 3)
- {
- sourceBaseInfo = readRevisionAvailabilityInfo(in, monitor.fork());
- }
- }
- finally
- {
- monitor.done();
- }
- }
-
- private CDORevisionAvailabilityInfo readRevisionAvailabilityInfo(CDODataInput in, OMMonitor monitor)
- throws IOException
- {
- CDOBranchPoint branchPoint = in.readCDOBranchPoint();
- CDORevisionAvailabilityInfo info = new CDORevisionAvailabilityInfo(branchPoint);
-
- int size = in.readInt();
- monitor.begin(size);
-
- try
- {
- for (int i = 0; i < size; i++)
- {
- CDOID id = in.readCDOID();
- info.getAvailableRevisions().put(id, null);
- monitor.worked();
- }
-
- return info;
- }
- finally
- {
- monitor.done();
- }
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- monitor.begin(2 + infos);
-
- try
- {
- InternalRepository repository = getRepository();
- Set<CDOID> ids = repository.getMergeData(targetInfo, sourceInfo, targetBaseInfo, sourceBaseInfo, monitor.fork());
-
- out.writeInt(ids.size());
- for (CDOID id : ids)
- {
- out.writeCDOID(id);
- }
-
- monitor.worked();
-
- Set<CDORevisionKey> writtenRevisions = new HashSet<CDORevisionKey>();
- writeRevisionAvailabilityInfo(out, targetInfo, writtenRevisions, monitor.fork());
- writeRevisionAvailabilityInfo(out, sourceInfo, writtenRevisions, monitor.fork());
-
- if (infos > 2)
- {
- writeRevisionAvailabilityInfo(out, targetBaseInfo, writtenRevisions, monitor.fork());
- }
-
- if (infos > 3)
- {
- writeRevisionAvailabilityInfo(out, sourceBaseInfo, writtenRevisions, monitor.fork());
- }
- }
- finally
- {
- monitor.done();
- }
- }
-
- private void writeRevisionAvailabilityInfo(final CDODataOutput out, CDORevisionAvailabilityInfo info,
- Set<CDORevisionKey> writtenRevisions, OMMonitor monitor) throws IOException
- {
- Collection<CDORevisionKey> revisions = info.getAvailableRevisions().values();
- for (Iterator<CDORevisionKey> it = revisions.iterator(); it.hasNext();)
- {
- CDORevisionKey key = it.next();
- if (key == null)
- {
- it.remove();
- }
- }
-
- int size = revisions.size();
- out.writeInt(size);
- monitor.begin(size);
-
- try
- {
- for (CDORevisionKey revision : revisions)
- {
- CDORevisionKey key = CDORevisionUtil.copyRevisionKey(revision);
- if (writtenRevisions.add(key))
- {
- out.writeBoolean(true);
- out.writeCDORevision((CDORevision)revision, CDORevision.UNCHUNKED);
- }
- else
- {
- out.writeBoolean(false);
- out.writeCDORevisionKey(key);
- }
-
- monitor.worked();
- }
- }
- finally
- {
- monitor.done();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; +import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import java.io.IOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class LoadMergeDataIndication extends CDOServerReadIndicationWithMonitoring +{ + private int infos; + + private CDORevisionAvailabilityInfo targetInfo; + + private CDORevisionAvailabilityInfo sourceInfo; + + private CDORevisionAvailabilityInfo targetBaseInfo; + + private CDORevisionAvailabilityInfo sourceBaseInfo; + + public LoadMergeDataIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_MERGE_DATA); + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception + { + infos = in.readInt(); + monitor.begin(infos); + + try + { + targetInfo = readRevisionAvailabilityInfo(in, monitor.fork()); + sourceInfo = readRevisionAvailabilityInfo(in, monitor.fork()); + + if (infos > 2) + { + targetBaseInfo = readRevisionAvailabilityInfo(in, monitor.fork()); + } + + if (infos > 3) + { + sourceBaseInfo = readRevisionAvailabilityInfo(in, monitor.fork()); + } + } + finally + { + monitor.done(); + } + } + + private CDORevisionAvailabilityInfo readRevisionAvailabilityInfo(CDODataInput in, OMMonitor monitor) + throws IOException + { + CDOBranchPoint branchPoint = in.readCDOBranchPoint(); + CDORevisionAvailabilityInfo info = new CDORevisionAvailabilityInfo(branchPoint); + + int size = in.readInt(); + monitor.begin(size); + + try + { + for (int i = 0; i < size; i++) + { + CDOID id = in.readCDOID(); + info.getAvailableRevisions().put(id, null); + monitor.worked(); + } + + return info; + } + finally + { + monitor.done(); + } + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception + { + monitor.begin(2 + infos); + + try + { + InternalRepository repository = getRepository(); + Set<CDOID> ids = repository.getMergeData(targetInfo, sourceInfo, targetBaseInfo, sourceBaseInfo, monitor.fork()); + + out.writeInt(ids.size()); + for (CDOID id : ids) + { + out.writeCDOID(id); + } + + monitor.worked(); + + Set<CDORevisionKey> writtenRevisions = new HashSet<CDORevisionKey>(); + writeRevisionAvailabilityInfo(out, targetInfo, writtenRevisions, monitor.fork()); + writeRevisionAvailabilityInfo(out, sourceInfo, writtenRevisions, monitor.fork()); + + if (infos > 2) + { + writeRevisionAvailabilityInfo(out, targetBaseInfo, writtenRevisions, monitor.fork()); + } + + if (infos > 3) + { + writeRevisionAvailabilityInfo(out, sourceBaseInfo, writtenRevisions, monitor.fork()); + } + } + finally + { + monitor.done(); + } + } + + private void writeRevisionAvailabilityInfo(final CDODataOutput out, CDORevisionAvailabilityInfo info, + Set<CDORevisionKey> writtenRevisions, OMMonitor monitor) throws IOException + { + Collection<CDORevisionKey> revisions = info.getAvailableRevisions().values(); + for (Iterator<CDORevisionKey> it = revisions.iterator(); it.hasNext();) + { + CDORevisionKey key = it.next(); + if (key == null) + { + it.remove(); + } + } + + int size = revisions.size(); + out.writeInt(size); + monitor.begin(size); + + try + { + for (CDORevisionKey revision : revisions) + { + CDORevisionKey key = CDORevisionUtil.copyRevisionKey(revision); + if (writtenRevisions.add(key)) + { + out.writeBoolean(true); + out.writeCDORevision((CDORevision)revision, CDORevision.UNCHUNKED); // Exposes revision to client side + } + else + { + out.writeBoolean(false); + out.writeCDORevisionKey(key); + } + + monitor.worked(); + } + } + finally + { + monitor.done(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionByVersionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionByVersionIndication.java index 6efc0014e6..7414de36d5 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionByVersionIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionByVersionIndication.java @@ -1,75 +1,75 @@ -/*
- * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadRevisionByVersionIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL,
- LoadRevisionByVersionIndication.class);
-
- private CDOID id;
-
- private CDOBranchVersion branchVersion;
-
- private int referenceChunk;
-
- public LoadRevisionByVersionIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_VERSION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- id = in.readCDOID();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read id: {0}", id); //$NON-NLS-1$
- }
-
- branchVersion = in.readCDOBranchVersion();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read branchVersion: {0}", branchVersion); //$NON-NLS-1$
- }
-
- referenceChunk = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read referenceChunk: {0}", referenceChunk); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- InternalCDORevisionManager revisionManager = getRepository().getRevisionManager();
- InternalCDORevision revision = revisionManager.getRevisionByVersion(id, branchVersion, referenceChunk, true);
- RevisionInfo.writeResult(out, revision, referenceChunk);
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; +import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadRevisionByVersionIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, + LoadRevisionByVersionIndication.class); + + private CDOID id; + + private CDOBranchVersion branchVersion; + + private int referenceChunk; + + public LoadRevisionByVersionIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_VERSION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + id = in.readCDOID(); + if (TRACER.isEnabled()) + { + TRACER.format("Read id: {0}", id); //$NON-NLS-1$ + } + + branchVersion = in.readCDOBranchVersion(); + if (TRACER.isEnabled()) + { + TRACER.format("Read branchVersion: {0}", branchVersion); //$NON-NLS-1$ + } + + referenceChunk = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.format("Read referenceChunk: {0}", referenceChunk); //$NON-NLS-1$ + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + InternalCDORevisionManager revisionManager = getRepository().getRevisionManager(); + InternalCDORevision revision = revisionManager.getRevisionByVersion(id, branchVersion, referenceChunk, true); + RevisionInfo.writeResult(out, revision, referenceChunk, null); // Exposes revision to client side + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java index c8ed75442b..f91d59e7f5 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java @@ -1,356 +1,356 @@ -/*
- * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.model.CDOClassInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.util.CDOFetchRule;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-
-import org.eclipse.net4j.util.collection.MoveableList;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class LoadRevisionsIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionsIndication.class);
-
- private RevisionInfo[] infos;
-
- private CDOBranchPoint branchPoint;
-
- private int referenceChunk;
-
- private int prefetchDepth;
-
- private Map<EClass, CDOFetchRule> fetchRules = new HashMap<EClass, CDOFetchRule>();
-
- private CDOID contextID = CDOID.NULL;
-
- private int loadRevisionCollectionChunkSize;
-
- public LoadRevisionsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISIONS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- branchPoint = in.readCDOBranchPoint();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read branchPoint: {0}", branchPoint); //$NON-NLS-1$
- }
-
- referenceChunk = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read referenceChunk: {0}", referenceChunk); //$NON-NLS-1$
- }
-
- int size = in.readInt();
- if (size < 0)
- {
- size = -size;
- prefetchDepth = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read prefetchDepth: {0}", prefetchDepth); //$NON-NLS-1$
- }
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} infos", size); //$NON-NLS-1$
- }
-
- infos = new RevisionInfo[size];
- for (int i = 0; i < size; i++)
- {
- RevisionInfo info = RevisionInfo.read(in, branchPoint);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read info: {0}", info); //$NON-NLS-1$
- }
-
- infos[i] = info;
- }
-
- int fetchSize = in.readInt();
- if (fetchSize > 0)
- {
- loadRevisionCollectionChunkSize = in.readInt();
- if (loadRevisionCollectionChunkSize < 1)
- {
- loadRevisionCollectionChunkSize = 1;
- }
-
- contextID = in.readCDOID();
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading fetch rules for context {0}", contextID); //$NON-NLS-1$
- }
-
- for (int i = 0; i < fetchSize; i++)
- {
- CDOFetchRule fetchRule = new CDOFetchRule(in, getRepository().getPackageRegistry());
- fetchRules.put(fetchRule.getEClass(), fetchRule);
- }
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- List<CDORevision> additionalRevisions = new ArrayList<CDORevision>();
- Set<CDOID> revisionIDs = new HashSet<CDOID>();
- int size = infos.length;
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} results", size); //$NON-NLS-1$
- }
-
- for (RevisionInfo info : infos)
- {
- revisionIDs.add(info.getID());
- }
-
- // Need to fetch the rule first.
- Set<CDOFetchRule> visitedFetchRules = new HashSet<CDOFetchRule>();
- if (!CDOIDUtil.isNull(contextID) && fetchRules.size() > 0)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Collecting more revisions based on rules"); //$NON-NLS-1$
- }
-
- InternalCDORevision revisionContext = getRevision(contextID);
- collectRevisions(revisionContext, revisionIDs, additionalRevisions, visitedFetchRules);
- }
-
- InternalCDORevisionManager revisionManager = getRepository().getRevisionManager();
- InternalCDORevision[] revisions = new InternalCDORevision[size];
- for (int i = 0; i < size; i++)
- {
- RevisionInfo info = infos[i];
- info.execute(revisionManager, referenceChunk);
- revisions[i] = info.getResult();
- if (loadRevisionCollectionChunkSize > 0)
- {
- collectRevisions(revisions[i], revisionIDs, additionalRevisions, visitedFetchRules);
- }
- }
-
- if (prefetchDepth != 0)
- {
- prefetchRevisions(prefetchDepth > 0 ? prefetchDepth : Integer.MAX_VALUE, revisions, additionalRevisions);
- }
-
- getRepository().notifyReadAccessHandlers(getSession(), revisions, additionalRevisions);
-
- for (int i = 0; i < size; i++)
- {
- RevisionInfo info = infos[i];
- info.setResult(revisions[i]);
- info.writeResult(out, referenceChunk);
- }
-
- int additionalSize = additionalRevisions.size();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} additional revisions", additionalSize); //$NON-NLS-1$
- }
-
- out.writeInt(additionalSize);
- for (CDORevision revision : additionalRevisions)
- {
- out.writeCDORevision(revision, referenceChunk);
- }
- }
-
- private InternalCDORevision getRevision(CDOID id)
- {
- return getRepository().getRevisionManager().getRevision(id, branchPoint, referenceChunk, CDORevision.DEPTH_NONE,
- true);
- }
-
- private void collectRevisions(InternalCDORevision revision, Set<CDOID> revisions,
- List<CDORevision> additionalRevisions, Set<CDOFetchRule> visitedFetchRules)
- {
- if (revision == null)
- {
- return;
- }
-
- getSession().collectContainedRevisions(revision, branchPoint, referenceChunk, revisions, additionalRevisions);
-
- CDOFetchRule fetchRule = fetchRules.get(revision.getEClass());
- if (fetchRule == null || visitedFetchRules.contains(fetchRule))
- {
- return;
- }
-
- visitedFetchRules.add(fetchRule);
-
- for (EStructuralFeature feature : fetchRule.getFeatures())
- {
- if (feature.isMany())
- {
- MoveableList<Object> list = revision.getList(feature);
- int toIndex = Math.min(loadRevisionCollectionChunkSize, list.size()) - 1;
- for (int i = 0; i <= toIndex; i++)
- {
- Object value = list.get(i);
- if (value instanceof CDOID)
- {
- CDOID id = (CDOID)value;
- if (!CDOIDUtil.isNull(id) && !revisions.contains(id))
- {
- InternalCDORevision containedRevision = getRevision(id);
- if (containedRevision != null)
- {
- revisions.add(containedRevision.getID());
- additionalRevisions.add(containedRevision);
- collectRevisions(containedRevision, revisions, additionalRevisions, visitedFetchRules);
- }
- }
- }
- }
- }
- else
- {
- Object value = revision.getValue(feature);
- if (value instanceof CDOID)
- {
- CDOID id = (CDOID)value;
- if (!id.isNull() && !revisions.contains(id))
- {
- InternalCDORevision containedRevision = getRevision(id);
- if (containedRevision != null)
- {
- revisions.add(containedRevision.getID());
- additionalRevisions.add(containedRevision);
- collectRevisions(containedRevision, revisions, additionalRevisions, visitedFetchRules);
- }
- }
- }
- }
- }
-
- visitedFetchRules.remove(fetchRule);
- }
-
- private void prefetchRevisions(int depth, CDORevision[] revisions, List<CDORevision> additionalRevisions)
- {
- Map<CDOID, CDORevision> map = new HashMap<CDOID, CDORevision>();
- for (CDORevision revision : revisions)
- {
- map.put(revision.getID(), revision);
- }
-
- for (CDORevision revision : additionalRevisions)
- {
- map.put(revision.getID(), revision);
- }
-
- for (CDORevision revision : revisions)
- {
- prefetchRevision(depth, (InternalCDORevision)revision, additionalRevisions, map);
- }
- }
-
- private void prefetchRevision(int depth, InternalCDORevision revision, List<CDORevision> additionalRevisions,
- Map<CDOID, CDORevision> map)
- {
- CDOClassInfo classInfo = revision.getClassInfo();
- for (EStructuralFeature feature : classInfo.getAllPersistentFeatures())
- {
- if (feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- Object value = revision.getValue(reference);
- if (value instanceof CDOID)
- {
- CDOID id = (CDOID)value;
- prefetchRevisionChild(depth, id, additionalRevisions, map);
- }
- else if (value instanceof Collection<?>)
- {
- Collection<?> c = (Collection<?>)value;
- for (Object e : c)
- {
- // If this revision was loaded with referenceChunk != UNCHUNKED, then
- // some elements might be uninitialized, i.e. not instanceof CDOID.
- // (See bug 339313.)
- if (e instanceof CDOID)
- {
- CDOID id = (CDOID)e;
- prefetchRevisionChild(depth, id, additionalRevisions, map);
- }
- }
- }
- }
- }
- }
- }
-
- private void prefetchRevisionChild(int depth, CDOID id, List<CDORevision> additionalRevisions,
- Map<CDOID, CDORevision> map)
- {
- if (CDOIDUtil.isNull(id))
- {
- return;
- }
-
- CDORevision child = map.get(id);
- if (child == null)
- {
- child = getRevision(id);
- if (child != null)
- {
- map.put(id, child);
- additionalRevisions.add(child);
- }
- }
-
- if (child != null && depth > 0)
- {
- prefetchRevision(depth - 1, (InternalCDORevision)child, additionalRevisions, map);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.model.CDOClassInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.util.CDOFetchRule; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; +import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo; + +import org.eclipse.net4j.util.collection.MoveableList; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class LoadRevisionsIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionsIndication.class); + + private RevisionInfo[] infos; + + private CDOBranchPoint branchPoint; + + private int referenceChunk; + + private int prefetchDepth; + + private Map<EClass, CDOFetchRule> fetchRules = new HashMap<EClass, CDOFetchRule>(); + + private CDOID contextID = CDOID.NULL; + + private int loadRevisionCollectionChunkSize; + + public LoadRevisionsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISIONS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + branchPoint = in.readCDOBranchPoint(); + if (TRACER.isEnabled()) + { + TRACER.format("Read branchPoint: {0}", branchPoint); //$NON-NLS-1$ + } + + referenceChunk = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.format("Read referenceChunk: {0}", referenceChunk); //$NON-NLS-1$ + } + + int size = in.readInt(); + if (size < 0) + { + size = -size; + prefetchDepth = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.format("Read prefetchDepth: {0}", prefetchDepth); //$NON-NLS-1$ + } + } + + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} infos", size); //$NON-NLS-1$ + } + + infos = new RevisionInfo[size]; + for (int i = 0; i < size; i++) + { + RevisionInfo info = RevisionInfo.read(in, branchPoint); + if (TRACER.isEnabled()) + { + TRACER.format("Read info: {0}", info); //$NON-NLS-1$ + } + + infos[i] = info; + } + + int fetchSize = in.readInt(); + if (fetchSize > 0) + { + loadRevisionCollectionChunkSize = in.readInt(); + if (loadRevisionCollectionChunkSize < 1) + { + loadRevisionCollectionChunkSize = 1; + } + + contextID = in.readCDOID(); + if (TRACER.isEnabled()) + { + TRACER.format("Reading fetch rules for context {0}", contextID); //$NON-NLS-1$ + } + + for (int i = 0; i < fetchSize; i++) + { + CDOFetchRule fetchRule = new CDOFetchRule(in, getRepository().getPackageRegistry()); + fetchRules.put(fetchRule.getEClass(), fetchRule); + } + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + List<CDORevision> additionalRevisions = new ArrayList<CDORevision>(); + Set<CDOID> revisionIDs = new HashSet<CDOID>(); + int size = infos.length; + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} results", size); //$NON-NLS-1$ + } + + for (RevisionInfo info : infos) + { + revisionIDs.add(info.getID()); + } + + // Need to fetch the rule first. + Set<CDOFetchRule> visitedFetchRules = new HashSet<CDOFetchRule>(); + if (!CDOIDUtil.isNull(contextID) && fetchRules.size() > 0) + { + if (TRACER.isEnabled()) + { + TRACER.format("Collecting more revisions based on rules"); //$NON-NLS-1$ + } + + InternalCDORevision revisionContext = getRevision(contextID); + collectRevisions(revisionContext, revisionIDs, additionalRevisions, visitedFetchRules); + } + + InternalCDORevisionManager revisionManager = getRepository().getRevisionManager(); + InternalCDORevision[] revisions = new InternalCDORevision[size]; + for (int i = 0; i < size; i++) + { + RevisionInfo info = infos[i]; + info.execute(revisionManager, referenceChunk); + revisions[i] = info.getResult(); + if (loadRevisionCollectionChunkSize > 0) + { + collectRevisions(revisions[i], revisionIDs, additionalRevisions, visitedFetchRules); + } + } + + if (prefetchDepth != 0) + { + prefetchRevisions(prefetchDepth > 0 ? prefetchDepth : Integer.MAX_VALUE, revisions, additionalRevisions); + } + + getRepository().notifyReadAccessHandlers(getSession(), revisions, additionalRevisions); + + for (int i = 0; i < size; i++) + { + RevisionInfo info = infos[i]; + info.setResult(revisions[i]); + info.writeResult(out, referenceChunk, branchPoint); // Exposes revision to client side + } + + int additionalSize = additionalRevisions.size(); + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} additional revisions", additionalSize); //$NON-NLS-1$ + } + + out.writeInt(additionalSize); + for (CDORevision revision : additionalRevisions) + { + out.writeCDORevision(revision, referenceChunk, branchPoint); // Exposes revision to client side + } + } + + private InternalCDORevision getRevision(CDOID id) + { + return getRepository().getRevisionManager().getRevision(id, branchPoint, referenceChunk, CDORevision.DEPTH_NONE, + true); + } + + private void collectRevisions(InternalCDORevision revision, Set<CDOID> revisions, + List<CDORevision> additionalRevisions, Set<CDOFetchRule> visitedFetchRules) + { + if (revision == null) + { + return; + } + + getSession().collectContainedRevisions(revision, branchPoint, referenceChunk, revisions, additionalRevisions); + + CDOFetchRule fetchRule = fetchRules.get(revision.getEClass()); + if (fetchRule == null || visitedFetchRules.contains(fetchRule)) + { + return; + } + + visitedFetchRules.add(fetchRule); + + for (EStructuralFeature feature : fetchRule.getFeatures()) + { + if (feature.isMany()) + { + MoveableList<Object> list = revision.getList(feature); + int toIndex = Math.min(loadRevisionCollectionChunkSize, list.size()) - 1; + for (int i = 0; i <= toIndex; i++) + { + Object value = list.get(i); + if (value instanceof CDOID) + { + CDOID id = (CDOID)value; + if (!CDOIDUtil.isNull(id) && !revisions.contains(id)) + { + InternalCDORevision containedRevision = getRevision(id); + if (containedRevision != null) + { + revisions.add(containedRevision.getID()); + additionalRevisions.add(containedRevision); + collectRevisions(containedRevision, revisions, additionalRevisions, visitedFetchRules); + } + } + } + } + } + else + { + Object value = revision.getValue(feature); + if (value instanceof CDOID) + { + CDOID id = (CDOID)value; + if (!id.isNull() && !revisions.contains(id)) + { + InternalCDORevision containedRevision = getRevision(id); + if (containedRevision != null) + { + revisions.add(containedRevision.getID()); + additionalRevisions.add(containedRevision); + collectRevisions(containedRevision, revisions, additionalRevisions, visitedFetchRules); + } + } + } + } + } + + visitedFetchRules.remove(fetchRule); + } + + private void prefetchRevisions(int depth, CDORevision[] revisions, List<CDORevision> additionalRevisions) + { + Map<CDOID, CDORevision> map = new HashMap<CDOID, CDORevision>(); + for (CDORevision revision : revisions) + { + map.put(revision.getID(), revision); + } + + for (CDORevision revision : additionalRevisions) + { + map.put(revision.getID(), revision); + } + + for (CDORevision revision : revisions) + { + prefetchRevision(depth, (InternalCDORevision)revision, additionalRevisions, map); + } + } + + private void prefetchRevision(int depth, InternalCDORevision revision, List<CDORevision> additionalRevisions, + Map<CDOID, CDORevision> map) + { + CDOClassInfo classInfo = revision.getClassInfo(); + for (EStructuralFeature feature : classInfo.getAllPersistentFeatures()) + { + if (feature instanceof EReference) + { + EReference reference = (EReference)feature; + if (reference.isContainment()) + { + Object value = revision.getValue(reference); + if (value instanceof CDOID) + { + CDOID id = (CDOID)value; + prefetchRevisionChild(depth, id, additionalRevisions, map); + } + else if (value instanceof Collection<?>) + { + Collection<?> c = (Collection<?>)value; + for (Object e : c) + { + // If this revision was loaded with referenceChunk != UNCHUNKED, then + // some elements might be uninitialized, i.e. not instanceof CDOID. + // (See bug 339313.) + if (e instanceof CDOID) + { + CDOID id = (CDOID)e; + prefetchRevisionChild(depth, id, additionalRevisions, map); + } + } + } + } + } + } + } + + private void prefetchRevisionChild(int depth, CDOID id, List<CDORevision> additionalRevisions, + Map<CDOID, CDORevision> map) + { + if (CDOIDUtil.isNull(id)) + { + return; + } + + CDORevision child = map.get(id); + if (child == null) + { + child = getRevision(id); + if (child != null) + { + map.put(id, child); + additionalRevisions.add(child); + } + } + + if (child != null && depth > 0) + { + prefetchRevision(depth - 1, (InternalCDORevision)child, additionalRevisions, map); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java index 62dcc59654..9a8e2a4fb2 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java @@ -1,169 +1,179 @@ -/*
- * Copyright (c) 2004 - 2012 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author Simon McDuff
- */
-public class RefreshSessionIndication extends CDOServerReadIndication
-{
- private Map<CDOBranch, List<CDORevisionKey>> viewedRevisions = new HashMap<CDOBranch, List<CDORevisionKey>>();
-
- private long lastUpdateTime;
-
- private int initialChunkSize;
-
- private boolean enablePassiveUpdates;
-
- public RefreshSessionIndication(CDOServerProtocol protocol)
- {
- this(protocol, CDOProtocolConstants.SIGNAL_REFRESH_SESSION);
- }
-
- protected RefreshSessionIndication(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- public Map<CDOBranch, List<CDORevisionKey>> getViewedRevisions()
- {
- return viewedRevisions;
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- lastUpdateTime = in.readLong();
- initialChunkSize = in.readInt();
- enablePassiveUpdates = in.readBoolean();
-
- int branches = in.readInt();
- for (int i = 0; i < branches; i++)
- {
- CDOBranch branch = in.readCDOBranch();
- List<CDORevisionKey> revisions = new ArrayList<CDORevisionKey>();
- viewedRevisions.put(branch, revisions);
- int size = in.readInt();
- for (int j = 0; j < size; j++)
- {
- CDORevisionKey revision = in.readCDORevisionKey();
- revisions.add(revision);
- }
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- long lastCommitTimeStamp = getRepository().getLastCommitTimeStamp();
- out.writeLong(lastCommitTimeStamp);
-
- writePackageUnits(out, lastCommitTimeStamp);
- writeRevisions(out);
-
- respondingDone();
- }
-
- protected void respondingDone()
- {
- InternalSession session = getSession();
- session.setPassiveUpdateEnabled(enablePassiveUpdates);
- }
-
- protected void writPackageUnit(CDODataOutput out, InternalCDOPackageUnit packageUnit) throws IOException
- {
- out.writeByte(CDOProtocolConstants.REFRESH_PACKAGE_UNIT);
- out.writeCDOPackageUnit(packageUnit, false);
- }
-
- protected void writeChangedObject(CDODataOutput out, InternalCDORevision revision) throws IOException
- {
- out.writeByte(CDOProtocolConstants.REFRESH_CHANGED_OBJECT);
- out.writeCDORevision(revision, initialChunkSize);
- }
-
- protected void writeDetachedObject(CDODataOutput out, CDORevisionKey key) throws IOException
- {
- out.writeByte(CDOProtocolConstants.REFRESH_DETACHED_OBJECT);
- out.writeCDORevisionKey(key);
- }
-
- private void writePackageUnits(CDODataOutput out, long lastCommitTimeStamp) throws IOException
- {
- InternalCDOPackageRegistry packageRegistry = getRepository().getPackageRegistry();
- InternalCDOPackageUnit[] packageUnits = packageRegistry.getPackageUnits(lastUpdateTime + 1L, lastCommitTimeStamp);
- for (InternalCDOPackageUnit packageUnit : packageUnits)
- {
- writPackageUnit(out, packageUnit);
- }
- }
-
- private void writeRevisions(CDODataOutput out) throws IOException
- {
- InternalCDORevisionManager revisionManager = getRepository().getRevisionManager();
- SyntheticCDORevision[] synthetics = new SyntheticCDORevision[1];
-
- for (Entry<CDOBranch, List<CDORevisionKey>> entry : viewedRevisions.entrySet())
- {
- CDOBranch branch = entry.getKey();
- CDOBranchPoint head = branch.getHead();
-
- for (CDORevisionKey key : entry.getValue())
- {
- CDOID id = key.getID();
- synthetics[0] = null;
- InternalCDORevision revision = revisionManager.getRevision(id, head, CDORevision.UNCHUNKED,
- CDORevision.DEPTH_NONE, true, synthetics);
-
- if (revision == null)
- {
- writeDetachedObject(out, synthetics[0]);
- }
- else if (hasChanged(key, revision))
- {
- writeChangedObject(out, revision);
- }
- }
- }
-
- out.writeByte(CDOProtocolConstants.REFRESH_FINISHED);
- }
-
- private static boolean hasChanged(CDORevisionKey oldKey, CDORevisionKey newKey)
- {
- return !ObjectUtil.equals(oldKey.getBranch(), newKey.getBranch()) || oldKey.getVersion() != newKey.getVersion();
- }
-}
+/* + * Copyright (c) 2004 - 2012 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; +import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.util.ObjectUtil; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * @author Simon McDuff + */ +public class RefreshSessionIndication extends CDOServerReadIndication +{ + private Map<CDOBranch, List<CDORevisionKey>> viewedRevisions = new HashMap<CDOBranch, List<CDORevisionKey>>(); + + private long lastUpdateTime; + + private int initialChunkSize; + + private boolean enablePassiveUpdates; + + public RefreshSessionIndication(CDOServerProtocol protocol) + { + this(protocol, CDOProtocolConstants.SIGNAL_REFRESH_SESSION); + } + + protected RefreshSessionIndication(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + public Map<CDOBranch, List<CDORevisionKey>> getViewedRevisions() + { + return viewedRevisions; + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + lastUpdateTime = in.readLong(); + initialChunkSize = in.readInt(); + enablePassiveUpdates = in.readBoolean(); + + int branches = in.readInt(); + for (int i = 0; i < branches; i++) + { + CDOBranch branch = in.readCDOBranch(); + List<CDORevisionKey> revisions = new ArrayList<CDORevisionKey>(); + viewedRevisions.put(branch, revisions); + int size = in.readInt(); + for (int j = 0; j < size; j++) + { + CDORevisionKey revision = in.readCDORevisionKey(); + revisions.add(revision); + } + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + long lastCommitTimeStamp = getRepository().getLastCommitTimeStamp(); + out.writeLong(lastCommitTimeStamp); + + writePackageUnits(out, lastCommitTimeStamp); + writeRevisions(out); + + respondingDone(); + } + + protected void respondingDone() + { + InternalSession session = getSession(); + session.setPassiveUpdateEnabled(enablePassiveUpdates); + } + + protected void writPackageUnit(CDODataOutput out, InternalCDOPackageUnit packageUnit) throws IOException + { + out.writeByte(CDOProtocolConstants.REFRESH_PACKAGE_UNIT); + out.writeCDOPackageUnit(packageUnit, false); + } + + /** + * @deprecated Call {@link #writeChangedObject(CDODataOutput, InternalCDORevision, CDOBranchPoint)} + */ + @Deprecated + protected void writeChangedObject(CDODataOutput out, InternalCDORevision revision) throws IOException + { + writeChangedObject(out, revision, null); + } + + protected void writeChangedObject(CDODataOutput out, InternalCDORevision revision, CDOBranchPoint securityContext) + throws IOException + { + out.writeByte(CDOProtocolConstants.REFRESH_CHANGED_OBJECT); + out.writeCDORevision(revision, initialChunkSize, securityContext); // Exposes revision to client side + } + + protected void writeDetachedObject(CDODataOutput out, CDORevisionKey key) throws IOException + { + out.writeByte(CDOProtocolConstants.REFRESH_DETACHED_OBJECT); + out.writeCDORevisionKey(key); + } + + private void writePackageUnits(CDODataOutput out, long lastCommitTimeStamp) throws IOException + { + InternalCDOPackageRegistry packageRegistry = getRepository().getPackageRegistry(); + InternalCDOPackageUnit[] packageUnits = packageRegistry.getPackageUnits(lastUpdateTime + 1L, lastCommitTimeStamp); + for (InternalCDOPackageUnit packageUnit : packageUnits) + { + writPackageUnit(out, packageUnit); + } + } + + private void writeRevisions(CDODataOutput out) throws IOException + { + InternalCDORevisionManager revisionManager = getRepository().getRevisionManager(); + SyntheticCDORevision[] synthetics = new SyntheticCDORevision[1]; + + for (Entry<CDOBranch, List<CDORevisionKey>> entry : viewedRevisions.entrySet()) + { + CDOBranch branch = entry.getKey(); + CDOBranchPoint head = branch.getHead(); + + for (CDORevisionKey key : entry.getValue()) + { + CDOID id = key.getID(); + synthetics[0] = null; + InternalCDORevision revision = revisionManager.getRevision(id, head, CDORevision.UNCHUNKED, + CDORevision.DEPTH_NONE, true, synthetics); + + if (revision == null) + { + writeDetachedObject(out, synthetics[0]); + } + else if (hasChanged(key, revision)) + { + writeChangedObject(out, revision, head); + } + } + } + + out.writeByte(CDOProtocolConstants.REFRESH_FINISHED); + } + + private static boolean hasChanged(CDORevisionKey oldKey, CDORevisionKey newKey) + { + return !ObjectUtil.equals(oldKey.getBranch(), newKey.getBranch()) || oldKey.getVersion() != newKey.getVersion(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java index b4b2d2e15a..8c3b8969a7 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java @@ -1,145 +1,145 @@ -/*
- * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.CDOReplicationContext;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class ReplicateRepositoryIndication extends CDOServerReadIndication
-{
- private int lastReplicatedBranchID;
-
- private long lastReplicatedCommitTime;
-
- private String[] lockAreaIDs;
-
- public ReplicateRepositoryIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- lastReplicatedBranchID = in.readInt();
- lastReplicatedCommitTime = in.readLong();
- lockAreaIDs = new String[in.readInt()];
- for (int i = 0; i < lockAreaIDs.length; i++)
- {
- lockAreaIDs[i] = in.readString();
- }
- }
-
- private Set<String> createLockAreaIDSet()
- {
- Set<String> idSet = new HashSet<String>(lockAreaIDs.length);
- for (String id : lockAreaIDs)
- {
- idSet.add(id);
- }
- return idSet;
- }
-
- @Override
- protected void responding(final CDODataOutput out) throws IOException
- {
- // We will remove IDs from this set as we process lockAreas one by one;
- // what remains in this set at the end are the lockAreas that the client
- // has, but we don't have, which means that they were removed.
- //
- final Set<String> lockAreaIDSet = createLockAreaIDSet();
-
- getRepository().replicate(new CDOReplicationContext()
- {
- public int getLastReplicatedBranchID()
- {
- return lastReplicatedBranchID;
- }
-
- public long getLastReplicatedCommitTime()
- {
- return lastReplicatedCommitTime;
- }
-
- public String[] getLockAreaIDs()
- {
- return lockAreaIDs;
- }
-
- public void handleBranch(CDOBranch branch)
- {
- try
- {
- out.writeByte(CDOProtocolConstants.REPLICATE_BRANCH);
- out.writeCDOBranch(branch);
- }
- catch (IOException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public void handleCommitInfo(CDOCommitInfo commitInfo)
- {
- try
- {
- out.writeByte(CDOProtocolConstants.REPLICATE_COMMIT);
- out.writeCDOCommitInfo(commitInfo);
- }
- catch (IOException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public boolean handleLockArea(LockArea lockArea)
- {
- try
- {
- out.writeByte(CDOProtocolConstants.REPLICATE_LOCKAREA);
- out.writeBoolean(true);
- out.writeCDOLockArea(lockArea);
- lockAreaIDSet.remove(lockArea.getDurableLockingID());
- return true;
- }
- catch (IOException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- });
-
- // The IDs that are still in the lockAreaIDSet, must be the IDs of lockAreas that have
- // been removed.
- for (String deletedLockAreaID : lockAreaIDSet)
- {
- out.writeByte(CDOProtocolConstants.REPLICATE_LOCKAREA);
- out.writeBoolean(false);
- out.writeString(deletedLockAreaID);
- }
-
- out.writeByte(CDOProtocolConstants.REPLICATE_FINISHED);
- }
-}
+/* + * Copyright (c) 2004 - 2012 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.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.CDOReplicationContext; + +import org.eclipse.net4j.util.WrappedException; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class ReplicateRepositoryIndication extends CDOServerReadIndication +{ + private int lastReplicatedBranchID; + + private long lastReplicatedCommitTime; + + private String[] lockAreaIDs; + + public ReplicateRepositoryIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + lastReplicatedBranchID = in.readInt(); + lastReplicatedCommitTime = in.readLong(); + lockAreaIDs = new String[in.readInt()]; + for (int i = 0; i < lockAreaIDs.length; i++) + { + lockAreaIDs[i] = in.readString(); + } + } + + private Set<String> createLockAreaIDSet() + { + Set<String> idSet = new HashSet<String>(lockAreaIDs.length); + for (String id : lockAreaIDs) + { + idSet.add(id); + } + return idSet; + } + + @Override + protected void responding(final CDODataOutput out) throws IOException + { + // We will remove IDs from this set as we process lockAreas one by one; + // what remains in this set at the end are the lockAreas that the client + // has, but we don't have, which means that they were removed. + // + final Set<String> lockAreaIDSet = createLockAreaIDSet(); + + getRepository().replicate(new CDOReplicationContext() + { + public int getLastReplicatedBranchID() + { + return lastReplicatedBranchID; + } + + public long getLastReplicatedCommitTime() + { + return lastReplicatedCommitTime; + } + + public String[] getLockAreaIDs() + { + return lockAreaIDs; + } + + public void handleBranch(CDOBranch branch) + { + try + { + out.writeByte(CDOProtocolConstants.REPLICATE_BRANCH); + out.writeCDOBranch(branch); + } + catch (IOException ex) + { + throw WrappedException.wrap(ex); + } + } + + public void handleCommitInfo(CDOCommitInfo commitInfo) + { + try + { + out.writeByte(CDOProtocolConstants.REPLICATE_COMMIT); + out.writeCDOCommitInfo(commitInfo); + } + catch (IOException ex) + { + throw WrappedException.wrap(ex); + } + } + + public boolean handleLockArea(LockArea lockArea) + { + try + { + out.writeByte(CDOProtocolConstants.REPLICATE_LOCKAREA); + out.writeBoolean(true); + out.writeCDOLockArea(lockArea); + lockAreaIDSet.remove(lockArea.getDurableLockingID()); + return true; + } + catch (IOException ex) + { + throw WrappedException.wrap(ex); + } + } + }); + + // The IDs that are still in the lockAreaIDSet, must be the IDs of lockAreas that have + // been removed. + for (String deletedLockAreaID : lockAreaIDSet) + { + out.writeByte(CDOProtocolConstants.REPLICATE_LOCKAREA); + out.writeBoolean(false); + out.writeString(deletedLockAreaID); + } + + out.writeByte(CDOProtocolConstants.REPLICATE_FINISHED); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.security/.classpath b/plugins/org.eclipse.emf.cdo.server.security/.classpath new file mode 100644 index 0000000000..64c5e31b7a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.emf.cdo.server.security/.project b/plugins/org.eclipse.emf.cdo.server.security/.project new file mode 100644 index 0000000000..790a997a69 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.emf.cdo.server.security</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..8111b513cb --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Mon Jul 04 13:01:32 CEST 2011 +eclipse.preferences.version=1 +encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8 diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..805cd8fbdd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,395 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.ucls,doc-files/,package.html,package-info.java +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled +org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW +org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,PERF,MEM,POLISH,@generated NOT,@ADDED +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=120 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=2 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.launching.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 0000000000..556ed07a3c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,3 @@ +#Fri Sep 02 05:38:34 CEST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..4343e2f963 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,119 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=false +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_EMFT +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_EMFT +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=ex +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=99 +org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=true +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.ltk.core.refactoring.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000000..864e30fe5d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,3 @@ +#Thu Feb 04 09:44:24 CET 2010 +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.mylyn.tasks.ui.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 0000000000..b050639a54 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,4 @@ +#Thu Feb 04 09:44:24 CET 2010 +eclipse.preferences.version=1 +project.repository.kind=bugzilla +project.repository.url=https\://bugs.eclipse.org/bugs diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.mylyn.team.ui.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.mylyn.team.ui.prefs new file mode 100644 index 0000000000..2f50f36c0c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.mylyn.team.ui.prefs @@ -0,0 +1,3 @@ +#Thu Feb 04 09:44:24 CET 2010 +commit.comment.template=[${task.id}] ${task.description} \r\n${task.url} +eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.pde.api.tools.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 0000000000..66af0294f0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,94 @@ +#Sun Jul 18 08:53:50 CEST 2010 +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_JAVADOC_TAG=Ignore +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Ignore +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Ignore +automatically_removed_unused_problem_filters=Disabled +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Error +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.pde.prefs b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..c6b96bb45e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/.settings/org.eclipse.pde.prefs @@ -0,0 +1,31 @@ +#Thu Feb 04 09:44:24 CET 2010 +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=1 +compilers.p.missing-version-export-package=1 +compilers.p.missing-version-import-package=1 +compilers.p.missing-version-require-bundle=1 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..a78db5ee2d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.emf.cdo.server.security;singleton:=true +Bundle-Name: %pluginName +Bundle-Version: 4.1.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", + org.eclipse.emf.cdo.server;bundle-version="[4.1.0,5.0.0)", + org.eclipse.emf.cdo.security;bundle-version="[4.1.0,5.0.0)", + org.eclipse.emf.cdo.net4j;bundle-version="[4.1.0,5.0.0)", + org.eclipse.net4j.jvm;bundle-version="[4.1.0,5.0.0)" +Export-Package: org.eclipse.emf.cdo.server.internal.security;version="4.1.0"; + x-friends:="org.eclipse.emf.cdo.tests, + org.eclipse.emf.cdo.tests.db, + org.eclipse.emf.cdo.tests.db4o, + org.eclipse.emf.cdo.tests.hibernate, + org.eclipse.emf.cdo.tests.mongodb, + org.eclipse.emf.cdo.tests.objectivity", + org.eclipse.emf.cdo.server.security;version="4.1.0" diff --git a/plugins/org.eclipse.emf.cdo.server.security/about.html b/plugins/org.eclipse.emf.cdo.server.security/about.html new file mode 100644 index 0000000000..d35d5aed64 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 5, 2007</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + +</body> +</html> diff --git a/plugins/org.eclipse.emf.cdo.server.security/build.properties b/plugins/org.eclipse.emf.cdo.server.security/build.properties new file mode 100644 index 0000000000..1e496926db --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/build.properties @@ -0,0 +1,24 @@ +# Copyright (c) 2004 - 2012 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 + +# NLS_MESSAGEFORMAT_VAR + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + copyright.txt,\ + plugin.properties +src.includes = about.html,\ + copyright.txt + +doc.project = org.eclipse.emf.cdo.doc + +generateSourceReferences = true diff --git a/plugins/org.eclipse.emf.cdo.server.security/copyright.txt b/plugins/org.eclipse.emf.cdo.server.security/copyright.txt new file mode 100644 index 0000000000..0a0f67e6d7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/copyright.txt @@ -0,0 +1,8 @@ +Copyright (c) 2004 - 2012 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
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server.security/plugin.properties b/plugins/org.eclipse.emf.cdo.server.security/plugin.properties new file mode 100644 index 0000000000..8910bed17a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/plugin.properties @@ -0,0 +1,11 @@ +# Copyright (c) 2004 - 2012 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 + +pluginName = CDO Model Repository Server Security Support +providerName = Eclipse Modeling Project diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java new file mode 100644 index 0000000000..9a3c423e03 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2004 - 2012 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.server.internal.security; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; +import org.eclipse.emf.cdo.common.security.CDOPermission; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.net4j.CDONet4jSession; +import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration; +import org.eclipse.emf.cdo.net4j.CDONet4jUtil; +import org.eclipse.emf.cdo.security.Realm; +import org.eclipse.emf.cdo.security.RealmUtil; +import org.eclipse.emf.cdo.security.SecurityItem; +import org.eclipse.emf.cdo.security.User; +import org.eclipse.emf.cdo.server.IPermissionManager; +import org.eclipse.emf.cdo.server.IRepository; +import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext; +import org.eclipse.emf.cdo.server.ITransaction; +import org.eclipse.emf.cdo.server.security.ISecurityManager; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.ManagedRevisionProvider; +import org.eclipse.emf.cdo.spi.server.InternalRepository; +import org.eclipse.emf.cdo.spi.server.InternalSessionManager; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.acceptor.IAcceptor; +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.lifecycle.ILifecycle; +import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter; +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.security.IUserManager; + +import org.eclipse.emf.common.util.EList; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class SecurityManager implements ISecurityManager, IUserManager, IPermissionManager, + IRepository.WriteAccessHandler +{ + private final InternalRepository repository; + + private final String realmPath; + + private IManagedContainer container; + + private IAcceptor acceptor; + + private IConnector connector; + + private CDOTransaction transaction; + + private Realm realm; + + private Map<String, User> users = new HashMap<String, User>(); + + public SecurityManager(IRepository repository, String realmPath, IManagedContainer container) + { + this.repository = (InternalRepository)repository; + this.realmPath = realmPath; + this.container = container; + + init(); + } + + private void init() + { + String repositoryName = repository.getName(); + String acceptorName = repositoryName + "_security"; + + acceptor = Net4jUtil.getAcceptor(container, "jvm", acceptorName); + connector = Net4jUtil.getConnector(container, "jvm", acceptorName); + + CDONet4jSessionConfiguration config = CDONet4jUtil.createNet4jSessionConfiguration(); + config.setConnector(connector); + config.setRepositoryName(repositoryName); + + CDONet4jSession session = config.openNet4jSession(); + transaction = session.openTransaction(); + + CDOResource resource = transaction.getResource(realmPath); + realm = (Realm)resource.getContents().get(0); + + // Wire up with repository + InternalSessionManager sessionManager = repository.getSessionManager(); + sessionManager.setUserManager(this); + sessionManager.setPermissionManager(this); + repository.addHandler(this); + repository.addListener(new LifecycleEventAdapter() + { + @Override + protected void onDeactivated(ILifecycle lifecycle) + { + dispose(); + } + }); + } + + private void dispose() + { + users.clear(); + realm = null; + + transaction.getSession().close(); + transaction = null; + + connector.close(); + connector = null; + + acceptor.close(); + acceptor = null; + } + + public final IRepository getRepository() + { + return repository; + } + + public final String getRealmPath() + { + return realmPath; + } + + public void addUser(String userID, char[] password) + { + } + + public void removeUser(String userID) + { + } + + public byte[] encrypt(String userID, byte[] data, String algorithmName, byte[] salt, int count) + throws SecurityException + { + return null; + } + + public CDOPermission getPermission(CDORevision revision, CDOBranchPoint securityContext, String userID) + { + User user = getUser(userID); + CDORevisionProvider revisionProvider = new ManagedRevisionProvider(repository.getRevisionManager(), securityContext); + return getPermission(revision, revisionProvider, user); + } + + public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext, OMMonitor monitor) + throws RuntimeException + { + String userID = commitContext.getUserID(); + User user = getUser(userID); + + for (InternalCDORevision revision : commitContext.getNewObjects()) + { + getPermission(revision, commitContext, user); + + } + } + + public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext, OMMonitor monitor) + { + // Do nothing + } + + private User getUser(String userID) + { + synchronized (users) + { + User user = users.get(userID); + if (user == null) + { + EList<SecurityItem> items = realm.getItems(); + user = RealmUtil.findUser(items, userID); + if (user != null) + { + users.put(userID, user); + } + } + + return user; + } + } + + private CDOPermission getPermission(CDORevision revision, CDORevisionProvider revisionProvider, User user) + { + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/ISecurityManager.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/ISecurityManager.java new file mode 100644 index 0000000000..ee035770b7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/ISecurityManager.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2004 - 2012 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.server.security; + +/** + * @author Eike Stepper + */ +public interface ISecurityManager +{ + +} diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/SecurityManagerUtil.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/SecurityManagerUtil.java new file mode 100644 index 0000000000..595c3b0511 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/SecurityManagerUtil.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2004 - 2012 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.server.security; + +import org.eclipse.emf.cdo.server.IRepository; + +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginContainer; + +/** + * Static factory methods for creating {@link ISecurityManager security managers}. + * + * @author Eike Stepper + */ +public final class SecurityManagerUtil +{ + private SecurityManagerUtil() + { + } + + public static ISecurityManager createSecurityManager(IRepository repository, String realmPath) + { + return createSecurityManager(repository, realmPath, IPluginContainer.INSTANCE); + } + + public static ISecurityManager createSecurityManager(IRepository repository, String realmPath, + IManagedContainer container) + { + return new org.eclipse.emf.cdo.server.internal.security.SecurityManager(repository, realmPath, container); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/package-info.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/package-info.java new file mode 100644 index 0000000000..efe69dc445 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/package-info.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2004 - 2012 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 + */ + +/** + * Server integration of the {@link org.eclipse.emf.cdo.security.Realm Security} model + */ +package org.eclipse.emf.cdo.server.security; + diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java index 707cc9639e..4094de52eb 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java @@ -354,15 +354,15 @@ public class Session extends Container<IView> implements InternalSession return (CDOID)idObject; } - public CDOPermission getPermission(Object protectableObject) + public CDOPermission getPermission(CDORevision revision, CDOBranchPoint securityContext) { IPermissionManager permissionManager = manager.getPermissionManager(); if (permissionManager != null) { - return permissionManager.getPermission(protectableObject, userID); + return permissionManager.getPermission(revision, securityContext, userID); } - return CDORevision.PERMISSION_PROVIDER.getPermission(protectableObject); + return CDORevision.PERMISSION_PROVIDER.getPermission(revision, securityContext); } public void sendRepositoryTypeNotification(CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType) diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IPermissionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IPermissionManager.java index 69f9d01f8d..7ef3e8f8b6 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IPermissionManager.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IPermissionManager.java @@ -10,15 +10,17 @@ */ package org.eclipse.emf.cdo.server; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.security.CDOPermission; /** - * Provides the protection level of protectable objects in the context of a specific user. + * Provides the protection level of {@link CDORevision revisions} in the context of a specific user. * * @author Eike Stepper * @since 4.1 */ public interface IPermissionManager { - public CDOPermission getPermission(Object protectableObject, String userID); + public CDOPermission getPermission(CDORevision revision, CDOBranchPoint securityContext, String userID); } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343084_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343084_Test.java index bc6f93ce26..5d106602a2 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343084_Test.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343084_Test.java @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.tests.bugzilla; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.common.security.NoPermissionException; @@ -59,16 +60,13 @@ public class Bugzilla_343084_Test extends AbstractCDOTest IPermissionManager permissionManager = new IPermissionManager() { - public CDOPermission getPermission(Object protectableObject, String userID) + public CDOPermission getPermission(CDORevision revision, CDOBranchPoint securityContext, String userID) { - if (protectableObject instanceof CDORevision) + EClass eClass = revision.getEClass(); + CDOPermission permission = permissions.get(eClass); + if (permission != null) { - EClass eClass = ((CDORevision)protectableObject).getEClass(); - CDOPermission permission = permissions.get(eClass); - if (permission != null) - { - return permission; - } + return permission; } return CDOPermission.WRITE; diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java index 32a29a219c..ba362b9146 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java @@ -1,547 +1,547 @@ -/*
- * Copyright (c) 2004 - 2012 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 - maintenance
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.util;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
-import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionManager;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.transaction.CDOXATransaction;
-import org.eclipse.emf.cdo.view.CDOFeatureAnalyzer;
-import org.eclipse.emf.cdo.view.CDOFetchRuleManager;
-import org.eclipse.emf.cdo.view.CDORevisionPrefetchingPolicy;
-import org.eclipse.emf.cdo.view.CDOStaleObject;
-import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.emf.cdo.view.CDOViewSet;
-
-import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerModelBased;
-import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerUI;
-import org.eclipse.emf.internal.cdo.analyzer.CDOFetchRuleManagerThreadLocal;
-import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.messages.Messages;
-import org.eclipse.emf.internal.cdo.object.CDOFactoryImpl;
-import org.eclipse.emf.internal.cdo.object.CDOObjectWrapper;
-import org.eclipse.emf.internal.cdo.session.CDOCollectionLoadingPolicyImpl;
-import org.eclipse.emf.internal.cdo.transaction.CDOXATransactionImpl;
-import org.eclipse.emf.internal.cdo.transaction.CDOXATransactionImpl.CDOXAInternalAdapter;
-import org.eclipse.emf.internal.cdo.view.CDORevisionPrefetchingPolicyImpl;
-import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
-
-import org.eclipse.net4j.util.AdapterUtil;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.spi.cdo.FSMUtil;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
-
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Various static methods that may help in CDO client applications.
- *
- * @author Eike Stepper
- */
-public final class CDOUtil
-{
- private static final ThreadLocal<Boolean> legacyModeDefault = new InheritableThreadLocal<Boolean>()
- {
- @Override
- protected Boolean initialValue()
- {
- return false;
- }
- };
-
- static
- {
- if (!OMPlatform.INSTANCE.isOSGiRunning())
- {
- registerResourceFactory(Resource.Factory.Registry.INSTANCE);
- }
- }
-
- private CDOUtil()
- {
- }
-
- /**
- * @since 4.0
- */
- public static boolean registerResourceFactory(Resource.Factory.Registry registry)
- {
- if (registry == null)
- {
- return false;
- }
-
- Map<String, Object> map = registry.getProtocolToFactoryMap();
- if (!map.containsKey(CDOURIUtil.PROTOCOL_NAME))
- {
- map.put(CDOURIUtil.PROTOCOL_NAME, CDOResourceFactory.INSTANCE);
- return true;
- }
-
- return false;
- }
-
- /**
- * @since 3.0
- */
- public static CDOSession getSession(Object object)
- {
- if (object == null)
- {
- return null;
- }
-
- CDOSession session = AdapterUtil.adapt(object, CDOSession.class);
- if (session != null)
- {
- return session;
- }
-
- CDOView view = AdapterUtil.adapt(object, CDOView.class);
- if (view != null)
- {
- return view.getSession();
- }
-
- CDOObject cdoObject = AdapterUtil.adapt(object, CDOObject.class);
- if (cdoObject != null)
- {
- return cdoObject.cdoView().getSession();
- }
-
- CDORemoteSessionManager remoteSessionManager = AdapterUtil.adapt(object, CDORemoteSessionManager.class);
- if (remoteSessionManager != null)
- {
- return remoteSessionManager.getLocalSession();
- }
-
- return null;
- }
-
- /**
- * @since 2.0
- */
- public static boolean prepareDynamicEPackage(EPackage startPackage)
- {
- if (CDOFactoryImpl.prepareDynamicEPackage(startPackage))
- {
- for (EPackage subPackage : startPackage.getESubpackages())
- {
- prepareDynamicEPackage(subPackage);
- }
-
- return true;
- }
-
- return false;
- }
-
- /**
- * @since 2.0
- */
- public static CDOCollectionLoadingPolicy createCollectionLoadingPolicy(int initialChunkSize, int resolveChunkSize)
- {
- return new CDOCollectionLoadingPolicyImpl(initialChunkSize, resolveChunkSize);
- }
-
- /**
- * @since 2.0
- */
- public static CDORevisionPrefetchingPolicy createRevisionPrefetchingPolicy(int chunkSize)
- {
- if (chunkSize <= 0)
- {
- return CDORevisionPrefetchingPolicy.NO_PREFETCHING;
- }
-
- return new CDORevisionPrefetchingPolicyImpl(chunkSize);
- }
-
- /**
- * @since 4.1
- */
- public static CDOFetchRuleManager createThreadLocalFetchRuleManager()
- {
- return new CDOFetchRuleManagerThreadLocal();
- }
-
- /**
- * @since 4.1
- */
- public static CDOFeatureAnalyzer createModelBasedFeatureAnalyzer()
- {
- return new CDOFeatureAnalyzerModelBased();
- }
-
- /**
- * @since 4.1
- */
- public static CDOFeatureAnalyzer createUIFeatureAnalyzer()
- {
- return new CDOFeatureAnalyzerUI();
- }
-
- /**
- * @since 4.1
- */
- public static CDOFeatureAnalyzer createUIFeatureAnalyzer(long maxTimeBetweenOperation)
- {
- return new CDOFeatureAnalyzerUI(maxTimeBetweenOperation);
- }
-
- /**
- * @since 4.0
- */
- public static CDOXATransaction createXATransaction(Notifier... notifiers)
- {
- CDOXATransaction xaTransaction = new CDOXATransactionImpl();
- for (Notifier notifier : notifiers)
- {
- CDOViewSet viewSet = getViewSet(notifier);
- if (viewSet == null)
- {
- throw new IllegalArgumentException("Notifier is not associated with a CDOViewSet: " + notifier);
- }
-
- try
- {
- xaTransaction.add(viewSet);
- }
- catch (IllegalArgumentException ex)
- {
- OM.LOG.warn(ex);
- }
- }
-
- return xaTransaction;
- }
-
- /**
- * @since 2.0
- */
- public static CDOXATransaction getXATransaction(CDOViewSet viewSet)
- {
- EList<Adapter> adapters = viewSet.eAdapters();
- for (Adapter adapter : adapters)
- {
- if (adapter instanceof CDOXAInternalAdapter)
- {
- return ((CDOXAInternalAdapter)adapter).getXATransaction();
- }
- }
-
- return null;
- }
-
- /**
- * @since 4.0
- */
- public static CDOViewSet getViewSet(Notifier notifier)
- {
- if (notifier instanceof CDOViewSet)
- {
- return (CDOViewSet)notifier;
- }
-
- EList<Adapter> adapters = notifier.eAdapters();
- for (Adapter adapter : adapters)
- {
- if (adapter instanceof CDOViewSet)
- {
- return (CDOViewSet)adapter;
- }
- }
-
- if (notifier instanceof InternalEObject)
- {
- InternalEObject object = (InternalEObject)notifier;
- EObject container = object.eContainer();
- if (container != null)
- {
- CDOViewSet viewSet = getViewSet(container);
- if (viewSet != null)
- {
- return viewSet;
- }
- }
-
- Resource.Internal resource = object.eDirectResource();
- if (resource != null)
- {
- CDOViewSet viewSet = getViewSet(resource);
- if (viewSet != null)
- {
- return viewSet;
- }
- }
- }
-
- if (notifier instanceof Resource)
- {
- Resource resource = (Resource)notifier;
- ResourceSet resourceSet = resource.getResourceSet();
- if (resourceSet != null)
- {
- CDOViewSet viewSet = getViewSet(resourceSet);
- if (viewSet != null)
- {
- return viewSet;
- }
- }
- }
-
- return null;
- }
-
- /**
- * @since 3.0
- */
- public static boolean isStaleObject(Object object)
- {
- return object instanceof CDOStaleObject;
- }
-
- /**
- * @since 3.0
- */
- public static void cleanStaleReference(EObject eObject, EStructuralFeature eFeature)
- {
- if (!eFeature.isMany() && eFeature.getEContainingClass() != null)
- {
- InternalCDOObject cdoObject = (InternalCDOObject)getCDOObject(eObject);
- cdoObject.eStore().unset(cdoObject, eFeature);
- }
- }
-
- /**
- * @since 3.0
- */
- public static void cleanStaleReference(EObject eObject, EStructuralFeature eFeature, int index)
- {
- if (eFeature.isMany() && eFeature.getEContainingClass() != null)
- {
- InternalCDOObject cdoObject = (InternalCDOObject)getCDOObject(eObject);
- try
- {
- cdoObject.eStore().remove(cdoObject, eFeature, index);
- }
- catch (ObjectNotFoundException ex)
- {
- // Ignore the exception
- }
- }
- }
-
- /**
- * @since 2.0
- */
- public static void load(EObject eObject, CDOView view)
- {
- InternalCDOObject cdoObject = FSMUtil.adapt(eObject, view);
- CDOStateMachine.INSTANCE.read(cdoObject);
-
- for (Iterator<InternalCDOObject> it = FSMUtil.iterator(cdoObject.eContents(), (InternalCDOView)view); it.hasNext();)
- {
- InternalCDOObject content = it.next();
- load(content, view);
- }
- }
-
- /**
- * @since 2.0
- */
- public static EObject getEObject(EObject object)
- {
- if (object instanceof InternalCDOObject)
- {
- return ((InternalCDOObject)object).cdoInternalInstance();
- }
-
- return object;
- }
-
- /**
- * @since 2.0
- */
- public static CDOObject getCDOObject(EObject object)
- {
- if (object instanceof CDOObject)
- {
- return (CDOObject)object;
- }
-
- return FSMUtil.adaptLegacy((InternalEObject)object);
- }
-
- /**
- * @since 2.0
- */
- public static CDORevision getRevisionByVersion(CDOObject object, int version)
- {
- if (FSMUtil.isTransient(object))
- {
- return null;
- }
-
- CDORevision revision = CDOStateMachine.INSTANCE.read((InternalCDOObject)object);
- return getRevisionByVersion(object, revision.getBranch(), version, revision);
- }
-
- /**
- * @since 3.0
- */
- public static CDORevision getRevisionByVersion(CDOObject object, CDOBranch branch, int version)
- {
- if (FSMUtil.isTransient(object))
- {
- return null;
- }
-
- CDORevision revision = CDOStateMachine.INSTANCE.read((InternalCDOObject)object);
- return getRevisionByVersion(object, branch, version, revision);
- }
-
- private static CDORevision getRevisionByVersion(CDOObject object, CDOBranch branch, int version, CDORevision revision)
- {
- if (revision.getVersion() != version)
- {
- CDOSession session = object.cdoView().getSession();
- if (!session.getRepositoryInfo().isSupportingAudits())
- {
- throw new IllegalStateException(Messages.getString("CDOUtil.0")); //$NON-NLS-1$
- }
-
- revision = session.getRevisionManager().getRevisionByVersion(object.cdoID(), branch.getVersion(version), 0, true);
- }
-
- return revision;
- }
-
- /**
- * @since 2.0
- */
- public static EList<Resource> getResources(ResourceSet resourceSet)
- {
- EList<Resource> result = new BasicEList<Resource>();
- EList<Resource> resources = resourceSet.getResources();
- for (Resource resource : resources)
- {
- if (resource instanceof CDOResource)
- {
- CDOResource cdoResource = (CDOResource)resource;
- if (cdoResource.isRoot())
- {
- continue;
- }
- }
-
- result.add(resource);
- }
-
- return result;
- }
-
- /**
- * Returns <code>true</code> if the given {@link CDOSession session} contains a dirty {@link CDOTransaction
- * transaction}, <code>false</code> otherwise.
- *
- * @since 2.0
- * @see CDOTransaction
- */
- public static boolean isSessionDirty(CDOSession session)
- {
- for (CDOView view : session.getElements())
- {
- if (view.isDirty())
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @since 3.0
- * @deprecated As of 4.0 use CDOView.isInvalidationRunnerActive()
- */
- @Deprecated
- public static boolean isInvalidationRunnerActive()
- {
- throw new UnsupportedOperationException("Use CDOView.isInvalidationRunnerActive()");
- }
-
- /**
- * @since 3.0
- */
- public static boolean isLegacyObject(EObject object)
- {
- return object instanceof CDOObjectWrapper;
- }
-
- /**
- * @since 3.0
- */
- public static boolean isLegacyModeDefault()
- {
- return legacyModeDefault.get();
- }
-
- /**
- * @since 3.0
- */
- public static void setLegacyModeDefault(boolean on)
- {
- legacyModeDefault.set(on);
- }
-
- /**
- * @since 4.0
- */
- public static void setCredentialsProvider(URI uri, IPasswordCredentialsProvider provider)
- {
- CDOURIData data = new CDOURIData(uri);
- data.setUserName(null);
- data.setPassWord(null);
- data.setResourcePath(null);
- data.setBranchPath(null);
- data.setTimeStamp(CDOBranchPoint.UNSPECIFIED_DATE);
- data.setTransactional(false);
-
- String resource = data.toString();
- IPluginContainer.INSTANCE.putElement("org.eclipse.net4j.util.credentialsProviders", "password", resource, provider);
- }
-}
+/* + * Copyright (c) 2004 - 2012 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 - maintenance + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.util; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFactory; +import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionManager; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.transaction.CDOXATransaction; +import org.eclipse.emf.cdo.view.CDOFeatureAnalyzer; +import org.eclipse.emf.cdo.view.CDOFetchRuleManager; +import org.eclipse.emf.cdo.view.CDORevisionPrefetchingPolicy; +import org.eclipse.emf.cdo.view.CDOStaleObject; +import org.eclipse.emf.cdo.view.CDOView; +import org.eclipse.emf.cdo.view.CDOViewSet; + +import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerModelBased; +import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerUI; +import org.eclipse.emf.internal.cdo.analyzer.CDOFetchRuleManagerThreadLocal; +import org.eclipse.emf.internal.cdo.bundle.OM; +import org.eclipse.emf.internal.cdo.messages.Messages; +import org.eclipse.emf.internal.cdo.object.CDOFactoryImpl; +import org.eclipse.emf.internal.cdo.object.CDOObjectWrapper; +import org.eclipse.emf.internal.cdo.session.CDOCollectionLoadingPolicyImpl; +import org.eclipse.emf.internal.cdo.transaction.CDOXATransactionImpl; +import org.eclipse.emf.internal.cdo.transaction.CDOXATransactionImpl.CDOXAInternalAdapter; +import org.eclipse.emf.internal.cdo.view.CDORevisionPrefetchingPolicyImpl; +import org.eclipse.emf.internal.cdo.view.CDOStateMachine; + +import org.eclipse.net4j.util.AdapterUtil; +import org.eclipse.net4j.util.container.IPluginContainer; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.security.IPasswordCredentialsProvider; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.spi.cdo.FSMUtil; +import org.eclipse.emf.spi.cdo.InternalCDOObject; +import org.eclipse.emf.spi.cdo.InternalCDOView; + +import java.util.Iterator; +import java.util.Map; + +/** + * Various static methods that may help in CDO client applications. + * + * @author Eike Stepper + */ +public final class CDOUtil +{ + private static final ThreadLocal<Boolean> legacyModeDefault = new InheritableThreadLocal<Boolean>() + { + @Override + protected Boolean initialValue() + { + return false; + } + }; + + static + { + if (!OMPlatform.INSTANCE.isOSGiRunning()) + { + registerResourceFactory(Resource.Factory.Registry.INSTANCE); + } + } + + private CDOUtil() + { + } + + /** + * @since 4.0 + */ + public static boolean registerResourceFactory(Resource.Factory.Registry registry) + { + if (registry == null) + { + return false; + } + + Map<String, Object> map = registry.getProtocolToFactoryMap(); + if (!map.containsKey(CDOURIUtil.PROTOCOL_NAME)) + { + map.put(CDOURIUtil.PROTOCOL_NAME, CDOResourceFactory.INSTANCE); + return true; + } + + return false; + } + + /** + * @since 3.0 + */ + public static CDOSession getSession(Object object) + { + if (object == null) + { + return null; + } + + CDOSession session = AdapterUtil.adapt(object, CDOSession.class); + if (session != null) + { + return session; + } + + CDOView view = AdapterUtil.adapt(object, CDOView.class); + if (view != null) + { + return view.getSession(); + } + + CDOObject cdoObject = AdapterUtil.adapt(object, CDOObject.class); + if (cdoObject != null) + { + return cdoObject.cdoView().getSession(); + } + + CDORemoteSessionManager remoteSessionManager = AdapterUtil.adapt(object, CDORemoteSessionManager.class); + if (remoteSessionManager != null) + { + return remoteSessionManager.getLocalSession(); + } + + return null; + } + + /** + * @since 2.0 + */ + public static boolean prepareDynamicEPackage(EPackage startPackage) + { + if (CDOFactoryImpl.prepareDynamicEPackage(startPackage)) + { + for (EPackage subPackage : startPackage.getESubpackages()) + { + prepareDynamicEPackage(subPackage); + } + + return true; + } + + return false; + } + + /** + * @since 2.0 + */ + public static CDOCollectionLoadingPolicy createCollectionLoadingPolicy(int initialChunkSize, int resolveChunkSize) + { + return new CDOCollectionLoadingPolicyImpl(initialChunkSize, resolveChunkSize); + } + + /** + * @since 2.0 + */ + public static CDORevisionPrefetchingPolicy createRevisionPrefetchingPolicy(int chunkSize) + { + if (chunkSize <= 0) + { + return CDORevisionPrefetchingPolicy.NO_PREFETCHING; + } + + return new CDORevisionPrefetchingPolicyImpl(chunkSize); + } + + /** + * @since 4.1 + */ + public static CDOFetchRuleManager createThreadLocalFetchRuleManager() + { + return new CDOFetchRuleManagerThreadLocal(); + } + + /** + * @since 4.1 + */ + public static CDOFeatureAnalyzer createModelBasedFeatureAnalyzer() + { + return new CDOFeatureAnalyzerModelBased(); + } + + /** + * @since 4.1 + */ + public static CDOFeatureAnalyzer createUIFeatureAnalyzer() + { + return new CDOFeatureAnalyzerUI(); + } + + /** + * @since 4.1 + */ + public static CDOFeatureAnalyzer createUIFeatureAnalyzer(long maxTimeBetweenOperation) + { + return new CDOFeatureAnalyzerUI(maxTimeBetweenOperation); + } + + /** + * @since 4.0 + */ + public static CDOXATransaction createXATransaction(Notifier... notifiers) + { + CDOXATransaction xaTransaction = new CDOXATransactionImpl(); + for (Notifier notifier : notifiers) + { + CDOViewSet viewSet = getViewSet(notifier); + if (viewSet == null) + { + throw new IllegalArgumentException("Notifier is not associated with a CDOViewSet: " + notifier); + } + + try + { + xaTransaction.add(viewSet); + } + catch (IllegalArgumentException ex) + { + OM.LOG.warn(ex); + } + } + + return xaTransaction; + } + + /** + * @since 2.0 + */ + public static CDOXATransaction getXATransaction(CDOViewSet viewSet) + { + EList<Adapter> adapters = viewSet.eAdapters(); + for (Adapter adapter : adapters) + { + if (adapter instanceof CDOXAInternalAdapter) + { + return ((CDOXAInternalAdapter)adapter).getXATransaction(); + } + } + + return null; + } + + /** + * @since 4.0 + */ + public static CDOViewSet getViewSet(Notifier notifier) + { + if (notifier instanceof CDOViewSet) + { + return (CDOViewSet)notifier; + } + + EList<Adapter> adapters = notifier.eAdapters(); + for (Adapter adapter : adapters) + { + if (adapter instanceof CDOViewSet) + { + return (CDOViewSet)adapter; + } + } + + if (notifier instanceof InternalEObject) + { + InternalEObject object = (InternalEObject)notifier; + EObject container = object.eContainer(); + if (container != null) + { + CDOViewSet viewSet = getViewSet(container); + if (viewSet != null) + { + return viewSet; + } + } + + Resource.Internal resource = object.eDirectResource(); + if (resource != null) + { + CDOViewSet viewSet = getViewSet(resource); + if (viewSet != null) + { + return viewSet; + } + } + } + + if (notifier instanceof Resource) + { + Resource resource = (Resource)notifier; + ResourceSet resourceSet = resource.getResourceSet(); + if (resourceSet != null) + { + CDOViewSet viewSet = getViewSet(resourceSet); + if (viewSet != null) + { + return viewSet; + } + } + } + + return null; + } + + /** + * @since 3.0 + */ + public static boolean isStaleObject(Object object) + { + return object instanceof CDOStaleObject; + } + + /** + * @since 3.0 + */ + public static void cleanStaleReference(EObject eObject, EStructuralFeature eFeature) + { + if (!eFeature.isMany() && eFeature.getEContainingClass() != null) + { + InternalCDOObject cdoObject = (InternalCDOObject)getCDOObject(eObject); + cdoObject.eStore().unset(cdoObject, eFeature); + } + } + + /** + * @since 3.0 + */ + public static void cleanStaleReference(EObject eObject, EStructuralFeature eFeature, int index) + { + if (eFeature.isMany() && eFeature.getEContainingClass() != null) + { + InternalCDOObject cdoObject = (InternalCDOObject)getCDOObject(eObject); + try + { + cdoObject.eStore().remove(cdoObject, eFeature, index); + } + catch (ObjectNotFoundException ex) + { + // Ignore the exception + } + } + } + + /** + * @since 2.0 + */ + public static void load(EObject eObject, CDOView view) + { + InternalCDOObject cdoObject = FSMUtil.adapt(eObject, view); + CDOStateMachine.INSTANCE.read(cdoObject); + + for (Iterator<InternalCDOObject> it = FSMUtil.iterator(cdoObject.eContents(), (InternalCDOView)view); it.hasNext();) + { + InternalCDOObject content = it.next(); + load(content, view); + } + } + + /** + * @since 2.0 + */ + public static EObject getEObject(EObject object) + { + if (object instanceof InternalCDOObject) + { + return ((InternalCDOObject)object).cdoInternalInstance(); + } + + return object; + } + + /** + * @since 2.0 + */ + public static CDOObject getCDOObject(EObject object) + { + if (object instanceof CDOObject) + { + return (CDOObject)object; + } + + return FSMUtil.adaptLegacy((InternalEObject)object); + } + + /** + * @since 2.0 + */ + public static CDORevision getRevisionByVersion(CDOObject object, int version) + { + if (FSMUtil.isTransient(object)) + { + return null; + } + + CDORevision revision = CDOStateMachine.INSTANCE.read((InternalCDOObject)object); + return getRevisionByVersion(object, revision.getBranch(), version, revision); + } + + /** + * @since 3.0 + */ + public static CDORevision getRevisionByVersion(CDOObject object, CDOBranch branch, int version) + { + if (FSMUtil.isTransient(object)) + { + return null; + } + + CDORevision revision = CDOStateMachine.INSTANCE.read((InternalCDOObject)object); + return getRevisionByVersion(object, branch, version, revision); + } + + private static CDORevision getRevisionByVersion(CDOObject object, CDOBranch branch, int version, CDORevision revision) + { + if (revision.getVersion() != version) + { + CDOSession session = object.cdoView().getSession(); + if (!session.getRepositoryInfo().isSupportingAudits()) + { + throw new IllegalStateException(Messages.getString("CDOUtil.0")); //$NON-NLS-1$ + } + + revision = session.getRevisionManager().getRevisionByVersion(object.cdoID(), branch.getVersion(version), 0, true); + } + + return revision; + } + + /** + * @since 2.0 + */ + public static EList<Resource> getResources(ResourceSet resourceSet) + { + EList<Resource> result = new BasicEList<Resource>(); + EList<Resource> resources = resourceSet.getResources(); + for (Resource resource : resources) + { + if (resource instanceof CDOResource) + { + CDOResource cdoResource = (CDOResource)resource; + if (cdoResource.isRoot()) + { + continue; + } + } + + result.add(resource); + } + + return result; + } + + /** + * Returns <code>true</code> if the given {@link CDOSession session} contains a dirty {@link CDOTransaction + * transaction}, <code>false</code> otherwise. + * + * @since 2.0 + * @see CDOTransaction + */ + public static boolean isSessionDirty(CDOSession session) + { + for (CDOView view : session.getElements()) + { + if (view.isDirty()) + { + return true; + } + } + + return false; + } + + /** + * @since 3.0 + * @deprecated As of 4.0 use CDOView.isInvalidationRunnerActive() + */ + @Deprecated + public static boolean isInvalidationRunnerActive() + { + throw new UnsupportedOperationException("Use CDOView.isInvalidationRunnerActive()"); + } + + /** + * @since 3.0 + */ + public static boolean isLegacyObject(EObject object) + { + return object instanceof CDOObjectWrapper; + } + + /** + * @since 3.0 + */ + public static boolean isLegacyModeDefault() + { + return legacyModeDefault.get(); + } + + /** + * @since 3.0 + */ + public static void setLegacyModeDefault(boolean on) + { + legacyModeDefault.set(on); + } + + /** + * @since 4.0 + */ + public static void setCredentialsProvider(URI uri, IPasswordCredentialsProvider provider) + { + CDOURIData data = new CDOURIData(uri); + data.setUserName(null); + data.setPassWord(null); + data.setResourcePath(null); + data.setBranchPath(null); + data.setTimeStamp(CDOBranchPoint.UNSPECIFIED_DATE); + data.setTransactional(false); + + String resource = data.toString(); + IPluginContainer.INSTANCE.putElement("org.eclipse.net4j.util.credentialsProviders", "password", resource, provider); + } +} |