Search in sources :

Example 1 with NessieReferenceConflictException

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);
    }
}
Also used : NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceNotFoundException(org.projectnessie.versioned.ReferenceNotFoundException) NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceConflictException(org.projectnessie.versioned.ReferenceConflictException) NessieReferenceConflictException(org.projectnessie.error.NessieReferenceConflictException) NessieReferenceConflictException(org.projectnessie.error.NessieReferenceConflictException) CommitMeta(org.projectnessie.model.CommitMeta)

Example 2 with NessieReferenceConflictException

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);
    }
}
Also used : NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceNotFoundException(org.projectnessie.versioned.ReferenceNotFoundException) NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceConflictException(org.projectnessie.versioned.ReferenceConflictException) NessieReferenceConflictException(org.projectnessie.error.NessieReferenceConflictException) NessieReferenceConflictException(org.projectnessie.error.NessieReferenceConflictException) Operation(org.projectnessie.model.Operation) CommitMeta(org.projectnessie.model.CommitMeta) WithHash(org.projectnessie.versioned.WithHash) Hash(org.projectnessie.versioned.Hash)

Example 3 with NessieReferenceConflictException

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);
    }
}
Also used : NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceNotFoundException(org.projectnessie.versioned.ReferenceNotFoundException) NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceConflictException(org.projectnessie.versioned.ReferenceConflictException) NessieReferenceConflictException(org.projectnessie.error.NessieReferenceConflictException) NessieReferenceConflictException(org.projectnessie.error.NessieReferenceConflictException) WithHash(org.projectnessie.versioned.WithHash) Hash(org.projectnessie.versioned.Hash)

Aggregations

NessieReferenceConflictException (org.projectnessie.error.NessieReferenceConflictException)3 NessieReferenceNotFoundException (org.projectnessie.error.NessieReferenceNotFoundException)3 ReferenceConflictException (org.projectnessie.versioned.ReferenceConflictException)3 ReferenceNotFoundException (org.projectnessie.versioned.ReferenceNotFoundException)3 CommitMeta (org.projectnessie.model.CommitMeta)2 Hash (org.projectnessie.versioned.Hash)2 WithHash (org.projectnessie.versioned.WithHash)2 Operation (org.projectnessie.model.Operation)1