コード例 #1
0
  private void visitPaths(final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream) {
    for (final org.uberfire.java.nio.file.Path path : directoryStream) {
      if (Files.isDirectory(path)) {
        visitPaths(Files.newDirectoryStream(path));

      } else {
        // Don't process dotFiles
        if (!dotFileFilter.accept(path)) {

          // Resource Type might require "external" validation (i.e. it's not covered by Kie)
          final BuildValidationHelper validator = getBuildValidationHelper(path);
          if (validator != null) {
            nonKieResourceValidationHelpers.put(path, validator);
          }

          // Add new resource
          final String destinationPath =
              path.toUri().toString().substring(projectPrefix.length() + 1);
          final InputStream is = ioService.newInputStream(path);
          final BufferedInputStream bis = new BufferedInputStream(is);
          kieFileSystem.write(
              destinationPath,
              KieServices.Factory.get().getResources().newInputStreamResource(bis));
          handles.put(getBaseFileName(destinationPath), Paths.convert(path));

          // Java classes are handled by KIE so we can safely post-process them here
          addJavaClass(path);
        }
      }
    }
  }
コード例 #2
0
  public IncrementalBuildResults addResource(final Path resource) {
    synchronized (kieFileSystem) {
      checkNotNull("resource", resource);

      // Only files can be processed
      if (!Files.isRegularFile(resource)) {
        return new IncrementalBuildResults(projectGAV);
      }

      checkAFullBuildHasBeenPerformed();

      // Resource Type might require "external" validation (i.e. it's not covered by Kie)
      final IncrementalBuildResults results = new IncrementalBuildResults(projectGAV);
      final BuildValidationHelper validator = getBuildValidationHelper(resource);
      if (validator != null) {
        final List<ValidationMessage> addedValidationMessages =
            validator.validate(Paths.convert(resource));

        results.addAllAddedMessages(convertValidationMessages(addedValidationMessages));
        results.addAllRemovedMessages(
            convertValidationMessages(nonKieResourceValidationHelperMessages.remove(resource)));

        nonKieResourceValidationHelpers.put(resource, validator);
        nonKieResourceValidationHelperMessages.put(resource, addedValidationMessages);
      }

      // Add new resource
      final String destinationPath =
          resource.toUri().toString().substring(projectPrefix.length() + 1);
      final InputStream is = ioService.newInputStream(resource);
      final BufferedInputStream bis = new BufferedInputStream(is);
      kieFileSystem.write(
          destinationPath, KieServices.Factory.get().getResources().newInputStreamResource(bis));
      addJavaClass(resource);
      handles.put(getBaseFileName(destinationPath), Paths.convert(resource));

      buildIncrementally(results, destinationPath);

      return results;
    }
  }
コード例 #3
0
  private void update(
      final List<ValidationMessage> nonKieResourceValidatorAddedMessages,
      final List<ValidationMessage> nonKieResourceValidatorRemovedMessages,
      final Path resource,
      final String destinationPath) {
    // Resource Type might require "external" validation (i.e. it's not covered by Kie)
    final BuildValidationHelper validator = getBuildValidationHelper(resource);
    if (validator != null) {
      final List<ValidationMessage> addedValidationMessages =
          validator.validate(Paths.convert(resource));

      if (!(addedValidationMessages == null || addedValidationMessages.isEmpty())) {
        for (ValidationMessage validationMessage : addedValidationMessages) {
          nonKieResourceValidatorAddedMessages.add(validationMessage);
        }
      }

      final List<ValidationMessage> removedValidationMessages =
          nonKieResourceValidationHelperMessages.remove(resource);
      if (!(removedValidationMessages == null || removedValidationMessages.isEmpty())) {
        for (ValidationMessage validationMessage : removedValidationMessages) {
          nonKieResourceValidatorRemovedMessages.add(validationMessage);
        }
      }
      nonKieResourceValidationHelpers.put(resource, validator);
      nonKieResourceValidationHelperMessages.put(resource, addedValidationMessages);
    }

    // Add new resource
    final InputStream is = ioService.newInputStream(resource);
    final BufferedInputStream bis = new BufferedInputStream(is);
    kieFileSystem.write(
        destinationPath, KieServices.Factory.get().getResources().newInputStreamResource(bis));
    addJavaClass(resource);
    handles.put(getBaseFileName(destinationPath), Paths.convert(resource));
  }