Exemple #1
0
  /** @since 3.0 */
  public void read(CDODataInput in) throws IOException {
    if (READING.isEnabled()) {
      READING.start(this);
    }

    readSystemValues(in);

    flags = in.readByte(); // Don't set permissions into this.falgs before readValues()
    flags |= UNCHUNKED_FLAG; // First assume all lists are unchunked; may be revised below
    flags |=
        BYPASS_PERMISSION_CHECKS_FLAG; // Temporarily disable permission checking to be able to set
                                       // the read values

    if ((flags & PERMISSION_MASK) == CDOPermission.NONE.ordinal()) {
      if (getClassInfo().isResourceNode()) {
        clearValues();

        EClass eClass = getEClass();
        EStructuralFeature[] features = getAllPersistentFeatures();
        readValue(in, eClass, features, RESOURCE_NODE_NAME_INDEX, true);

        if (getClassInfo().isResourceFolder()) {
          if (!readValue(in, eClass, features, RESOURCE_FOLDER_NODES_INDEX, true)) {
            flags &= ~UNCHUNKED_FLAG;
          }
        }
      }
    } else {
      if (!readValues(in)) {
        flags &= ~UNCHUNKED_FLAG;
      }
    }

    // Enable permission checking
    flags &= ~BYPASS_PERMISSION_CHECKS_FLAG;

    if (READING.isEnabled()) {
      READING.stop(this);
    }
  }
Exemple #2
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);
    }
  }