예제 #1
0
  private void importFromManualOrder(final VirtualFile nodeFolder) {
    final List<String> childNames;

    try {
      final List<String> relativeChildNames = processBinarySource(nodeFolder);
      childNames = getChildrenAbsolutePaths(nodeFolder, relativeChildNames);

    } catch (Exception e) {
      result.addError("Not able to import nodes by manual order, using default ordering", e);
      importFromDirectoryLayout(nodeFolder);
      return;
    }

    long currentManualOrderValue = IMPORT_NODE_ORDER_START_VALUE;

    for (final String childName : childNames) {
      final VirtualFile child = nodeFolder.resolve(VirtualFilePaths.from(childName, "/"));

      final ProcessNodeSettings.Builder processNodeSettings =
          ProcessNodeSettings.create()
              .insertManualStrategy(InsertManualStrategy.MANUAL)
              .manualOrderValue(currentManualOrderValue);

      if (child != null) {
        processNodeFolder(child, processNodeSettings);
      }

      currentManualOrderValue -= IMPORT_NODE_ORDER_SPACE;
    }
  }
예제 #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);
    }
  }
예제 #3
0
  private void processNodeFolder(
      final VirtualFile nodeFolder, final ProcessNodeSettings.Builder processNodeSettings) {
    try {
      final Node node = processNodeSource(nodeFolder, processNodeSettings);

      try {
        if (!node.getChildOrder().isManualOrder()) {
          importFromDirectoryLayout(nodeFolder);
        } else {
          importFromManualOrder(nodeFolder);
        }
      } catch (Exception e) {
        result.addError("Error when parsing children of " + node.path(), e);
      }

    } catch (Exception e) {
      result.addError(
          "Could not import node in folder ["
              + nodeFolder.getPath().getPath()
              + "]: "
              + e.getMessage(),
          e);
    }
  }