@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; }
pathsBuilder.add(entry.path()); } catch (JsonParseException e) { future.completeExceptionally(e);
@Test public void testGetFilesWithDirectory() throws Exception { final String testRootWithoutSlash = TEST_ROOT.substring(0, TEST_ROOT.length() - 1); final Map<String, Entry<?>> files = rule.client().getFiles( rule.project(), rule.repo1(), Revision.HEAD, testRootWithoutSlash + ", " + TEST_ROOT + '*').join(); assertThat(files).hasSize(NUM_FILES + 1); final Entry<?> dir = files.get(testRootWithoutSlash); assertThat(dir.type()).isEqualTo(EntryType.DIRECTORY); assertThat(dir.path()).isEqualTo(testRootWithoutSlash); assertThat(dir.hasContent()).isFalse(); assertThatThrownBy(dir::content).isInstanceOf(IllegalStateException.class); files.values().forEach(f -> { if (f.type() != EntryType.DIRECTORY) { assertThatJson(f.content()).isEqualTo("{}"); } }); }
pathsBuilder.add(entry.path()); } catch (JsonParseException e) { future.completeExceptionally(e);
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; }
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; }