コード例 #1
0
 public void updateChoices(boolean reportError, Form<?> form) {
   final String repoUriStr = repositoryUriModel.getObject();
   if (REPOSITORY.sample != null && REPOSITORY.sample.equals(repoUriStr)) {
     return;
   }
   List<String> branchNames = new ArrayList<>();
   if (repoUriStr != null) {
     try {
       RepositoryManager manager = this.manager.get();
       URI repoURI = new URI(repoUriStr);
       RepositoryResolver resolver = RepositoryResolver.lookup(repoURI);
       String repoName = resolver.getName(repoURI);
       RepositoryInfo repoInfo = manager.getByRepoName(repoName);
       String repoId = repoInfo.getId();
       List<Ref> branchRefs = manager.listBranches(repoId);
       for (Ref branch : branchRefs) {
         branchNames.add(branch.localName());
       }
     } catch (IOException | URISyntaxException e) {
       if (reportError) {
         form.error("Could not list branches: " + e.getMessage());
       }
       branchNames = new ArrayList<String>();
     }
     String current = (String) choice.getModelObject();
     if (current != null && !branchNames.contains(current)) {
       branchNames.add(0, current);
     }
   }
   choice.setChoices(branchNames);
 }
コード例 #2
0
  private void create(final RepositoryInfo repoInfo) {
    // File targetDirectory = new File(repoInfo.getLocation());
    // Preconditions.checkArgument(!isGeogigDirectory(targetDirectory));

    URI repoURI = repoInfo.getLocation();
    RepositoryResolver resolver = RepositoryResolver.lookup(repoURI);
    if (!resolver.repoExists(repoURI)) {
      Hints hints = new Hints();
      hints.set(Hints.REPOSITORY_URL, repoURI);
      hints.set(Hints.REPOSITORY_NAME, repoInfo.getRepoName());
      Context context = GlobalContextBuilder.builder().build(hints);
      GeoGIG geogig = new GeoGIG(context);
      try {
        Repository repository = geogig.command(InitOp.class).call();
        Preconditions.checkState(repository != null);
      } finally {
        geogig.close();
      }
    }
  }