From 017dd939406a5d877a990506567805c484c99e22 Mon Sep 17 00:00:00 2001 From: tharindu1st Date: Sun, 24 Mar 2024 10:30:22 +0530 Subject: [PATCH] remove lcm --- .../org.wso2.carbon.apimgt.gateway/pom.xml | 2 +- .../org.wso2.carbon.apimgt.impl/pom.xml | 11 +- .../carbon/apimgt/impl/APIProviderImpl.java | 2 +- .../apimgt/impl/lifecycle/CheckListItem.java | 142 ++++++++++++++++++ .../apimgt/impl/APIProviderImplTest.java | 5 +- .../swagger.json | 4 +- .../src/main/resources/publisher-api.yaml | 2 +- .../v1/common/mappings/APIMappingUtil.java | 2 +- .../apimgt/rest/api/publisher/v1/ApisApi.java | 3 +- pom.xml | 13 -- 10 files changed, 152 insertions(+), 34 deletions(-) create mode 100644 components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/lifecycle/CheckListItem.java diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml index e735875c7cb1..f0648e1127aa 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/pom.xml @@ -379,7 +379,7 @@ --add-exports java.base/sun.nio.cs=ALL-UNNAMED - org.wso2.org.ops4j.pax.logging:pax-logging-api + org.wso2.org.ops4j.pax.logging org.wso2.orbit.com.fasterxml.jackson.core:jackson-core diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml index f272f168ef37..7b455109155b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml @@ -223,16 +223,7 @@ hamcrest-all test - - org.wso2.carbon.governance - org.wso2.carbon.governance.custom.lifecycles.checklist - - - org.apache.poi.wso2 - poi-ooxml - - - + org.apache.pdfbox pdfbox diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java index 0a1c430b8ccd..74d37f442bad 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java @@ -66,6 +66,7 @@ import org.wso2.carbon.apimgt.impl.importexport.ExportFormat; import org.wso2.carbon.apimgt.impl.importexport.ImportExportAPI; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; +import org.wso2.carbon.apimgt.impl.lifecycle.CheckListItem; import org.wso2.carbon.apimgt.impl.monetization.DefaultMonetizationImpl; import org.wso2.carbon.apimgt.impl.notification.NotificationDTO; import org.wso2.carbon.apimgt.impl.notification.NotificationExecutor; @@ -96,7 +97,6 @@ import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.databridge.commons.Event; -import org.wso2.carbon.governance.custom.lifecycles.checklist.util.CheckListItem; import org.wso2.carbon.identity.application.common.model.IdentityProvider; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/lifecycle/CheckListItem.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/lifecycle/CheckListItem.java new file mode 100644 index 000000000000..7b5021de2158 --- /dev/null +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/lifecycle/CheckListItem.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.carbon.apimgt.impl.lifecycle; +public class CheckListItem implements Comparable { + private String lifeCycleStatus; + private String name; + private String value; + private String order; + private String propertyName; + private String isVisible; + private static final Object HASH_CODE_OBJECT = new Object(); + + public String getVisible() { + return this.isVisible; + } + + public void setVisible(String visible) { + this.isVisible = visible; + } + + public String getPropertyName() { + return this.propertyName; + } + + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + public String getLifeCycleStatus() { + return this.lifeCycleStatus; + } + + public void setLifeCycleStatus(String lifeCycleStatus) { + this.lifeCycleStatus = lifeCycleStatus; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getOrder() { + return this.order; + } + + public void setOrder(String order) { + this.order = order; + } + + public CheckListItem(String lifeCycleStatus, String name, String value, String order) { + this.lifeCycleStatus = lifeCycleStatus; + this.name = name; + this.value = value; + this.order = order; + } + + public CheckListItem() { + } + + public boolean matchLifeCycleStatus(String status, boolean ignoreCase) { + if (this.lifeCycleStatus != null && status != null) { + return ignoreCase ? this.lifeCycleStatus.equalsIgnoreCase(status) : this.lifeCycleStatus.equals(status); + } else { + return false; + } + } + + public boolean matchLifeCycleStatus(String status) { + return this.matchLifeCycleStatus(status, true); + } + + public int hashCode() { + int hashCode = HASH_CODE_OBJECT.hashCode(); + if (this.order != null) { + hashCode &= this.order.hashCode(); + } + + if (this.name != null) { + hashCode &= this.name.hashCode(); + } + + if (this.value != null) { + hashCode &= this.value.hashCode(); + } + + if (this.lifeCycleStatus != null) { + hashCode &= this.lifeCycleStatus.hashCode(); + } + + if (this.propertyName != null) { + hashCode &= this.propertyName.hashCode(); + } + + return hashCode; + } + + public boolean equals(Object obj) { + if (!(obj instanceof CheckListItem)) { + return false; + } else { + CheckListItem item = (CheckListItem)obj; + return (this.order != null && this.order.equals(item.order) || this.order == null && item.order == null) && (this.lifeCycleStatus != null && this.lifeCycleStatus.equals(item.lifeCycleStatus) || this.lifeCycleStatus == null && item.lifeCycleStatus == null) && (this.name != null && this.name.equals(item.name) || this.name == null && item.name == null) && (this.value != null && this.value.equals(item.value) || this.value == null && item.value == null) && (this.propertyName != null && this.propertyName.equals(item.propertyName) || this.propertyName == null && item.propertyName == null); + } + } + + public int compareTo(Object anotherItem) { + if (this.equals(anotherItem)) { + return 0; + } else { + CheckListItem item = (CheckListItem)anotherItem; + int otherItemOrder = Integer.parseInt(item.getOrder()); + int itemOrder = Integer.parseInt(this.order); + return itemOrder - otherItemOrder; + } + } +} diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java index 1398c4345039..2eb068ab6de8 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java @@ -31,7 +31,6 @@ import org.mockito.Mockito; import org.mockito.stubbing.Answer; import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; import org.powermock.modules.junit4.PowerMockRunner; @@ -105,7 +104,6 @@ import org.wso2.carbon.governance.api.generic.GenericArtifactManager; import org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact; import org.wso2.carbon.governance.api.util.GovernanceUtils; -import org.wso2.carbon.governance.custom.lifecycles.checklist.util.LifecycleBeanPopulator; import org.wso2.carbon.registry.core.Collection; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Resource; @@ -152,7 +150,7 @@ @SuppressStaticInitializationFor("org.wso2.carbon.context.PrivilegedCarbonContext") @PrepareForTest({ ServiceReferenceHolder.class, ApiMgtDAO.class, APIUtil.class, APIGatewayManager.class, GovernanceUtils.class, PrivilegedCarbonContext.class, WorkflowExecutorFactory.class, JavaUtils.class, - APIProviderImpl.class, APIManagerFactory.class, RegistryUtils.class, LifecycleBeanPopulator.class, + APIProviderImpl.class, APIManagerFactory.class, RegistryUtils.class, Caching.class, PaginationContext.class, MultitenantUtils.class, AbstractAPIManager.class, OASParserUtil.class, KeyManagerHolder.class, CertificateManagerImpl.class , PublisherAPI.class, Organization.class, APIPersistence.class, GatewayArtifactsMgtDAO.class, RegistryPersistenceUtil.class}) @@ -183,7 +181,6 @@ public void init() throws Exception { PowerMockito.mockStatic(RegistryUtils.class); PowerMockito.mockStatic(GovernanceUtils.class); PowerMockito.mockStatic(WorkflowExecutorFactory.class); - PowerMockito.mockStatic(LifecycleBeanPopulator.class); PowerMockito.mockStatic(KeyManagerHolder.class); PowerMockito.mockStatic(Caching.class); PowerMockito.mockStatic(PaginationContext.class); diff --git a/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json b/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json index 8040e385bd35..a7fa59630d63 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json +++ b/components/apimgt/org.wso2.carbon.apimgt.internal.service/swagger.json @@ -1354,8 +1354,8 @@ "type" : "string", "example" : "EXCHANGED", "description" : "The type of the tokens to be used (exchanged or without exchanged). Accepted values are EXCHANGED, DIRECT or BOTH.", - "default" : "DIRECT", - "enum" : [ "EXCHANGED", "DIRECT", "BOTH" ] + "enum" : [ "EXCHANGED", "DIRECT", "BOTH" ], + "default" : "DIRECT" } } }, diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml index aaf9ca9c34fc..7f13e3215e27 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml @@ -6626,7 +6626,7 @@ paths: x-code-samples: - lang: Curl source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v4/api-products/copy-api-products?newVersion=2.0&defaultVersion=false&apiproductId=2fd14eb8-b828-4013-b448-0739d2e76bf7"' + "https://127.0.0.1:9443/api/am/publisher/v4/api-products/copy-api-products?newVersion=2.0&defaultVersion=false&apiProductId=2fd14eb8-b828-4013-b448-0739d2e76bf7"' operationId: createNewAPIProductVersion /api-products/export: diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java index f4284f093503..5367d937353a 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java @@ -62,6 +62,7 @@ import org.wso2.carbon.apimgt.impl.definitions.AsyncApiParser; import org.wso2.carbon.apimgt.impl.definitions.OASParserUtil; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; +import org.wso2.carbon.apimgt.impl.lifecycle.CheckListItem; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.apimgt.impl.wsdl.model.WSDLInfo; import org.wso2.carbon.apimgt.impl.wsdl.model.WSDLValidationResponse; @@ -121,7 +122,6 @@ import org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WorkflowResponseDTO; import org.wso2.carbon.core.util.CryptoException; import org.wso2.carbon.core.util.CryptoUtil; -import org.wso2.carbon.governance.custom.lifecycles.checklist.util.CheckListItem; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java index 88c06e182eaf..fef871764b3a 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java @@ -462,7 +462,8 @@ public Response deleteAPIRevision(@ApiParam(value = "**API ID** consisting of th @ApiOperation(value = "Delete Pending Revision Deployment Workflow Tasks", notes = "This operation can be used to remove pending revision deployment requests that are in pending state ", response = Void.class, authorizations = { @Authorization(value = "OAuth2Security", scopes = { @AuthorizationScope(scope = "apim:api_publish", description = "Publish API"), - @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations") + @AuthorizationScope(scope = "apim:api_manage", description = "Manage all API related operations"), + @AuthorizationScope(scope = "apim:api_create", description = "Create API") }) }, tags={ "API Revisions", }) @ApiResponses(value = { diff --git a/pom.xml b/pom.xml index b3afaab5abe3..a0ad6c88aaa9 100644 --- a/pom.xml +++ b/pom.xml @@ -930,19 +930,6 @@ ${carbon.governance.version} - - - org.wso2.carbon.governance - org.wso2.carbon.governance.custom.lifecycles.checklist - ${carbon.governance.version} - - - org.apache.poi.wso2 - poi-scratchpad - - - - org.wso2.org.ops4j.pax.logging pax-logging-api