Exemplo n.º 1
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);
    }
  }
Exemplo n.º 2
0
  @Override
  public Path setUpKModuleStructure(final Path pathToPom) {
    try {
      // Create project structure
      final org.kie.commons.java.nio.file.Path directory = getPomDirectoryPath(pathToPom);

      ioService.createDirectory(directory.resolve("src/main/java"));
      ioService.createDirectory(directory.resolve("src/main/resources"));
      final org.kie.commons.java.nio.file.Path pathToKModuleXML =
          directory.resolve("src/main/resources/META-INF/kmodule.xml");
      saveKModule(pathToKModuleXML, new KModuleModel());

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

      return paths.convert(pathToKModuleXML);
    } catch (Exception e) {
      return null;
    }
  }
Exemplo n.º 3
0
  public String[] listUsers() {
    // TODO: a temporary hack to retrieve user list. Please refactor later.
    List<String> userList = new ArrayList<String>();
    org.kie.commons.java.nio.file.Path userRoot = bootstrapRoot.resolve("/.metadata/.users/");
    final Iterator<org.kie.commons.java.nio.file.Path> userIterator = userRoot.iterator();
    if (userIterator.hasNext()) {
      org.kie.commons.java.nio.file.Path userDir = userIterator.next();
      userList.add(userDir.getFileName().toString());
    }

    String[] result = new String[userList.size()];
    return userList.toArray(result);
  }
Exemplo n.º 4
0
  @Override
  public Path pathToRelatedKModuleFileIfAny(final Path pathToPomXML) {
    final org.kie.commons.java.nio.file.Path directory = getPomDirectoryPath(pathToPomXML);

    final org.kie.commons.java.nio.file.Path pathToKModuleXML =
        directory.resolve("src/main/resources/META-INF/kmodule.xml");

    if (ioService.exists(pathToKModuleXML)) {
      return paths.convert(pathToKModuleXML);
    } else {
      return null;
    }
  }