mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-25 08:50:18 +00:00
Fixes 1106 - Version API returning 204 No Content for latest version
This commit is contained in:
parent
a41e1d751e
commit
bc725f2b1b
@ -55,4 +55,8 @@ public final class CatalogExceptionMessage {
|
||||
public static String invalidColumnFQN(String fqn) {
|
||||
return String.format("Invalid fully qualified column name %s", fqn);
|
||||
}
|
||||
|
||||
public static String entityVersionNotFound(String entity, String id, Double version) {
|
||||
return String.format("%s instance for %s and version %s not found", StringUtils.capitalize(entity), id, version);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package org.openmetadata.catalog.jdbi3;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.Entity;
|
||||
import org.openmetadata.catalog.exception.CatalogExceptionMessage;
|
||||
import org.openmetadata.catalog.exception.EntityNotFoundException;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO.EntityVersionPair;
|
||||
import org.openmetadata.catalog.type.ChangeDescription;
|
||||
import org.openmetadata.catalog.type.EntityHistory;
|
||||
@ -127,11 +129,24 @@ public abstract class EntityRepository<T> {
|
||||
}
|
||||
|
||||
@Transaction
|
||||
public T getVersion(String id, String version) throws IOException {
|
||||
String extension = EntityUtil.getVersionExtension(entityName, Double.parseDouble(version));
|
||||
public T getVersion(String id, String version) throws IOException, ParseException {
|
||||
Double requestedVersion = Double.parseDouble(version);
|
||||
String extension = EntityUtil.getVersionExtension(entityName, requestedVersion);
|
||||
|
||||
// Get previous version from version history
|
||||
String json = daoCollection.entityExtensionDAO().getEntityVersion(id, extension);
|
||||
if (json != null) {
|
||||
return JsonUtils.readValue(json, entityClass);
|
||||
}
|
||||
// If requested latest version, return it from current version of the entity
|
||||
T entity = setFields(dao.findEntityById(UUID.fromString(id)), putFields);
|
||||
EntityInterface<T> entityInterface = getEntityInterface(entity);
|
||||
if (entityInterface.getVersion().equals(requestedVersion)) {
|
||||
return entity;
|
||||
}
|
||||
throw EntityNotFoundException.byMessage(
|
||||
CatalogExceptionMessage.entityVersionNotFound(entityName, id, requestedVersion));
|
||||
}
|
||||
|
||||
@Transaction
|
||||
public EntityHistory listVersions(String id) throws IOException, ParseException {
|
||||
|
@ -28,8 +28,6 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import org.openmetadata.catalog.api.data.CreateChart;
|
||||
import org.openmetadata.catalog.entity.data.Chart;
|
||||
import org.openmetadata.catalog.entity.data.Database;
|
||||
import org.openmetadata.catalog.entity.data.Table;
|
||||
import org.openmetadata.catalog.jdbi3.ChartRepository;
|
||||
import org.openmetadata.catalog.jdbi3.ChartRepository.ChartEntityInterface;
|
||||
import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
||||
|
@ -10,6 +10,10 @@
|
||||
"type": "string",
|
||||
"maxLength": 45
|
||||
},
|
||||
"description": {
|
||||
"description": "Unique name of the tag category.",
|
||||
"type": "string"
|
||||
},
|
||||
"labelType": {
|
||||
"description" : "Label type describes how a tag label was applied. 'Manual' indicates the tag label was applied by a person. 'Derived' indicates a tag label was derived using the associated tag relationship (see TagCategory.json for more details). 'Propagated` indicates a tag label was propagated from upstream based on lineage. 'Automated' is used when a tool was used to determine the tag label.",
|
||||
"type": "string",
|
||||
@ -35,5 +39,6 @@
|
||||
"$ref": "basic.json#/definitions/href"
|
||||
}
|
||||
},
|
||||
"required": ["tagFQN", "labelType", "state"],
|
||||
"additionalProperties": false
|
||||
}
|
@ -638,9 +638,8 @@ public abstract class EntityResourceTest<T> extends CatalogApplicationTest {
|
||||
|
||||
// GET ../entity/{id}/versions/{versionId} to get specific versions of the entity
|
||||
// Get the latest version of the entity from the versions API and ensure it is correct
|
||||
// TODO fix this
|
||||
// latestVersion = getVersion(entityInterface.getId(), entityInterface.getVersion(), authHeaders);
|
||||
// validateChangeDescription(latestVersion, updateType, changeDescription);
|
||||
latestVersion = getVersion(entityInterface.getId(), entityInterface.getVersion(), authHeaders);
|
||||
validateChangeDescription(latestVersion, updateType, changeDescription);
|
||||
if (updateType != NO_CHANGE && updateType != UpdateType.CREATED){
|
||||
// Get the previous version of the entity from the versions API and ensure it is correct
|
||||
T previousVersion = getVersion(entityInterface.getId(), changeDescription.getPreviousVersion(), authHeaders);
|
||||
|
Loading…
x
Reference in New Issue
Block a user