Example #1
0
  private BinaryAttachments processBinaryAttachments(
      final VirtualFile nodeFile, final Node newNode) {
    final PropertyTree data = newNode.data();

    final ImmutableList<Property> binaryReferences =
        data.getProperties(ValueTypes.BINARY_REFERENCE);

    if (binaryReferences.isEmpty()) {
      return BinaryAttachments.empty();
    }

    final BinaryAttachments.Builder builder = BinaryAttachments.create();

    for (final Property binaryReference : binaryReferences) {
      addBinary(nodeFile, builder, binaryReference);
    }

    return builder.build();
  }
Example #2
0
  private void addBinary(
      final VirtualFile nodeFile,
      final BinaryAttachments.Builder builder,
      final Property binaryRefProperty) {
    final BinaryReference binaryReference = binaryRefProperty.getBinaryReference();

    try {
      final VirtualFile binary = exportReader.getBinarySource(nodeFile, binaryReference.toString());
      builder.add(new BinaryAttachment(binaryReference, binary.getByteSource()));

      result.addBinary(binary.getPath().getPath(), binaryReference);
    } catch (Exception e) {
      result.addError("Error processing binary, skip", e);
    }
  }