static EntryType convert(com.linecorp.centraldogma.common.EntryType type) { return EntryConverter.convertEntryType(type); } ////////////////
static Entry convert(com.linecorp.centraldogma.common.Entry<?> entry) { return EntryConverter.convert(entry); }
static EntryType convert(com.linecorp.centraldogma.common.EntryType type) { return EntryConverter.convertEntryType(type); } ////////////////
static Entry convert(com.linecorp.centraldogma.common.Entry<?> entry) { return EntryConverter.convert(entry); }
static EntryType convert(com.linecorp.centraldogma.common.EntryType type) { return EntryConverter.convertEntryType(type); } ////////////////
static Entry convert(com.linecorp.centraldogma.common.Entry<?> entry) { return EntryConverter.convert(entry); }
@Override public CompletableFuture<Map<String, EntryType>> listFiles(String projectName, String repositoryName, Revision revision, String pathPattern) { final CompletableFuture<List<com.linecorp.centraldogma.internal.thrift.Entry>> future = run(callback -> client.listFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(revision), pathPattern, callback)); return future.thenApply(list -> list.stream().collect(toImmutableMap( com.linecorp.centraldogma.internal.thrift.Entry::getPath, e -> EntryConverter.convertEntryType(e.getType())))); }
@Override public CompletableFuture<Map<String, EntryType>> listFiles(String projectName, String repositoryName, Revision revision, String pathPattern) { final CompletableFuture<List<com.linecorp.centraldogma.internal.thrift.Entry>> future = run(callback -> client.listFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(revision), pathPattern, callback)); return future.thenApply(list -> list.stream().collect(toImmutableMap( com.linecorp.centraldogma.internal.thrift.Entry::getPath, e -> EntryConverter.convertEntryType(e.getType())))); }
@Override public CompletableFuture<Map<String, Entry<?>>> getFiles(String projectName, String repositoryName, Revision revision, String pathPattern) { return normalizeRevision(projectName, repositoryName, revision).thenCompose(normRev -> { final CompletableFuture<List<com.linecorp.centraldogma.internal.thrift.Entry>> future = run(callback -> client.getFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(normRev), pathPattern, callback)); return future.thenApply(list -> convertToMap(list, e -> EntryConverter.convert(normRev, e), Entry::path, Function.identity())); }); }
@Override public CompletableFuture<Map<String, EntryType>> listFiles(String projectName, String repositoryName, Revision revision, String pathPattern) { final CompletableFuture<List<com.linecorp.centraldogma.internal.thrift.Entry>> future = run(callback -> client.listFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(revision), pathPattern, callback)); return future.thenApply(list -> list.stream().collect(toImmutableMap( com.linecorp.centraldogma.internal.thrift.Entry::getPath, e -> EntryConverter.convertEntryType(e.getType())))); }
@Override public CompletableFuture<Map<String, Entry<?>>> getFiles(String projectName, String repositoryName, Revision revision, String pathPattern) { return normalizeRevision(projectName, repositoryName, revision).thenCompose(normRev -> { final CompletableFuture<List<com.linecorp.centraldogma.internal.thrift.Entry>> future = run(callback -> client.getFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(normRev), pathPattern, callback)); return future.thenApply(list -> convertToMap(list, e -> EntryConverter.convert(normRev, e), Entry::path, Function.identity())); }); }
@Override public <T> CompletableFuture<MergedEntry<T>> mergeFiles(String projectName, String repositoryName, Revision revision, MergeQuery<T> mergeQuery) { final CompletableFuture<com.linecorp.centraldogma.internal.thrift.MergedEntry> future = run(callback -> { client.mergeFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(revision), MergeQueryConverter.TO_DATA.convert(mergeQuery), callback); }); return future.thenApply(entry -> { final EntryType entryType = EntryConverter.convertEntryType(entry.getType()); assert entryType != null; switch (entryType) { case JSON: try { @SuppressWarnings("unchecked") final MergedEntry<T> converted = (MergedEntry<T>) MergedEntry.of( RevisionConverter.TO_MODEL.convert(entry.revision), entryType, Jackson.readTree(entry.content), entry.paths); return converted; } catch (IOException e) { throw new CompletionException( "failed to parse the content: " + entry.content, e); } default: throw new Error("unsupported entry type: " + entryType); } }); }
@Override public CompletableFuture<Map<String, Entry<?>>> getFiles(String projectName, String repositoryName, Revision revision, String pathPattern) { return normalizeRevision(projectName, repositoryName, revision).thenCompose(normRev -> { final CompletableFuture<List<com.linecorp.centraldogma.internal.thrift.Entry>> future = run(callback -> client.getFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(normRev), pathPattern, callback)); return future.thenApply(list -> convertToMap(list, e -> EntryConverter.convert(normRev, e), Entry::path, Function.identity())); }); }
public static Entry convert(com.linecorp.centraldogma.common.Entry<?> entry) { final Entry file = new Entry(entry.path(), convertEntryType(entry.type())); switch (entry.type()) { case JSON: // FIXME(trustin): Inefficiency try { file.setContent(Jackson.writeValueAsString(entry.content())); } catch (JsonProcessingException e) { throw new UncheckedIOException(e); } break; case TEXT: file.setContent((String) entry.content()); break; case DIRECTORY: break; default: throw new IllegalArgumentException("unsupported entry type: " + entry.type()); } return file; }
public static Entry convert(com.linecorp.centraldogma.common.Entry<?> entry) { final Entry file = new Entry(entry.path(), convertEntryType(entry.type())); switch (entry.type()) { case JSON: // FIXME(trustin): Inefficiency try { file.setContent(Jackson.writeValueAsString(entry.content())); } catch (JsonProcessingException e) { throw new UncheckedIOException(e); } break; case TEXT: file.setContent((String) entry.content()); break; case DIRECTORY: break; default: throw new IllegalArgumentException("unsupported entry type: " + entry.type()); } return file; }
@Override public <T> CompletableFuture<MergedEntry<T>> mergeFiles(String projectName, String repositoryName, Revision revision, MergeQuery<T> mergeQuery) { final CompletableFuture<com.linecorp.centraldogma.internal.thrift.MergedEntry> future = run(callback -> { client.mergeFiles(projectName, repositoryName, RevisionConverter.TO_DATA.convert(revision), MergeQueryConverter.TO_DATA.convert(mergeQuery), callback); }); return future.thenApply(entry -> { final EntryType entryType = EntryConverter.convertEntryType(entry.getType()); assert entryType != null; switch (entryType) { case JSON: try { @SuppressWarnings("unchecked") final MergedEntry<T> converted = (MergedEntry<T>) MergedEntry.of( RevisionConverter.TO_MODEL.convert(entry.revision), entryType, Jackson.readTree(entry.content), entry.paths); return converted; } catch (IOException e) { throw new CompletionException( "failed to parse the content: " + entry.content, e); } default: throw new Error("unsupported entry type: " + entryType); } }); }