use of org.projectnessie.error.NessieReferenceConflictException in project nessie by projectnessie.
the class TreeApiImpl method assignReference.
protected void assignReference(NamedRef ref, String oldHash, Reference assignTo) throws NessieNotFoundException, NessieConflictException {
try {
ReferenceInfo<CommitMeta> resolved = getStore().getNamedRef(ref.getName(), GetNamedRefsParams.DEFAULT);
getStore().assign(resolved.getNamedRef(), toHash(oldHash, true), toHash(assignTo.getName(), assignTo.getHash()));
} catch (ReferenceNotFoundException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
} catch (ReferenceConflictException e) {
throw new NessieReferenceConflictException(e.getMessage(), e);
}
}
use of org.projectnessie.error.NessieReferenceConflictException in project nessie by projectnessie.
the class TreeApiImpl method commitMultipleOperations.
@Override
public Branch commitMultipleOperations(String branch, String hash, Operations operations) throws NessieNotFoundException, NessieConflictException {
List<org.projectnessie.versioned.Operation<Content>> ops = operations.getOperations().stream().map(TreeApiImpl::toOp).collect(ImmutableList.toImmutableList());
CommitMeta commitMeta = operations.getCommitMeta();
if (commitMeta.getCommitter() != null) {
throw new IllegalArgumentException("Cannot set the committer on the client side. It is set by the server.");
}
try {
Hash newHash = getStore().commit(BranchName.of(Optional.ofNullable(branch).orElse(getConfig().getDefaultBranch())), Optional.ofNullable(hash).map(Hash::of), commitMetaUpdate().apply(commitMeta), ops);
return Branch.of(branch, newHash.asString());
} catch (ReferenceNotFoundException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
} catch (ReferenceConflictException e) {
throw new NessieReferenceConflictException(e.getMessage(), e);
}
}
use of org.projectnessie.error.NessieReferenceConflictException in project nessie by projectnessie.
the class TreeApiImpl method transplantCommitsIntoBranch.
@Override
public void transplantCommitsIntoBranch(String branchName, String hash, String message, Transplant transplant) throws NessieNotFoundException, NessieConflictException {
try {
List<Hash> transplants;
try (Stream<Hash> s = transplant.getHashesToTransplant().stream().map(Hash::of)) {
transplants = s.collect(Collectors.toList());
}
getStore().transplant(BranchName.of(branchName), toHash(hash, true), transplants, commitMetaUpdate());
} catch (ReferenceNotFoundException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
} catch (ReferenceConflictException e) {
throw new NessieReferenceConflictException(e.getMessage(), e);
}
}
Aggregations