示例#1
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);
  }
示例#2
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;
    }
  }
  @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);
    }
  }
  @Override
  public boolean accept(final org.kie.commons.java.nio.file.Path path) {
    // Check with super class first
    boolean accept = super.accept(path);
    if (!accept) {
      return accept;
    }

    // Only match files
    if (!Files.isRegularFile(path)) {
      return false;
    }

    // Assume the Path does not match by default
    accept = false;
    final String uri = path.toUri().toString();
    for (String extension : extensions) {
      if (uri.substring(uri.length() - extension.length()).equals(extension)) {
        accept = true;
        break;
      }
    }
    return accept;
  }
示例#5
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;
    }
  }