use of org.projectnessie.model.Content in project nessie by projectnessie.
the class NessieViewOperations method refresh.
@Override
public ViewVersionMetadata refresh() {
try {
reference.refresh(api);
} catch (NessieNotFoundException e) {
throw new RuntimeException("Failed to refresh as ref is no longer valid.", e);
}
String metadataLocation = null;
try {
Content content = api.getContent().key(key).reference(reference.getReference()).get().get(key);
LOG.debug("Content '{}' at '{}': {}", key, reference.getReference(), content);
if (content == null) {
if (currentMetadataLocation() != null) {
throw new NoSuchTableException("No such view %s in %s", key, reference.getReference());
}
} else {
this.icebergView = content.unwrap(IcebergView.class).orElseThrow(() -> new IllegalStateException("Cannot refresh iceberg view: " + String.format("Nessie points to a non-Iceberg object for path: %s.", key)));
metadataLocation = icebergView.getMetadataLocation();
}
} catch (NessieNotFoundException ex) {
if (currentMetadataLocation() != null) {
throw new NoSuchTableException(ex, "No such view %s", key);
}
}
refreshFromMetadataLocation(metadataLocation, RETRY_IF, 2);
return current();
}
use of org.projectnessie.model.Content in project nessie by projectnessie.
the class NessieViewOperations method view.
private IcebergView view(TableIdentifier viewIdentifier) {
try {
ContentKey key = NessieUtil.toKey(viewIdentifier);
Content view = api.getContent().key(key).reference(reference.getReference()).get().get(key);
return view != null ? view.unwrap(IcebergView.class).orElse(null) : null;
} catch (NessieNotFoundException e) {
return null;
}
}
Aggregations