Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a default version_comparable value to fix error thrown in APIs migrated from the version which doesn't support API Revisions #12036

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@
GenericArtifact apiArtifact = artifactManager.getGenericArtifact(apiUUID);
String lcState = ((GenericArtifactImpl) apiArtifact).getLcState();
if (apiArtifact != null) {
String existingVersionComparable = apiArtifact.getAttribute(APIConstants
.API_OVERVIEW_VERSION_COMPARABLE);
API api = RegistryPersistenceUtil.getApiForPublishing(registry, apiArtifact);
String visibleRolesList = api.getVisibleRoles();
String[] visibleRoles = new String[0];
Expand All @@ -370,6 +372,16 @@
((UserRegistry) registry).getTenantId());
RegistryPersistenceUtil.setResourcePermissions(api.getId().getProviderName(), api.getVisibility(),
visibleRoles, apiPath);
GenericArtifact newArtifact = artifactManager.getGenericArtifact(apiUUID);
if (newArtifact != null && newArtifact.getAttribute(APIConstants.API_OVERVIEW_VERSION_COMPARABLE) == null) {
if (existingVersionComparable != null) {
newArtifact.setAttribute(APIConstants.API_OVERVIEW_VERSION_COMPARABLE, existingVersionComparable);

Check warning on line 378 in components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java#L378

Added line #L378 was not covered by tests
} else {
newArtifact.setAttribute(APIConstants.API_OVERVIEW_VERSION_COMPARABLE,
String.valueOf(System.currentTimeMillis()));

Check warning on line 381 in components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java#L380-L381

Added lines #L380 - L381 were not covered by tests
}
artifactManager.updateGenericArtifact(newArtifact);

Check warning on line 383 in components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java

View check run for this annotation

Codecov / codecov/patch

components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java#L383

Added line #L383 was not covered by tests
}
}
registry.commitTransaction();
transactionCommitted = true;
Expand Down
Loading