org.locationtech.geogig.repository.Repository.open()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.locationtech.geogig.repository.Repository.open方法的一些代码示例,展示了Repository.open的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.open方法的具体详情如下:
包路径:org.locationtech.geogig.repository.Repository
类名称:Repository
方法名:open

Repository.open介绍

[英]Opens the repository.
[中]打开存储库。

代码示例

代码示例来源:origin: locationtech/geogig

/**
 * @return the configured repository or {@code null} if no repository is found on the current
 *         directory
 */
public synchronized @Nullable Repository getRepository() {
  if (repository != null) {
    return repository;
  }
  final Optional<URI> repoLocation = command(ResolveGeogigURI.class).call();
  if (repoLocation.isPresent()) {
    if (RepositoryResolver.lookup(repoLocation.get()).repoExists(repoLocation.get())) {
      repository = context.repository();
      try {
        repository.open();
      } catch (RepositoryConnectionException e) {
        throw new RuntimeException(e);
      }
    }
  }
  return repository;
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

/**
 * @return the configured repository or {@code null} if no repository is found on the current
 *         directory
 */
public synchronized Repository getRepository() {
  if (repository != null) {
    return repository;
  }
  final Optional<URI> repoLocation = command(ResolveGeogigURI.class).call();
  if (repoLocation.isPresent()) {
    try {
      if (RepositoryResolver.lookup(repoLocation.get()).repoExists(repoLocation.get())) {
        repository = context.repository();
        repository.open();
      }
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
  return repository;
}

代码示例来源:origin: org.locationtech.geogig/geogig-postgres

@Override
public Repository open(URI repositoryLocation) throws RepositoryConnectionException {
  Preconditions.checkArgument(canHandle(repositoryLocation), "Not a PostgreSQL URI: %s",
      repositoryLocation);
  Hints hints = new Hints();
  hints.set(Hints.REPOSITORY_URL, repositoryLocation.toString());
  Context context = GlobalContextBuilder.builder().build(hints);
  Repository repository = new GeoGIG(context).getRepository();
  repository.open();
  return repository;
}

代码示例来源:origin: org.geoserver.community/gs-geogig

if (exists) {
  try {
    repository.open();
  } catch (RepositoryConnectionException e) {
    throw Throwables.propagate(e);

代码示例来源:origin: org.locationtech.geogig/geogig-web-app

@VisibleForTesting
Repository loadGeoGIG(final String repoName) {
  LOG.info(
      "Loading repository " + repoName + " using " + resolver.getClass().getSimpleName());
  Hints hints = new Hints();
  final URI repoURI = resolver.buildRepoURI(rootRepoURI, repoName);
  hints.set(Hints.REPOSITORY_URL, repoURI);
  hints.set(Hints.REPOSITORY_NAME, repoName);
  Context context = GlobalContextBuilder.builder().build(hints);
  Repository repository = context.repository();
  if (!repository.isOpen()) {
    // Only open it if is was an existing repository.
    for (String existingRepo : resolver.listRepoNamesUnderRootURI(rootRepoURI)) {
      if (existingRepo.equals(repoName)) {
        try {
          repository.open();
        } catch (RepositoryConnectionException e) {
          throw Throwables.propagate(e);
        }
        break;
      }
    }
  }
  return repository;
}

代码示例来源:origin: org.locationtech.geogig/geogig-web-app

private static Optional<Repository> createGeoGIG(RepositoryResolver defaultResolver,
      URI rootRepoURI, String repositoryName,
      Map<String, String> parameters) {
    try {
      final Hints hints = InitRequestUtil.createHintsFromParameters(repositoryName,
          parameters);
      Optional<Serializable> repositoryUri = hints.get(Hints.REPOSITORY_URL);
      if (!repositoryUri.isPresent()) {
        URI repoURI = defaultResolver.buildRepoURI(rootRepoURI, repositoryName);
        hints.set(Hints.REPOSITORY_URL, repoURI);
        repositoryUri = hints.get(Hints.REPOSITORY_URL);
      }
      final URI repoUri = URI.create(repositoryUri.get().toString());
      final RepositoryResolver resolver = RepositoryResolver.lookup(repoUri);
      final Repository repository = GlobalContextBuilder.builder().build(hints).repository();
      if (resolver.repoExists(repoUri)) {
        // open it
        repository.open();
      }
      // now build the repo with the Hints
      return Optional.fromNullable(repository);
    } catch (Exception ex) {
      Throwables.propagate(ex);
    }
    return Optional.absent();
  }
}

代码示例来源:origin: locationtech/geogig

@Override
public Repository open(URI repositoryLocation) throws RepositoryConnectionException {
  Preconditions.checkArgument(canHandle(repositoryLocation), "Not a file repository: %s",
      repositoryLocation.getScheme());
  if (!repoExists(repositoryLocation)) {
    throw new RepositoryConnectionException(
        "The provided location is not a geogig repository");
  }
  Context context = GlobalContextBuilder.builder().build(new Hints().uri(repositoryLocation));
  GeoGIG geoGIG = new GeoGIG(context);
  Repository repository = geoGIG.getRepository();
  repository.open();
  return repository;
}

代码示例来源:origin: locationtech/geogig

@Override
public Repository open(URI repositoryLocation) throws RepositoryConnectionException {
  Preconditions.checkArgument(canHandle(repositoryLocation), "Not a PostgreSQL URI: %s",
      maskPassword(repositoryLocation));
  Hints hints = new Hints();
  hints.set(Hints.REPOSITORY_URL, repositoryLocation.toString());
  Context context = GlobalContextBuilder.builder().build(hints);
  Repository repository = new GeoGIG(context).getRepository();
  // Ensure the repository exists. If it's null, we might have a non-existing repo URI
  // location
  if (repository == null) {
    throw new RepositoryConnectionException(
        "Could not connect to repository. Check that the URI is valid.");
  }
  repository.open();
  return repository;
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

@Override
public Repository open(URI repositoryLocation) throws RepositoryConnectionException {
  Preconditions.checkArgument(canHandle(repositoryLocation), "Not a file repository: %s",
      repositoryLocation);
  if (!repoExists(repositoryLocation)) {
    throw new RepositoryConnectionException(
        repositoryLocation + " is not a geogig repository");
  }
  Context context = GlobalContextBuilder.builder().build(new Hints().uri(repositoryLocation));
  GeoGIG geoGIG = new GeoGIG(context);
  Repository repository = geoGIG.getRepository();
  repository.open();
  return repository;
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

repository.open();

代码示例来源:origin: locationtech/geogig

repository.open();

代码示例来源:origin: locationtech/geogig

return null;
}).when(mockRepo).open();

代码示例来源:origin: org.locationtech.geogig/geogig-core

return null;
}).when(mockRepo).open();

代码示例来源:origin: locationtech/geogig

public TestData newRepo(@NonNull String name) {
  Preconditions.checkState(!repos.containsKey(name));
  URI uri;
  try {
    uri = tmp.newFolder(name).toURI();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  Hints hints = Hints.readWrite().uri(uri);
  hints.set(Hints.REPOSITORY_NAME, name);
  Context context = GlobalContextBuilder.builder().build(hints);
  Repository repo = context.command(InitOp.class).call();
  try {
    repo.open();
    TestData repoWorker = new TestData(repo);
    repoWorker.init();
    repos.put(name, repoWorker);
    return getRepo(name);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

相关文章