Ejemplo n.º 1
0
  @Override
  public Path save(
      final Path path, final KModuleModel content, final Metadata metadata, final String comment) {
    try {
      if (metadata == null) {
        ioService.write(
            paths.convert(path),
            moduleContentHandler.toString(content),
            makeCommentedOption(comment));
      } else {
        ioService.write(
            paths.convert(path),
            moduleContentHandler.toString(content),
            metadataService.setUpAttributes(path, metadata),
            makeCommentedOption(comment));
      }

      // The pom.xml, kmodule.xml and project.imports are all saved from ProjectScreenPresenter
      // We only raise InvalidateDMOProjectCacheEvent and ResourceUpdatedEvent(pom.xml) events once
      // in POMService.save to avoid duplicating events (and re-construction of DMO).

      return path;

    } catch (Exception e) {
      e.printStackTrace();
      throw ExceptionUtilities.handleException(e);
    }
  }
Ejemplo n.º 2
0
  @Override
  public Path setUpKModuleStructure(final Path projectRoot) {
    try {
      // Create project structure
      final org.kie.commons.java.nio.file.Path nioRoot = paths.convert(projectRoot);

      ioService.createDirectory(nioRoot.resolve("src/main/java"));
      ioService.createDirectory(nioRoot.resolve("src/main/resources"));
      ioService.createDirectory(nioRoot.resolve("src/test/java"));
      ioService.createDirectory(nioRoot.resolve("src/test/resources"));

      final org.kie.commons.java.nio.file.Path pathToKModuleXML =
          nioRoot.resolve("src/main/resources/META-INF/kmodule.xml");
      ioService.createFile(pathToKModuleXML);
      ioService.write(pathToKModuleXML, moduleContentHandler.toString(new KModuleModel()));

      // Don't raise a NewResourceAdded event as this is handled at the Project level in
      // ProjectServices

      return paths.convert(pathToKModuleXML);

    } catch (Exception e) {
      throw ExceptionUtilities.handleException(e);
    }
  }
Ejemplo n.º 3
0
 @Override
 public void saveKModule(
     String commitMessage, final Path path, final KModuleModel model, Metadata metadata) {
   if (metadata == null) {
     ioService.write(
         paths.convert(path),
         moduleContentHandler.toString(model),
         makeCommentedOption(commitMessage));
   } else {
     ioService.write(
         paths.convert(path),
         moduleContentHandler.toString(model),
         metadataService.setUpAttributes(path, metadata),
         makeCommentedOption(commitMessage));
   }
 }
Ejemplo n.º 4
0
 private void saveKModule(
     final org.kie.commons.java.nio.file.Path path, final KModuleModel model) {
   ioService.write(path, moduleContentHandler.toString(model));
 }