Esempio n. 1
0
 @Override
 public String getConfigDir() {
   if (Strings.isBlank(configDir)) {
     // lets default to the users home directory
     String home = System.getProperty("user.home", "~");
     configDir = home + System.getProperty("hawtio.dirname", "/.hawtio");
   }
   return configDir;
 }
Esempio n. 2
0
 protected FileInfo doExists(Git git, File rootDir, String branch, String pathOrEmpty)
     throws GitAPIException {
   checkoutBranch(git, branch);
   final String path = Strings.isBlank(pathOrEmpty) ? "/" : pathOrEmpty;
   File file = getFile(rootDir, path);
   if (file.exists()) {
     return FileInfo.createFileInfo(rootDir, file);
   }
   return null;
 }
Esempio n. 3
0
 protected List<String> doCompletePath(
     Git git, File rootDir, String branch, String completionText, boolean directoriesOnly)
     throws GitAPIException {
   checkoutBranch(git, branch);
   boolean empty = Strings.isBlank(completionText);
   String pattern = completionText;
   File file = getFile(rootDir, completionText);
   String prefix = completionText;
   if (file.exists()) {
     pattern = "";
   } else {
     String startPath = ".";
     if (!empty) {
       int idx = completionText.lastIndexOf('/');
       if (idx >= 0) {
         startPath = completionText.substring(0, idx);
         if (startPath.length() == 0) {
           startPath = "/";
         }
         pattern = completionText.substring(idx + 1);
       }
     }
     file = getFile(rootDir, startPath);
     prefix = startPath;
   }
   if (prefix.length() > 0 && !prefix.endsWith("/")) {
     prefix += "/";
   }
   if (prefix.equals("./")) {
     prefix = "";
   }
   File[] list = file.listFiles();
   List<String> answer = new ArrayList<String>();
   for (File aFile : list) {
     String name = aFile.getName();
     if (pattern.length() == 0 || name.contains(pattern)) {
       if (!isIgnoreFile(aFile) && (!directoriesOnly || aFile.isDirectory())) {
         answer.add(prefix + name);
       }
     }
   }
   return answer;
 }
Esempio n. 4
0
 /** Reads the file contents from the currently checked out branch */
 protected FileContents doRead(Git git, File rootDir, String branch, String pathOrEmpty)
     throws IOException, GitAPIException {
   checkoutBranch(git, branch);
   String path = Strings.isBlank(pathOrEmpty) ? "/" : pathOrEmpty;
   File file = getFile(rootDir, path);
   if (file.isFile()) {
     String contents = IOHelper.readFully(file);
     return new FileContents(false, contents, null);
   } else {
     List<FileInfo> children = new ArrayList<FileInfo>();
     if (file.exists()) {
       File[] files = file.listFiles();
       for (File child : files) {
         if (!isIgnoreFile(child)) {
           children.add(FileInfo.createFileInfo(rootDir, child));
         }
       }
     }
     return new FileContents(file.isDirectory(), null, children);
   }
 }
Esempio n. 5
0
  public AetherResult resolve(
      String groupId, String artifactId, String version, String extension, String classifier)
      throws PlexusContainerException, ComponentLookupException, DependencyCollectionException,
          ArtifactResolutionException, DependencyResolutionException {
    if (Strings.isBlank(extension) || extension.equals("bundle")) {
      extension = DEFAULT_EXTENSION;
    }
    if (classifier == null) {
      classifier = DEFAULT_CLASSIFIER;
    }

    RepositorySystemSession session = newSession();
    Dependency dependency =
        new Dependency(
            new DefaultArtifact(groupId, artifactId, classifier, extension, version), "runtime");

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(dependency);

    List<RemoteRepository> repos = getRemoteRepositories();
    RemoteRepository[] repoArray = new RemoteRepository[repos.size()];
    repos.toArray(repoArray);
    for (RemoteRepository repo : repoArray) {
      collectRequest.addRepository(repo);
    }
    RepositorySystem system = getRepositorySystem();
    DependencyNode rootNode = system.collectDependencies(session, collectRequest).getRoot();
    DependencyRequest dependencyRequest = new DependencyRequest();
    dependencyRequest.setRoot(rootNode);
    system.resolveDependencies(session, dependencyRequest);

    PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
    rootNode.accept(nlg);

    return new AetherResult(rootNode, nlg.getFiles(), nlg.getClassPath());
  }