use of org.projectnessie.model.Content.Type in project nessie by projectnessie.
the class PersistVersionStoreExtension method afterBeanDiscovery.
@SuppressWarnings("unused")
public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
TableCommitMetaStoreWorker storeWorker = new TableCommitMetaStoreWorker();
abd.addBean().addType(new TypeLiteral<VersionStore<Content, CommitMeta, Type>>() {
}).addQualifier(Default.Literal.INSTANCE).scope(ApplicationScoped.class).produceWith(i -> new PersistVersionStore<>(databaseAdapter.get(), storeWorker));
}
use of org.projectnessie.model.Content.Type in project nessie by projectnessie.
the class NamespaceApiImpl method deleteNamespace.
@Override
public void deleteNamespace(NamespaceParams params) throws NessieReferenceNotFoundException, NessieNamespaceNotEmptyException, NessieNamespaceNotFoundException {
BranchName branch = branchFromRefName(params.getRefName());
try {
Namespace namespace = getNamespace(params, branch);
Delete delete = Delete.of(ContentKey.of(namespace.getElements()));
Callable<Void> validator = () -> {
try (Stream<WithType<Key, Type>> keys = getStore().getKeys(branch)) {
if (keys.anyMatch(k -> Namespace.of(k.getValue().getElements()).name().startsWith(params.getNamespace().name()) && k.getType() != Type.NAMESPACE)) {
throw namespaceNotEmptyException(params);
}
}
return null;
};
commit(branch, "delete namespace " + namespace.name(), TreeApiImpl.toOp(delete), validator);
} catch (ReferenceNotFoundException | ReferenceConflictException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
}
}
use of org.projectnessie.model.Content.Type in project nessie by projectnessie.
the class AbstractRestContents method verifyAllContentAndOperationTypes.
@Test
public void verifyAllContentAndOperationTypes() throws BaseNessieClientServerException {
Branch branch = createBranch("contentAndOperationAll");
CommitMultipleOperationsBuilder commit = getApi().commitMultipleOperations().branch(branch).commitMeta(CommitMeta.fromMessage("verifyAllContentAndOperationTypes"));
contentAndOperationTypes().flatMap(c -> c.globalOperation == null ? Stream.of(c.operation) : Stream.of(c.operation, c.globalOperation)).forEach(commit::operation);
commit.commit();
List<Entry> entries = getApi().getEntries().refName(branch.getName()).get().getEntries();
List<Entry> expect = contentAndOperationTypes().filter(c -> c.operation instanceof Put).map(c -> Entry.builder().type(c.type).name(c.operation.getKey()).build()).collect(Collectors.toList());
assertThat(entries).containsExactlyInAnyOrderElementsOf(expect);
}
use of org.projectnessie.model.Content.Type in project nessie by projectnessie.
the class PersistVersionStoreExtension method afterBeanDiscovery.
@SuppressWarnings("unused")
public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
TableCommitMetaStoreWorker storeWorker = new TableCommitMetaStoreWorker();
abd.addBean().addType(new TypeLiteral<VersionStore<Content, CommitMeta, Type>>() {
}).addQualifier(Default.Literal.INSTANCE).scope(ApplicationScoped.class).produceWith(i -> new PersistVersionStore<>(databaseAdapter.get(), storeWorker));
}
use of org.projectnessie.model.Content.Type in project nessie by projectnessie.
the class TreeApiImpl method truncate.
private EntriesResponse.Entry truncate(EntriesResponse.Entry entry, Integer depth) {
if (depth == null || depth < 1) {
return entry;
}
Type type = entry.getName().getElements().size() > depth ? Type.NAMESPACE : entry.getType();
ContentKey key = ContentKey.of(entry.getName().getElements().subList(0, depth));
return EntriesResponse.Entry.builder().type(type).name(key).build();
}
Aggregations