From 055fe6f24fe8caa13ba853439d66700a1cc0932e Mon Sep 17 00:00:00 2001 From: shnrndk Date: Fri, 1 Dec 2023 11:42:02 +0530 Subject: [PATCH] Api restore lifeCycleState bug fix --- .../carbon/apimgt/persistence/RegistryPersistenceImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java index f567d2896037..1ef1d62c5f30 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java @@ -348,7 +348,6 @@ public void restoreAPIRevision(Organization org, String apiUUID, String revision 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); @@ -359,6 +358,8 @@ public void restoreAPIRevision(Organization org, String apiUUID, String revision visibleRoles = visibleRolesList.split(","); } String apiPath = GovernanceUtils.getArtifactPath(registry, apiUUID); + String lifecycleStatus = artifactManager.getGenericArtifact(apiUUID) + .getAttribute(APIConstants.API_OVERVIEW_STATUS); int prependIndex = apiPath.lastIndexOf("/api"); String apiSourcePath = apiPath.substring(0, prependIndex); String revisionTargetPath = RegistryPersistenceUtil.getRevisionPath(apiUUID, revisionId); @@ -366,8 +367,10 @@ public void restoreAPIRevision(Organization org, String apiUUID, String revision 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); RegistryPersistenceUtil.clearResourcePermissions(apiPath, api.getId(), ((UserRegistry) registry).getTenantId()); RegistryPersistenceUtil.setResourcePermissions(api.getId().getProviderName(), api.getVisibility(),