示例#1
0
 @Override
 public List<URI> getMavenRepoURIs() {
   assertValid();
   try {
     List<URI> uris = new ArrayList<URI>();
     if (exists(curator.get(), ZkPath.MAVEN_PROXY.getPath("download")) != null) {
       List<String> children = getChildren(curator.get(), ZkPath.MAVEN_PROXY.getPath("download"));
       if (children != null && !children.isEmpty()) {
         Collections.sort(children);
       }
       if (children != null) {
         for (String child : children) {
           String mavenRepo =
               getSubstitutedPath(
                   curator.get(), ZkPath.MAVEN_PROXY.getPath("download") + "/" + child);
           if (mavenRepo != null && !mavenRepo.endsWith("/")) {
             mavenRepo += "/";
           }
           uris.add(new URI(mavenRepo));
         }
       }
     }
     return uris;
   } catch (Exception e) {
     throw FabricException.launderThrowable(e);
   }
 }
示例#2
0
  @Override
  public URI getMavenRepoUploadURI() {
    assertValid();
    URI uri = URI.create(getDefaultRepo());
    try {
      if (exists(curator.get(), ZkPath.MAVEN_PROXY.getPath("upload")) != null) {
        List<String> children = getChildren(curator.get(), ZkPath.MAVEN_PROXY.getPath("upload"));
        if (children != null && !children.isEmpty()) {
          Collections.sort(children);

          String mavenRepo =
              getSubstitutedPath(
                  curator.get(), ZkPath.MAVEN_PROXY.getPath("upload") + "/" + children.get(0));
          if (mavenRepo != null && !mavenRepo.endsWith("/")) {
            mavenRepo += "/";
          }
          uri = new URI(mavenRepo);
        }
      }
    } catch (Exception e) {
      // On exception just return uri.
    }
    return uri;
  }