diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml index 7752047cad27..e77ac5a02700 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml @@ -237,10 +237,7 @@ org.apache.pdfbox pdfbox - - org.wso2.carbon.governance - org.wso2.carbon.governance.lcm - + org.wso2.carbon.event-processing org.wso2.carbon.event.processor.stub diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployer.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployer.java index df115a1e0015..ef4f6d35aff3 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployer.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployer.java @@ -29,17 +29,10 @@ import org.wso2.carbon.apimgt.impl.dto.ThrottleProperties; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; import org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever; -import org.wso2.carbon.apimgt.impl.service.KeyMgtRegistrationService; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.governance.lcm.util.CommonUtil; -import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver; -import java.io.FileNotFoundException; - -import javax.xml.stream.XMLStreamException; - /** * This task provisions mandatory configs & Artifacts needed by any tenant. The reason for introducing this task is * to prevent {@link org.wso2.carbon.apimgt.impl.observers.TenantServiceCreator} class being run on None-synapse @@ -124,17 +117,6 @@ public void run() { } catch (Exception e) { // The generic Exception is handled explicitly so execution does not stop during config deployment log.error("Exception when creating default roles for tenant " + tenantDomain, e); } - try { - CommonUtil.addDefaultLifecyclesIfNotAvailable(ServiceReferenceHolder.getInstance().getRegistryService() - .getConfigSystemRegistry(tenantId), CommonUtil - .getRootSystemRegistry(tenantId)); - } catch (RegistryException e) { - log.error("Error while accessing registry", e); - } catch (FileNotFoundException e) { - log.error("Error while find lifecycle.xml", e); - } catch (XMLStreamException e) { - log.error("Error while parsing Lifecycle.xml", e); - } KeyManagerConfigurationDataRetriever keyManagerConfigurationDataRetriever = new KeyManagerConfigurationDataRetriever(tenantDomain); keyManagerConfigurationDataRetriever.startLoadKeyManagerConfigurations(); diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployerTestCase.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployerTestCase.java index c6ecd5bd788f..c5fbd7e4ba65 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployerTestCase.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/observers/CommonConfigDeployerTestCase.java @@ -30,14 +30,13 @@ import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.governance.lcm.util.CommonUtil; import org.wso2.carbon.registry.core.service.RegistryService; import static org.wso2.carbon.base.CarbonBaseConstants.CARBON_HOME; @RunWith(PowerMockRunner.class) -@PrepareForTest({APIUtil.class, PrivilegedCarbonContext.class, ServiceReferenceHolder.class, CommonUtil.class}) +@PrepareForTest({APIUtil.class, PrivilegedCarbonContext.class, ServiceReferenceHolder.class}) public class CommonConfigDeployerTestCase { private final int TENANT_ID = 1234; @@ -45,7 +44,6 @@ public class CommonConfigDeployerTestCase { @Test public void testCreatedConfigurationContext() throws APIManagementException { - PowerMockito.mockStatic(CommonUtil.class); System.setProperty(CARBON_HOME, ""); PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class); PowerMockito.mockStatic(PrivilegedCarbonContext.class); @@ -84,16 +82,12 @@ public void testCreatedConfigurationContext() throws APIManagementException { PowerMockito.verifyStatic(APIUtil.class); APIUtil.loadAndSyncTenantConf(TENANT_DOMAIN); - - //PowerMockito.verifyStatic(APIUtil.class); - //APIUtil.addDefaultTenantAdvancedThrottlePolicies(TENANT_DOMAIN, TENANT_ID); } @Test public void testExceptions() throws Exception { PowerMockito.mockStatic(APIUtil.class); - PowerMockito.mockStatic(CommonUtil.class); System.setProperty(CARBON_HOME, ""); PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class); PowerMockito.mockStatic(PrivilegedCarbonContext.class); @@ -144,7 +138,6 @@ public void testExceptions() throws Exception { @Test public void testCreatedConfigurationContextRuntimeException() throws APIManagementException { System.setProperty(CARBON_HOME, ""); - PowerMockito.mockStatic(CommonUtil.class); PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class); PowerMockito.mockStatic(PrivilegedCarbonContext.class); PowerMockito.when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext); diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/pom.xml b/components/apimgt/org.wso2.carbon.apimgt.persistence/pom.xml index e47112f99c50..756ca905dc3d 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/pom.xml +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/pom.xml @@ -37,7 +37,6 @@ org.apache.commons.logging.*; version="${import.package.version.commons.logging}", org.wso2.carbon.registry.core.*; version="${carbon.registry.imp.pkg.version}", - org.wso2.carbon.governance.lcm.* version="${carbon.governance.version}", org.apache.cxf.jaxrs.ext.multipart.* version="${cxf.version}" * @@ -100,17 +99,22 @@ org.wso2.carbon org.wso2.carbon.registry.core - - org.wso2.carbon.governance - org.wso2.carbon.governance.lcm - - - jboss - javassist - - - - + + org.wso2.carbon.governance + org.wso2.carbon.governance.api + + + org.wso2.carbon + org.wso2.carbon.core + + + org.wso2.carbon.registry + org.wso2.carbon.registry.indexing + + + javassist + javassist + org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api 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 018e297cd62c..13282971c59b 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 @@ -3080,7 +3080,6 @@ protected RegistryHolder getRegistry(String requestedTenantDomain) throws APIPer loadTenantRegistry(tenantId); registry = getRegistryService().getGovernanceSystemRegistry(tenantId); RegistryPersistenceUtil.loadloadTenantAPIRXT(null, tenantId); - RegistryPersistenceUtil.addLifecycleIfNotExists(tenantId); RegistryPersistenceUtil.registerCustomQueries(registry, null, userTenantDomain); holder.setTenantId(tenantId); } @@ -3089,7 +3088,6 @@ protected RegistryHolder getRegistry(String requestedTenantDomain) throws APIPer loadTenantRegistry(tenantId); registry = getRegistryService().getGovernanceSystemRegistry(tenantId); RegistryPersistenceUtil.loadloadTenantAPIRXT(null, tenantId); - RegistryPersistenceUtil.addLifecycleIfNotExists(tenantId); RegistryPersistenceUtil.registerCustomQueries(registry, null, userTenantDomain); holder.setTenantId(tenantId); } @@ -3151,7 +3149,6 @@ protected RegistryHolder getRegistry(String username, String requestedTenantDoma holder.setTenantId(tenantId); } RegistryPersistenceUtil.registerCustomQueries(configRegistry, username, userTenantDomain); - RegistryPersistenceUtil.addLifecycleIfNotExists(tenantId); } catch (RegistryException | UserStoreException | PersistenceException e) { String msg = "Failed to get API"; throw new APIPersistenceException(msg, e); diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java index caff6d983b67..2abad846ff43 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/utils/RegistryPersistenceUtil.java @@ -18,7 +18,6 @@ import com.google.gson.Gson; import org.apache.axis2.context.ConfigurationContext; -import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -53,7 +52,6 @@ import org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact; import org.wso2.carbon.governance.api.util.GovernanceConstants; import org.wso2.carbon.governance.api.util.GovernanceUtils; -import org.wso2.carbon.governance.lcm.util.CommonUtil; import org.wso2.carbon.registry.core.ActionConstants; import org.wso2.carbon.registry.core.Association; import org.wso2.carbon.registry.core.Registry; @@ -76,7 +74,6 @@ import org.wso2.carbon.utils.FileUtil; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import javax.xml.stream.XMLStreamException; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; @@ -90,8 +87,6 @@ import java.util.Properties; import java.util.Set; -import static org.wso2.carbon.apimgt.persistence.utils.PersistenceUtil.handleException; - public class RegistryPersistenceUtil { private static final Log log = LogFactory.getLog(RegistryPersistenceUtil.class); @@ -1816,31 +1811,6 @@ private static TenantManager getTenantManager(){ return ServiceReferenceHolder.getInstance().getRealmService().getTenantManager(); } - public static void addLifecycleIfNotExists(int tenantId) throws APIPersistenceException { - //Add default API LC if it is not there - try { - if (!CommonUtil.lifeCycleExists(APIConstants.API_LIFE_CYCLE, - getRegistryService().getConfigSystemRegistry(tenantId))) { - String defaultLifecyclePath = CommonUtil.getDefaltLifecycleConfigLocation() + File.separator - + APIConstants.API_LIFE_CYCLE + APIConstants.XML_EXTENSION; - File file = new File(defaultLifecyclePath); - String content = null; - if (file != null && file.exists()) { - content = FileUtils.readFileToString(file); - } - if (content != null) { - CommonUtil.addLifecycle(content, getRegistryService().getConfigSystemRegistry(tenantId), - CommonUtil.getRootSystemRegistry(tenantId)); - } - } - } catch (RegistryException e) { - throw new APIPersistenceException("Error occurred while adding default APILifeCycle.", e); - } catch (IOException e) { - throw new APIPersistenceException("Error occurred while loading APILifeCycle.xml.", e); - } catch (XMLStreamException e) { - throw new APIPersistenceException("Error occurred while adding default API LifeCycle.", e); - } - } public static String extractProvider(String apiPath, String apiName) { int startIndex = apiPath.indexOf(APIConstants.API_PROVIDER_SUFFIX_SLASH) + diff --git a/pom.xml b/pom.xml index 0bd21d786cfa..be25c2fa6e92 100644 --- a/pom.xml +++ b/pom.xml @@ -930,12 +930,6 @@ ${carbon.governance.version} - - org.wso2.carbon.governance - org.wso2.carbon.governance.lcm - ${carbon.governance.version} - - org.wso2.carbon.governance @@ -2003,6 +1997,12 @@ spotbugs-annotations ${spotbugs.annotations.version} + + javassist + javassist + 3.3.GA + test +