Exemplo n.º 1
0
 private BuildValidationHelper getBuildValidationHelper(final Path nioResource) {
   for (BuildValidationHelper validator : buildValidationHelpers) {
     final org.uberfire.backend.vfs.Path resource = Paths.convert(nioResource);
     if (validator.accepts(resource)) {
       return validator;
     }
   }
   return null;
 }
Exemplo n.º 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;
    }
  }
Exemplo n.º 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));
  }