Search in sources :

Example 1 with NessieReferenceAlreadyExistsException

use of org.projectnessie.error.NessieReferenceAlreadyExistsException in project nessie by projectnessie.

the class TreeApiImpl method createReference.

@Override
public Reference createReference(String sourceRefName, Reference reference) throws NessieNotFoundException, NessieConflictException {
    Validation.validateForbiddenReferenceName(reference.getName());
    NamedRef namedReference = toNamedRef(reference);
    if (reference.getType() == Reference.ReferenceType.TAG && reference.getHash() == null) {
        throw new IllegalArgumentException("Tag-creation requires a target named-reference and hash.");
    }
    try {
        Hash hash = getStore().create(namedReference, toHash(reference.getHash(), false));
        return RefUtil.toReference(namedReference, hash);
    } catch (ReferenceNotFoundException e) {
        throw new NessieReferenceNotFoundException(e.getMessage(), e);
    } catch (ReferenceAlreadyExistsException e) {
        throw new NessieReferenceAlreadyExistsException(e.getMessage(), e);
    }
}
Also used : NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceNotFoundException(org.projectnessie.versioned.ReferenceNotFoundException) NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) ReferenceAlreadyExistsException(org.projectnessie.versioned.ReferenceAlreadyExistsException) NessieReferenceAlreadyExistsException(org.projectnessie.error.NessieReferenceAlreadyExistsException) NamedRef(org.projectnessie.versioned.NamedRef) RefUtil.toNamedRef(org.projectnessie.services.impl.RefUtil.toNamedRef) WithHash(org.projectnessie.versioned.WithHash) Hash(org.projectnessie.versioned.Hash) NessieReferenceAlreadyExistsException(org.projectnessie.error.NessieReferenceAlreadyExistsException)

Aggregations

NessieReferenceAlreadyExistsException (org.projectnessie.error.NessieReferenceAlreadyExistsException)1 NessieReferenceNotFoundException (org.projectnessie.error.NessieReferenceNotFoundException)1 RefUtil.toNamedRef (org.projectnessie.services.impl.RefUtil.toNamedRef)1 Hash (org.projectnessie.versioned.Hash)1 NamedRef (org.projectnessie.versioned.NamedRef)1 ReferenceAlreadyExistsException (org.projectnessie.versioned.ReferenceAlreadyExistsException)1 ReferenceNotFoundException (org.projectnessie.versioned.ReferenceNotFoundException)1 WithHash (org.projectnessie.versioned.WithHash)1