@Override public String toString() { return MoreObjects.toStringHelper(this).omitNullValues() .add("revision", revision.text()) .add("path", path) .add("type", type) .add("content", contentAsText()) .toString(); } }
@Override int weigh(Map<String, Entry<?>> value) { int weight = 0; weight += pathPattern.length(); weight += options.size(); for (Entry<?> e : value.values()) { weight += e.path().length(); if (e.hasContent()) { weight += e.contentAsText().length(); } } return weight; }
@Override int weigh(Map<String, Entry<?>> value) { int weight = 0; weight += pathPattern.length(); weight += options.size(); for (Entry<?> e : value.values()) { weight += e.path().length(); if (e.hasContent()) { weight += e.contentAsText().length(); } } return weight; }
@Override int weigh(Map<String, Entry<?>> value) { int weight = 0; weight += pathPattern.length(); weight += options.size(); for (Entry<?> e : value.values()) { weight += e.path().length(); if (e.hasContent()) { weight += e.contentAsText().length(); } } return weight; }
@Override int weigh(Entry<?> value) { int weight = 0; weight += query.path().length(); for (String e : query.expressions()) { weight += e.length(); } if (value != null && value.hasContent()) { weight += value.contentAsText().length(); } return weight; }
@Override int weigh(Entry<?> value) { int weight = 0; weight += query.path().length(); for (String e : query.expressions()) { weight += e.length(); } if (value != null && value.hasContent()) { weight += value.contentAsText().length(); } return weight; }
@Override int weigh(Entry<?> value) { int weight = 0; weight += query.path().length(); for (String e : query.expressions()) { weight += e.length(); } if (value != null && value.hasContent()) { weight += value.contentAsText().length(); } return weight; }
/** * Returns the JSON representation of {@link #content()}. * * @return the {@link JsonNode} parsed from the {@link #content()} * * @throws IllegalStateException if this {@link Entry} is a directory * @throws JsonParseException if failed to parse the {@link #content()} as JSON */ public JsonNode contentAsJson() throws JsonParseException { final T content = content(); if (content instanceof JsonNode) { return (JsonNode) content; } return Jackson.readTree(contentAsText()); }
/** * Returns the value converted from the JSON representation of {@link #content()}. * * @return the value converted from {@link #content()} * * @throws IllegalStateException if this {@link Entry} is a directory * @throws JsonParseException if failed to parse the {@link #content()} as JSON * @throws JsonMappingException if failed to convert the parsed JSON into {@code valueType} */ public <U> U contentAsJson(Class<U> valueType) throws JsonParseException, JsonMappingException { final T content = content(); if (content instanceof TreeNode) { return Jackson.treeToValue((TreeNode) content, valueType); } return Jackson.readValue(contentAsText(), valueType); }
@Override public void getFile(String projectName, String repositoryName, Revision revision, Query query, AsyncMethodCallback resultHandler) { handle(projectManager.get(projectName).repos().get(repositoryName) .get(convert(revision), convert(query)) .thenApply(res -> new GetFileResult(convert(res.type()), res.contentAsText())), resultHandler); }
@Override public void getFile(String projectName, String repositoryName, Revision revision, Query query, AsyncMethodCallback resultHandler) { handle(projectManager.get(projectName).repos().get(repositoryName) .get(convert(revision), convert(query)) .thenApply(res -> new GetFileResult(convert(res.type()), res.contentAsText())), resultHandler); }
@Override public void getFile(String projectName, String repositoryName, Revision revision, Query query, AsyncMethodCallback resultHandler) { handle(projectManager.get(projectName).repos().get(repositoryName) .get(convert(revision), convert(query)) .thenApply(res -> new GetFileResult(convert(res.type()), res.contentAsText())), resultHandler); }
@Override public String toString() { return MoreObjects.toStringHelper(this).omitNullValues() .add("revision", revision.text()) .add("path", path) .add("type", type) .add("content", contentAsText()) .toString(); } }
@Override public String toString() { return MoreObjects.toStringHelper(this).omitNullValues() .add("revision", revision.text()) .add("path", path) .add("type", type) .add("content", contentAsText()) .toString(); } }
private static void handleWatchFileResult( CompletableFuture<com.linecorp.centraldogma.common.Entry<Object>> future, AsyncMethodCallback resultHandler) { future.handle((res, cause) -> { if (cause == null) { final WatchFileResult wfr = new WatchFileResult(); wfr.setRevision(convert(res.revision())); wfr.setType(convert(res.type())); wfr.setContent(res.contentAsText()); resultHandler.onComplete(wfr); } else if (cause instanceof CancellationException) { resultHandler.onComplete(CentralDogmaConstants.EMPTY_WATCH_FILE_RESULT); } else { logAndInvokeOnError("watchFile", resultHandler, cause); } return null; }); }
private static void handleWatchFileResult( CompletableFuture<com.linecorp.centraldogma.common.Entry<Object>> future, AsyncMethodCallback resultHandler) { future.handle((res, cause) -> { if (cause == null) { final WatchFileResult wfr = new WatchFileResult(); wfr.setRevision(convert(res.revision())); wfr.setType(convert(res.type())); wfr.setContent(res.contentAsText()); resultHandler.onComplete(wfr); } else if (cause instanceof CancellationException) { resultHandler.onComplete(CentralDogmaConstants.EMPTY_WATCH_FILE_RESULT); } else { logAndInvokeOnError("watchFile", resultHandler, cause); } return null; }); }
static EntryDto convert(Entry<?> entry) { final EntryDto dto = new EntryDto(); dto.setRevision(entry.revision().text()); dto.setPath(entry.path()); dto.setType(entry.type().name()); dto.setContent(entry.contentAsText()); return dto; }
static EntryDto convert(Entry<?> entry) { final EntryDto dto = new EntryDto(); dto.setRevision(entry.revision().text()); dto.setPath(entry.path()); dto.setType(entry.type().name()); dto.setContent(entry.contentAsText()); return dto; }
static EntryDto convert(Entry<?> entry) { final EntryDto dto = new EntryDto(); dto.setRevision(entry.revision().text()); dto.setPath(entry.path()); dto.setType(entry.type().name()); dto.setContent(entry.contentAsText()); return dto; }
private static void handleWatchFileResult( CompletableFuture<com.linecorp.centraldogma.common.Entry<Object>> future, AsyncMethodCallback resultHandler) { future.handle(voidFunction((res, cause) -> { if (cause == null) { final WatchFileResult wfr = new WatchFileResult(); wfr.setRevision(convert(res.revision())); wfr.setType(convert(res.type())); wfr.setContent(res.contentAsText()); resultHandler.onComplete(wfr); } else if (cause instanceof CancellationException) { resultHandler.onComplete(CentralDogmaConstants.EMPTY_WATCH_FILE_RESULT); } else { logAndInvokeOnError("watchFile", resultHandler, cause); } })); }