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);
}
}
Aggregations