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

Api restore lifeCycleState state inconsistency fixed #12192

Merged
merged 1 commit into from
Dec 4, 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 @@ -348,7 +348,6 @@
GenericArtifactManager artifactManager = RegistryPersistenceUtil.getArtifactManager(registry,
APIConstants.API_KEY);
GenericArtifact apiArtifact = artifactManager.getGenericArtifact(apiUUID);
String lcState = ((GenericArtifactImpl) apiArtifact).getLcState();
if (apiArtifact != null) {
String existingVersionComparable = apiArtifact.getAttribute(APIConstants
.API_OVERVIEW_VERSION_COMPARABLE);
Expand All @@ -359,15 +358,19 @@
visibleRoles = visibleRolesList.split(",");
}
String apiPath = GovernanceUtils.getArtifactPath(registry, apiUUID);
String lifecycleStatus = artifactManager.getGenericArtifact(apiUUID)
.getAttribute(APIConstants.API_OVERVIEW_STATUS);

Check warning on line 362 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#L361-L362

Added lines #L361 - L362 were not covered by tests
int prependIndex = apiPath.lastIndexOf("/api");
String apiSourcePath = apiPath.substring(0, prependIndex);
String revisionTargetPath = RegistryPersistenceUtil.getRevisionPath(apiUUID, revisionId);
registry.delete(apiSourcePath);
registry.copy(revisionTargetPath, apiSourcePath);
Resource newAPIArtifact = registry.get(apiPath);
newAPIArtifact.setUUID(apiUUID);
newAPIArtifact.setProperty("registry.lifecycle.APILifeCycle.state", java.util.Arrays.asList((lcState)));
registry.put(apiPath, newAPIArtifact);
GenericArtifact artifact = getAPIArtifact(apiUUID, registry);
artifact.setAttribute(APIConstants.API_OVERVIEW_STATUS, lifecycleStatus);
artifactManager.updateGenericArtifact(apiArtifact);

Check warning on line 373 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#L371-L373

Added lines #L371 - L373 were not covered by tests
RegistryPersistenceUtil.clearResourcePermissions(apiPath, api.getId(),
((UserRegistry) registry).getTenantId());
RegistryPersistenceUtil.setResourcePermissions(api.getId().getProviderName(), api.getVisibility(),
Expand Down
Loading