@Override
  protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException {
    if (TRACER.isEnabled()) {
      TRACER.format("Requesting %s of user credentials", operation); // $NON-NLS-1$
    }

    out.writeEnum(operation);
    out.writeString(userID);
  }
  @Override
  public void write(ExtendedDataOutput out) throws IOException {
    // TODO: change the parameter to prevent casting to CDODataInput
    CDODataOutput cdoDataOutput = (CDODataOutput) out;
    cdoDataOutput.writeCDOClassifierRef(classifierRef);

    // and let the super write the rest
    super.write(out);
  }
  @Override
  protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException {
    out.writeInt(viewID);
    out.writeCDOBranchPoint(branchPoint);

    out.writeInt(invalidObjects.size());
    for (InternalCDOObject object : invalidObjects) {
      out.writeCDOID(object.cdoID());
    }
  }
Example #4
0
  /** @since 4.0 */
  protected void writeSystemValues(CDODataOutput out) throws IOException {
    EClass eClass = getEClass();
    CDOClassifierRef classRef = new CDOClassifierRef(eClass);

    if (TRACER.isEnabled()) {
      TRACER.format(
          "Writing revision: ID={0}, className={1}, version={2}, branchPoint={3}, revised={4}, resource={5}, container={6}, featureID={7}", //$NON-NLS-1$
          id,
          eClass.getName(),
          getVersion(),
          branchPoint,
          revised,
          resourceID,
          containerID,
          containingFeatureID);
    }

    out.writeCDOClassifierRef(classRef);
    out.writeCDOID(id);
    out.writeCDOBranchPoint(branchPoint);
    out.writeInt(getVersion());
    if (!id.isTemporary()) {
      out.writeLong(revised);
    }

    out.writeCDOID(resourceID);
    out.writeCDOID(out.getIDProvider().provideCDOID(containerID));
    out.writeInt(containingFeatureID);
  }
  @Override
  protected void responding(CDODataOutput out, OMMonitor monitor) throws IOException {
    out.writeInt(allChangedObjects.size());
    for (CDORevisionDelta delta : allChangedObjects) {
      out.writeCDORevisionDelta(delta);
    }

    out.writeInt(allDetachedObjects.size());
    for (CDOID id : allDetachedObjects) {
      out.writeCDOID(id);
    }
  }
Example #6
0
  @Override
  protected void requesting(CDODataOutput out) throws IOException {
    out.writeInt(viewID);
    out.writeCDOLockType(lockType);
    out.writeBoolean(recursive);
    if (objectIDs == null) {
      if (TRACER.isEnabled()) {
        TRACER.format("Unlocking all objects for view {0}", viewID); // $NON-NLS-1$
      }

      out.writeInt(CDOProtocolConstants.RELEASE_ALL_LOCKS);
    } else {
      if (TRACER.isEnabled()) {
        TRACER.format(
            "Unlocking of type {0} requested for view {1}",
            lockType == LockType.READ
                ? "read" //$NON-NLS-1$ //$NON-NLS-2$
                : "write",
            viewID); //$NON-NLS-1$
      }

      out.writeInt(objectIDs.size());
      for (CDOID id : objectIDs) {
        if (TRACER.isEnabled()) {
          TRACER.format("Unlocking requested for object {0}", id); // $NON-NLS-1$
        }

        out.writeCDOID(id);
      }
    }
  }
Example #7
0
  /** @since 4.1 */
  public void write(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext)
      throws IOException {
    if (WRITING.isEnabled()) {
      WRITING.start(this);
    }

    writeSystemValues(out);

    CDOPermissionProvider permissionProvider = out.getPermissionProvider();
    CDOPermission permission = permissionProvider.getPermission(this, securityContext);
    out.writeByte(permission.getBits());

    if (permission == CDOPermission.NONE) {
      if (getClassInfo().isResourceNode()) {
        EClass eClass = getEClass();
        EStructuralFeature[] features = getAllPersistentFeatures();
        writeValue(out, eClass, features, RESOURCE_NODE_NAME_INDEX, referenceChunk);

        if (getClassInfo().isResourceFolder()) {
          writeValue(out, eClass, features, RESOURCE_FOLDER_NODES_INDEX, referenceChunk);
        }
      }
    } else {
      if (!isUnchunked() && referenceChunk != 0) {
        CDORevisionUnchunker unchunker = out.getRevisionUnchunker();
        if (unchunker != null) {
          unchunker.ensureChunks(this, referenceChunk);
        }
      }

      writeValues(out, referenceChunk);
    }

    if (WRITING.isEnabled()) {
      WRITING.stop(this);
    }
  }
Example #8
0
  @Override
  protected void requesting(CDODataOutput out) throws IOException {
    out.writeInt(viewID);
    out.writeCDOLockType(lockType);
    out.writeBoolean(recursive);
    out.writeLong(timeout);

    out.writeInt(revisionKeys.size());
    for (CDORevisionKey revKey : revisionKeys) {
      out.writeCDORevisionKey(revKey);
    }
  }
  @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);
  }
Example #10
0
  private void writeValue(
      CDODataOutput out, EClass owner, EStructuralFeature[] features, int i, int referenceChunk)
      throws IOException {
    EStructuralFeature feature = features[i];
    Object value = getValue(i);
    if (value == null) {
      // Feature is NOT set
      out.writeByte(UNSET_OPCODE);
      return;
    }

    // Feature IS set
    if (value == CDORevisionData.NIL) {
      // Feature IS null
      out.writeByte(SET_NULL_OPCODE);
      return;
    }

    // Feature is NOT null
    out.writeByte(SET_NOT_NULL_OPCODE);
    if (feature.isMany()) {
      CDOList list = (CDOList) value;
      out.writeCDOList(owner, feature, list, referenceChunk);
    } else {
      checkNoFeatureMap(feature);
      if (feature instanceof EReference) {
        value = out.getIDProvider().provideCDOID(value);
      }

      if (TRACER.isEnabled()) {
        TRACER.format("Writing feature {0}: {1}", feature.getName(), value);
      }

      out.writeCDOFeatureValue(feature, value);
    }
  }
Example #11
0
 @Override
 protected void responding(CDODataOutput out) throws IOException {
   out.writeBoolean(isLocked);
 }