From 338d0973e99b0088ece297543b59c3c67d911590 Mon Sep 17 00:00:00 2001 From: kavindya_devindi Date: Wed, 8 Mar 2023 07:36:58 +0530 Subject: [PATCH 01/29] Add subtype-mgt feature --- .../io.entgra.device.mgt.subtype.mgt/pom.xml | 413 ++++++ .../cache/GetDeviceSubTypeCacheLoader.java | 79 ++ .../mgt/subtype/mgt/dao/DeviceSubTypeDAO.java | 45 + .../mgt/dao/DeviceSubTypeDAOFactory.java | 54 + .../mgt/dao/impl/DeviceSubTypeDAOImpl.java | 254 ++++ .../dao/impl/DeviceSubTypeMySQLDAOImpl.java | 26 + .../mgt/dao/util/ConnectionManagerUtil.java | 220 +++ .../mgt/subtype/mgt/dao/util/DAOUtil.java | 60 + .../mgt/subtype/mgt/dto/DeviceSubType.java | 81 ++ .../mgt/dto/DeviceSubTypeCacheKey.java | 50 + .../mgt/exception/BadRequestException.java | 36 + .../mgt/exception/DBConnectionException.java | 36 + .../mgt/exception/SubTypeMgtDAOException.java | 57 + .../exception/SubTypeMgtPluginException.java | 58 + .../mgt/impl/DeviceSubTypeServiceImpl.java | 233 ++++ .../internal/DeviceSubTypeMgtDataHolder.java | 64 + .../DeviceSubTypeMgtServiceComponent.java | 138 ++ .../subtype/mgt/spi/DeviceSubTypeService.java | 44 + .../mgt/util/DeviceSubTypeMgtUtil.java | 42 + .../mgt/subtype/mgt/DAONegativeTest.java | 163 +++ .../device/mgt/subtype/mgt/DAOTest.java | 132 ++ .../mgt/subtype/mgt/DataSourceConfig.java | 79 ++ .../mgt/subtype/mgt/ServiceNegativeTest.java | 101 ++ .../device/mgt/subtype/mgt/ServiceTest.java | 117 ++ .../device/mgt/subtype/mgt/TestUtils.java | 100 ++ .../mgt/mock/BaseDeviceSubTypePluginTest.java | 158 +++ .../mgt/subtype/mgt/mock/MockConnection.java | 344 +++++ .../mgt/subtype/mgt/mock/MockDataSource.java | 124 ++ .../mgt/mock/MockDatabaseMetaData.java | 942 +++++++++++++ .../mgt/subtype/mgt/mock/MockResultSet.java | 1114 +++++++++++++++ .../mgt/subtype/mgt/mock/MockStatement.java | 562 ++++++++ .../carbon-home/dbscripts/dm-db-h2.sql | 738 ++++++++++ .../resources/carbon-home/dbscripts/h2.sql | 415 ++++++ .../repository/conf/axis2/axis2.xml | 727 ++++++++++ .../repository/conf/axis2/axis2_client.xml | 303 ++++ .../repository/conf/axis2/tenant-axis2.xml | 288 ++++ .../carbon-home/repository/conf/carbon.xml | 660 +++++++++ .../repository/conf/cdm-config.xml | 172 +++ .../conf/datasources/data-source-config.xml | 26 + .../conf/etc/bundle-config/README.txt | 12 + .../carboncontext-osgi-services.properties | 22 + .../repository/conf/etc/config-validation.xml | 56 + .../carbon-home/repository/conf/etc/jmx.xml | 35 + .../repository/conf/etc/launch.ini | 258 ++++ .../conf/etc/logging-bridge.properties | 73 + .../repository/conf/etc/mime.mappings | 27 + .../repository/conf/etc/mime.types | 734 ++++++++++ .../repository/conf/etc/osgi-debug.options | 95 ++ .../repository/conf/etc/tasks-config.xml | 70 + .../repository/conf/log4j.properties | 33 + .../carbon-home/repository/conf/registry.xml | 109 ++ .../conf/security/authenticators.xml | 76 + .../conf/tomcat/carbon/META-INF/context.xml | 36 + .../conf/tomcat/carbon/WEB-INF/web.xml | 62 + .../conf/tomcat/catalina-server.xml | 99 ++ .../repository/conf/tomcat/tomcat-users.xml | 35 + .../repository/conf/tomcat/web.xml | 1223 +++++++++++++++++ .../carbon-home/repository/conf/user-mgt.xml | 383 ++++++ .../src/test/resources/testng.xml | 38 + components/subtype-mgt/pom.xml | 39 + .../pom.xml | 107 ++ .../src/main/resources/build.properties | 1 + .../src/main/resources/p2.inf | 1 + features/subtype-mgt/pom.xml | 41 + pom.xml | 20 + 65 files changed, 12940 insertions(+) create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/launch.ini create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.mappings create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.types create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/web.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml create mode 100644 components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml create mode 100644 components/subtype-mgt/pom.xml create mode 100644 features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml create mode 100644 features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/build.properties create mode 100644 features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/p2.inf create mode 100644 features/subtype-mgt/pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml new file mode 100644 index 0000000000..53b037ff52 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml @@ -0,0 +1,413 @@ + + + + + org.wso2.carbon.devicemgt + subtype-mgt + 5.0.20-SNAPSHOT + ../pom.xml + + + 4.0.0 + io.entgra.device.mgt.subtype.mgt + Entgra IoT - Subtype Mgt Impl + bundle + Entgra IoT - Subtype Management Component Implementation + http://entgra.io + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Subtype Management Bundle + io.entgra.device.mgt.subtype.mgt.internal + + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.apache.commons.logging, + org.apache.commons.lang, + javax.xml, + javax.xml.stream, + javax.xml.bind.*, + javax.sql, + javax.xml.parsers; version=0.0.0, + org.w3c.dom, + javax.naming, + org.wso2.carbon.context, + org.wso2.carbon.base, + org.wso2.carbon.utils.*, + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.device.mgt.core.*, + org.wso2.carbon.ndatasource.core, + org.wso2.carbon.registry.core, + org.wso2.carbon.registry.core.session, + org.wso2.carbon.registry.core.service, + org.wso2.carbon.registry.api, + org.wso2.carbon.device.mgt.extensions.license.mgt.registry, + javax.net.ssl, + org.wso2.carbon.core.util, + okhttp3, + org.json.*, + com.google.gson.*, + com.fasterxml.jackson.core.*, + com.fasterxml.jackson.databind.*, + com.fasterxml.jackson.annotation.* + + + !io.entgra.device.mgt.subtype.mgt.internal, + io.entgra.device.mgt.subtype.mgt.* + + + + + + org.jacoco + jacoco-maven-plugin + + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/site + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + file:src/test/resources/carbon-home/repository/conf/log4j.properties + + + + src/test/resources/testng.xml + + + + + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + provided + + + org.wso2.carbon.identity.inbound.auth.oauth2 + org.wso2.carbon.identity.oauth.stub + + + org.apache.axis2.wso2 + axis2-client + + + org.apache.geronimo.specs.wso2 + geronimo-stax-api_1.0_spec + + + org.apache.ws.commons.axiom.wso2 + axiom + + + org.codehaus.woodstox + woodstox-core-asl + + + org.codehaus.woodstox + wstx-asl + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.analytics.data.publisher + + + org.wso2.carbon.analytics + org.wso2.carbon.analytics.api + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.extensions + provided + + + org.codehaus.woodstox + stax2-api + + + org.codehaus.woodstox + woodstox-core-asl + + + org.wso2.carbon + org.wso2.carbon.securevault + + + org.apache.ws.commons.axiom.wso2 + axiom + + + + + org.wso2.carbon + org.wso2.carbon.ndatasource.core + provided + + + org.wso2.securevault + org.wso2.securevault + + + + + org.wso2.carbon + org.wso2.carbon.base + provided + + + org.wso2.securevault + org.wso2.securevault + + + org.apache.ws.commons.axiom.wso2 + axiom + + + org.mockito + mockito-core + + + + + org.eclipse.osgi + org.eclipse.osgi + provided + + + org.eclipse.osgi + org.eclipse.osgi.services + provided + + + org.wso2.carbon + org.wso2.carbon.core + provided + + + org.wso2.carbon + org.wso2.carbon.logging + provided + + + org.wso2.carbon + org.wso2.carbon.utils + provided + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + provided + + + org.wso2.carbon + org.wso2.carbon.registry.api + provided + + + org.wso2.carbon + org.wso2.carbon.registry.core + provided + + + org.apache.tomcat.wso2 + jdbc-pool + provided + + + com.google.code.gson + gson + provided + + + io.github.openfeign + feign-core + provided + + + io.github.openfeign + feign-jackson + provided + + + io.github.openfeign + feign-jaxrs + provided + + + io.github.openfeign + feign-gson + provided + + + io.github.openfeign + feign-okhttp + provided + + + io.github.openfeign + feign-slf4j + provided + + + org.wso2.carbon.devicemgt + org.wso2.carbon.identity.jwt.client.extension + provided + + + commons-validator + commons-validator + provided + + + org.apache.cxf + cxf-rt-frontend-jaxws + provided + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-transports-http + provided + + + commons-lang.wso2 + commons-lang + provided + + + com.google.guava + guava + + + org.json + json + ${json.version} + provided + + + com.fasterxml.jackson.core + jackson-databind + ${fasterxml.jackson.version} + provided + + + org.powermock + powermock-module-testng + test + + + org.powermock + powermock-api-mockito + test + + + org.testng + testng + test + + + com.h2database.wso2 + h2-database-engine + test + + + org.apache.httpcomponents.wso2 + httpcore + test + + + org.wso2.apache.httpcomponents + httpclient + test + + + org.wso2.securevault + org.wso2.securevault + test + + + xerces.wso2 + xercesImpl + test + + + org.apache.axis2.wso2 + axis2 + test + + + org.wso2.carbon + org.wso2.carbon.queuing + test + + + javax.xml.bind + jaxb-api + test + + + \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java new file mode 100644 index 0000000000..3070f38c63 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.cache; + +import com.google.common.cache.CacheLoader; +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAO; +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubTypeCacheKey; +import io.entgra.device.mgt.subtype.mgt.exception.DBConnectionException; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtDAOException; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtPluginException; +import io.entgra.device.mgt.subtype.mgt.util.DeviceSubTypeMgtUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + +public class GetDeviceSubTypeCacheLoader extends CacheLoader { + + private static final Log log = LogFactory.getLog(GetDeviceSubTypeCacheLoader.class); + + private final DeviceSubTypeDAO deviceSubTypeDAO; + + public GetDeviceSubTypeCacheLoader() { + this.deviceSubTypeDAO = DeviceSubTypeDAOFactory.getDeviceSubTypeDAO(); + } + + @Override + public DeviceSubType load(String key) throws SubTypeMgtPluginException { + DeviceSubTypeCacheKey deviceSubTypeCacheKey = DeviceSubTypeMgtUtil.getDeviceSubTypeCacheKey(key); + int tenantId = deviceSubTypeCacheKey.getTenantId(); + int subTypeId = deviceSubTypeCacheKey.getSubTypeId(); + DeviceSubType.DeviceType deviceType = deviceSubTypeCacheKey.getDeviceType(); + + if (log.isTraceEnabled()) { + log.trace("Loading Device subtype for " + deviceType + " subtype & subtype Id : " + subTypeId); + } + try { + ConnectionManagerUtil.openDBConnection(); + return deviceSubTypeDAO.getDeviceSubType(subTypeId, tenantId, deviceType); + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the database connection to retrieve device subtype for " + + deviceType + " subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } catch (InvalidCacheLoadException e) { + String msg = "CacheLoader returned null for device subtype: " + deviceType + " subtype & subtype Id: " + + subTypeId; + log.error(msg, e); + return null; + } catch (SubTypeMgtDAOException e) { + String msg = "Error occurred in the database level while retrieving device subtype for " + deviceType + + " subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java new file mode 100644 index 0000000000..1b3ca0ce41 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dao; + +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtDAOException; + +import java.util.List; + +public interface DeviceSubTypeDAO { + boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtDAOException; + + boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, + String typeDefinition) throws SubTypeMgtDAOException; + + DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException; + + List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException; + + int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; + + int getMaxSubTypeId(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; + + DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException; +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java new file mode 100644 index 0000000000..d92fc28352 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dao; + +import io.entgra.device.mgt.subtype.mgt.dao.impl.DeviceSubTypeDAOImpl; +import io.entgra.device.mgt.subtype.mgt.dao.impl.DeviceSubTypeMySQLDAOImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; + +public class DeviceSubTypeDAOFactory { + private static final Log log = LogFactory.getLog(DeviceSubTypeDAOFactory.class); + private static String databaseEngine; + + public static void init(DataSourceConfig dataSourceConfiguration) { + if (log.isDebugEnabled()) { + log.debug("Initializing Device SubType Mgt Data Source"); + } + ConnectionManagerUtil.resolveDataSource(dataSourceConfiguration); + databaseEngine = ConnectionManagerUtil.getDatabaseType(); + } + + public static DeviceSubTypeDAO getDeviceSubTypeDAO() { + if (databaseEngine != null) { + //noinspection SwitchStatementWithTooFewBranches + switch (databaseEngine) { + case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL: + return new DeviceSubTypeMySQLDAOImpl(); + default: + return new DeviceSubTypeDAOImpl(); + } + } + throw new IllegalStateException("Database engine has not initialized properly."); + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java new file mode 100644 index 0000000000..6d7dcf5e25 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dao.impl; + +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAO; +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.dao.util.DAOUtil; +import io.entgra.device.mgt.subtype.mgt.exception.DBConnectionException; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; + + +public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { + private static final Log log = LogFactory.getLog(DeviceSubTypeDAOImpl.class); + + @Override + public boolean addDeviceSubType(DeviceSubType deviceSubType) + throws SubTypeMgtDAOException { + try { + String sql = "INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, " + + "TYPE_DEFINITION) VALUES (?, ?, ?, ?, ?)"; + + Connection conn = ConnectionManagerUtil.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, deviceSubType.getSubTypeId()); + stmt.setInt(2, deviceSubType.getTenantId()); + stmt.setString(3, deviceSubType.getDeviceType().toString()); + stmt.setString(4, deviceSubType.getSubTypeName()); + stmt.setString(5, deviceSubType.getTypeDefinition()); + return stmt.executeUpdate() > 0; + } + + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to insert device sub type for " + + deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId(); + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while processing SQL to insert device sub type for " + + deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId(); + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } + } + + @Override + public boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, + String subTypeName, String typeDefinition) + throws SubTypeMgtDAOException { + try { + String sql = "UPDATE DM_DEVICE_SUB_TYPE SET TYPE_DEFINITION = ? , SUB_TYPE_NAME = ? WHERE SUB_TYPE_ID = ? " + + "AND TENANT_ID = ? AND DEVICE_TYPE = ?"; + + Connection conn = ConnectionManagerUtil.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, typeDefinition); + stmt.setString(2, subTypeName); + stmt.setInt(3, subTypeId); + stmt.setInt(4, tenantId); + stmt.setString(5, deviceType.toString()); + return stmt.executeUpdate() > 0; + } + + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to update device sub type for " + + deviceType + " subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while processing SQL to update device sub type for " + + deviceType + " subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } + } + + @Override + public DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException { + try { + String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE = ?"; + + Connection conn = ConnectionManagerUtil.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, subTypeId); + stmt.setInt(2, tenantId); + stmt.setString(3, deviceType.toString()); + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + return DAOUtil.loadDeviceSubType(rs); + } + return null; + } + } + + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to retrieve device subtype for " + deviceType + + " subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while processing SQL to retrieve device subtype for " + deviceType + " " + + "subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } + } + + @Override + public List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException { + try { + String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE TENANT_ID = ? AND DEVICE_TYPE = ? ORDER BY " + + "SUB_TYPE_ID"; + + Connection conn = ConnectionManagerUtil.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, tenantId); + stmt.setString(2, deviceType.toString()); + try (ResultSet rs = stmt.executeQuery()) { + return DAOUtil.loadDeviceSubTypes(rs); + } + } + + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to retrieve all device sub types for " + + deviceType + " subtypes"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while processing SQL to retrieve all device sub types for " + deviceType + " " + + "subtypes"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } + } + + @Override + public int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException { + try { + String sql = "SELECT COUNT(*) as DEVICE_COUNT FROM DM_DEVICE_SUB_TYPE WHERE DEVICE_TYPE = ? "; + + Connection conn = ConnectionManagerUtil.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, deviceType.toString()); + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + return rs.getInt("DEVICE_COUNT"); + } + return 0; + } + } + + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to retrieve device sub types count for " + + deviceType + " subtypes"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while processing SQL to retrieve device sub types count for " + deviceType + + " subtypes"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } + } + + @Override + public int getMaxSubTypeId(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException { + try { + String sql = "SELECT COALESCE(MAX(SUB_TYPE_ID),0) as MAX_ID FROM DM_DEVICE_SUB_TYPE WHERE DEVICE_TYPE = ? "; + + Connection conn = ConnectionManagerUtil.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, deviceType.toString()); + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + return rs.getInt("MAX_ID"); + } + return 0; + } + } + + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to retrieve max device subtype id for " + + deviceType + " subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while processing SQL to retrieve max device subtype id for " + deviceType + + " subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } + } + + @Override + public DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, + DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException { + try { + String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_NAME = ? AND TENANT_ID = ? AND DEVICE_TYPE " + + "= ? "; + + Connection conn = ConnectionManagerUtil.getDBConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, subTypeName); + stmt.setInt(2, tenantId); + stmt.setString(3, deviceType.toString()); + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + return DAOUtil.loadDeviceSubType(rs); + } + return null; + } + } + + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to retrieve device subtype for " + deviceType + + " subtype & subtype name: " + subTypeName; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while processing SQL to retrieve device subtype for " + deviceType + " " + + "subtype & subtype name: " + subTypeName; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java new file mode 100644 index 0000000000..defb15afa7 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dao.impl; + +/** + * Implementation for MySQL + */ +public class DeviceSubTypeMySQLDAOImpl extends DeviceSubTypeDAOImpl { +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java new file mode 100644 index 0000000000..f6615254ed --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java @@ -0,0 +1,220 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dao.util; + +import io.entgra.device.mgt.subtype.mgt.exception.DBConnectionException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.exceptions.IllegalTransactionStateException; +import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; +import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; + +import javax.naming.InitialContext; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Hashtable; +import java.util.List; + +public class ConnectionManagerUtil { + + private static final Log log = LogFactory.getLog(ConnectionManagerUtil.class); + private static final ThreadLocal currentConnection = new ThreadLocal<>(); + private static DataSource dataSource; + + public static void openDBConnection() throws DBConnectionException { + Connection conn = currentConnection.get(); + if (conn != null) { + throw new IllegalTransactionStateException("Database connection has already been obtained."); + } + try { + conn = dataSource.getConnection(); + } catch (SQLException e) { + throw new DBConnectionException("Failed to get a database connection.", e); + } + currentConnection.set(conn); + } + + public static Connection getDBConnection() throws DBConnectionException { + Connection conn = currentConnection.get(); + if (conn == null) { + try { + conn = dataSource.getConnection(); + currentConnection.set(conn); + } catch (SQLException e) { + throw new DBConnectionException("Failed to get database connection.", e); + } + } + return conn; + } + + public static void beginDBTransaction() throws DBConnectionException { + Connection conn = currentConnection.get(); + if (conn == null) { + conn = getDBConnection(); + } else if (inTransaction(conn)) { + throw new IllegalTransactionStateException("Transaction has already been started."); + } + + try { + conn.setAutoCommit(false); + } catch (SQLException e) { + throw new DBConnectionException("Error occurred while starting a database transaction.", e); + } + } + + public static void endDBTransaction() throws DBConnectionException { + Connection conn = currentConnection.get(); + if (conn == null) { + throw new IllegalTransactionStateException("Database connection is not active."); + } + + if (!inTransaction(conn)) { + throw new IllegalTransactionStateException("Transaction has not been started."); + } + + try { + conn.setAutoCommit(true); + } catch (SQLException e) { + throw new DBConnectionException("Error occurred while ending database transaction.", e); + } + } + + public static void commitDBTransaction() { + Connection conn = currentConnection.get(); + if (conn == null) { + throw new IllegalTransactionStateException("Database connection is not active."); + } + + if (!inTransaction(conn)) { + throw new IllegalTransactionStateException("Transaction has not been started."); + } + + try { + conn.commit(); + } catch (SQLException e) { + log.error("Error occurred while committing the transaction", e); + } + } + + public static void rollbackDBTransaction() { + Connection conn = currentConnection.get(); + if (conn == null) { + throw new IllegalTransactionStateException("Database connection is not active."); + } + + if (!inTransaction(conn)) { + throw new IllegalTransactionStateException("Transaction has not been started."); + } + + try { + conn.rollback(); + } catch (SQLException e) { + log.warn("Error occurred while roll-backing the transaction", e); + } + } + + public static void closeDBConnection() { + Connection conn = currentConnection.get(); + if (conn == null) { + throw new IllegalTransactionStateException("Database connection is not active."); + } + try { + conn.close(); + } catch (SQLException e) { + log.error("Error occurred while closing the connection", e); + } + currentConnection.remove(); + } + + private static boolean inTransaction(Connection conn) { + boolean inTransaction = true; + try { + if (conn.getAutoCommit()) { + inTransaction = false; + } + } catch (SQLException e) { + throw new IllegalTransactionStateException("Failed to get transaction state."); + } + return inTransaction; + } + + public static boolean isTransactionStarted() throws DBConnectionException { + Connection connection = getDBConnection(); + return inTransaction(connection); + } + + /** + * Resolve data source from the data source definition. + * + * @param config Data source configuration + * @return data source resolved from the data source definition + */ + public static DataSource resolveDataSource(DataSourceConfig config) { + if (config == null) { + throw new RuntimeException("Device Management Repository data source configuration " + + "is null and thus, is not initialized"); + } + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); + if (jndiConfig != null) { + if (log.isDebugEnabled()) { + log.debug("Initializing Device Management Repository data source using the JNDI " + + "Lookup Definition"); + } + List jndiPropertyList = + jndiConfig.getJndiProperties(); + if (jndiPropertyList != null) { + Hashtable jndiProperties = new Hashtable<>(); + for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { + jndiProperties.put(prop.getName(), prop.getValue()); + } + dataSource = ConnectionManagerUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); + } else { + dataSource = ConnectionManagerUtil.lookupDataSource(jndiConfig.getJndiName(), null); + } + } + return dataSource; + } + + public static DataSource lookupDataSource(String dataSourceName, + final Hashtable jndiProperties) { + + try { + if (jndiProperties == null || jndiProperties.isEmpty()) { + return (DataSource) InitialContext.doLookup(dataSourceName); + } + final InitialContext context = new InitialContext(jndiProperties); + return (DataSource) context.lookup(dataSourceName); + } catch (Exception e) { + String msg = "Error in looking up data source: " + e.getMessage(); + log.error(msg, e); + throw new RuntimeException(msg + e.getMessage(), e); + } + } + + public static String getDatabaseType() { + try { + return dataSource.getConnection().getMetaData().getDatabaseProductName(); + } catch (SQLException e) { + log.error("Error occurred while retrieving config.datasource connection", e); + } + return null; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java new file mode 100644 index 0000000000..187924f09a --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dao.util; + +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class DAOUtil { + + private static final Log log = LogFactory.getLog(DAOUtil.class); + + public static DeviceSubType loadDeviceSubType(ResultSet rs) throws SQLException { + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { return null; } + }; + deviceSubType.setTenantId(rs.getInt("TENANT_ID")); + deviceSubType.setSubTypeId(rs.getInt("SUB_TYPE_ID")); + deviceSubType.setSubTypeName(rs.getString("SUB_TYPE_NAME")); + deviceSubType.setDeviceType(DeviceSubType.DeviceType.valueOf(rs.getString("DEVICE_TYPE"))); + deviceSubType.setTypeDefinition(rs.getString("TYPE_DEFINITION")); + return deviceSubType; + } + + public static List loadDeviceSubTypes(ResultSet rs) throws SQLException { + List deviceSubTypes = new ArrayList<>(); + while (rs.next()) { + deviceSubTypes.add(loadDeviceSubType(rs)); + } + return deviceSubTypes; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java new file mode 100644 index 0000000000..6d93bafa48 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dto; + + +import com.fasterxml.jackson.core.JsonProcessingException; + + +public abstract class DeviceSubType { + + private int subTypeId; + private int tenantId; + private DeviceType deviceType; + private String subTypeName; + private String typeDefinition; + + public int getSubTypeId() { + return subTypeId; + } + + public void setSubTypeId(int subTypeId) { + this.subTypeId = subTypeId; + } + + public int getTenantId() { + return tenantId; + } + + public void setTenantId(int tenantId) { + this.tenantId = tenantId; + } + + public DeviceType getDeviceType() { + return deviceType; + } + + public void setDeviceType(DeviceType deviceType) { + this.deviceType = deviceType; + } + + public String getSubTypeName() { + return subTypeName; + } + + public void setSubTypeName(String subTypeName) { + this.subTypeName = subTypeName; + } + + public String getTypeDefinition() { + return typeDefinition; + } + + public void setTypeDefinition(String typeDefinition) { + this.typeDefinition = typeDefinition; + } + + public abstract DeviceSubType setDeviceSubType(T objType, String typeDef); + + public abstract String parseSubTypeToJson(Object objType) throws JsonProcessingException; + + public enum DeviceType { + COM, METER, SIM + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java new file mode 100644 index 0000000000..78d74ab89c --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.dto; + +public class DeviceSubTypeCacheKey { + int tenantId; + int subTypeId; + DeviceSubType.DeviceType deviceType; + + public int getTenantId() { + return tenantId; + } + + public void setTenantId(int tenantId) { + this.tenantId = tenantId; + } + + public int getSubTypeId() { + return subTypeId; + } + + public void setSubTypeId(int subTypeId) { + this.subTypeId = subTypeId; + } + + public DeviceSubType.DeviceType getDeviceType() { + return deviceType; + } + + public void setDeviceType(DeviceSubType.DeviceType deviceType) { + this.deviceType = deviceType; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java new file mode 100644 index 0000000000..24cf90438a --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.exception; + +/** + * Represents the exception thrown during validating the request. + */ +public class BadRequestException extends SubTypeMgtPluginException { + + private static final long serialVersionUID = 4082332498085984791L; + + public BadRequestException(String message, Throwable ex) { + super(message, ex); + } + + public BadRequestException(String message) { + super(message); + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java new file mode 100644 index 0000000000..e5f3edec1c --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.exception; + +/** + * Exception thrown due to Database Connection issues. + */ +public class DBConnectionException extends Exception { + + private static final long serialVersionUID = 8568807205814328601L; + + public DBConnectionException(String message, Throwable cause) { + super(message, cause); + } + + public DBConnectionException(String msg) { + super(msg); + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java new file mode 100644 index 0000000000..645d387b5b --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.exception; + +public class SubTypeMgtDAOException extends Exception { + + private static final long serialVersionUID = 3031989080569168761L; + private String errorMessage; + + public SubTypeMgtDAOException() { + super(); + } + + public SubTypeMgtDAOException(Throwable cause) { + super(cause); + } + + public SubTypeMgtDAOException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public SubTypeMgtDAOException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public SubTypeMgtDAOException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java new file mode 100644 index 0000000000..b6ee6b6526 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.exception; + +public class SubTypeMgtPluginException extends Exception { + + private static final long serialVersionUID = -8034442883708462443L; + private String errorMessage; + + public SubTypeMgtPluginException() { + super(); + } + + public SubTypeMgtPluginException(Throwable cause) { + super(cause); + } + + public SubTypeMgtPluginException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public SubTypeMgtPluginException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public SubTypeMgtPluginException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java new file mode 100644 index 0000000000..368f39c8f8 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.impl; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import io.entgra.device.mgt.subtype.mgt.cache.GetDeviceSubTypeCacheLoader; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAO; +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtDAOException; +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import io.entgra.device.mgt.subtype.mgt.spi.DeviceSubTypeService; +import io.entgra.device.mgt.subtype.mgt.util.DeviceSubTypeMgtUtil; +import io.entgra.device.mgt.subtype.mgt.exception.BadRequestException; +import io.entgra.device.mgt.subtype.mgt.exception.DBConnectionException; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtPluginException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; + +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { + private static final Log log = LogFactory.getLog(DeviceSubTypeServiceImpl.class); + private static final LoadingCache deviceSubTypeCache = CacheBuilder.newBuilder() + .expireAfterWrite(15, TimeUnit.MINUTES).build(new GetDeviceSubTypeCacheLoader()); + private final DeviceSubTypeDAO deviceSubTypeDAO; + + public DeviceSubTypeServiceImpl() { + this.deviceSubTypeDAO = DeviceSubTypeDAOFactory.getDeviceSubTypeDAO(); + } + + @Override + public boolean addDeviceSubType(DeviceSubType deviceSubType) + throws SubTypeMgtPluginException { + String msg = ""; + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + deviceSubType.setTenantId(tenantId); + + try { + ConnectionManagerUtil.beginDBTransaction(); + + //TODO This is done as a temporary... we need to implement addDeviceSubType method either with uuid + // or auto incrementing subtype id. In order to that we have to fix hardcoded subtype id in code level.. + // ex: transport code level + + int maxSubTypeId = deviceSubTypeDAO.getMaxSubTypeId(deviceSubType.getDeviceType()); + deviceSubType.setSubTypeId(maxSubTypeId + 1); + boolean result = deviceSubTypeDAO.addDeviceSubType(deviceSubType); + if (result) { + msg = "Device subtype added successfully,for " + deviceSubType.getDeviceType() + " subtype & subtype " + + "Id: " + + deviceSubType.getSubTypeId(); + } else { + msg = "Device subtype failed to add,for " + deviceSubType.getDeviceType() + " subtype & subtype Id: " + + deviceSubType.getSubTypeId(); + throw new SubTypeMgtPluginException(msg); + } + ConnectionManagerUtil.commitDBTransaction(); + String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, deviceSubType.getSubTypeId(), + deviceSubType.getDeviceType()); + deviceSubTypeCache.put(key, deviceSubType); + if (log.isDebugEnabled()) { + log.debug(msg); + } + return true; + } catch (DBConnectionException e) { + msg = "Error occurred while obtaining the database connection to add device subtype for " + + deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId(); + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } catch (SubTypeMgtDAOException e) { + msg = "Error occurred in the database level while adding device subtype for " + + deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId(); + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, + String subTypeName, + String typeDefinition) throws SubTypeMgtPluginException { + String msg = ""; + DeviceSubType deviceSubTypeOld = getDeviceSubType(subTypeId, tenantId, deviceType); + + if (deviceSubTypeOld == null) { + String errorMsg = "Cannot find device subtype for " + deviceType + " subtype & subtype Id: " + subTypeId; + log.error(errorMsg); + throw new BadRequestException(errorMsg); + } + try { + ConnectionManagerUtil.beginDBTransaction(); + boolean result = deviceSubTypeDAO.updateDeviceSubType(subTypeId, tenantId, deviceType, subTypeName, + typeDefinition); + if (result) { + msg = "Device subtype updated successfully,for " + deviceType + " subtype & subtype Id: " + subTypeId; + } else { + msg = "Device subtype failed to update,for " + deviceType + " subtype & subtype Id: " + subTypeId; + throw new SubTypeMgtPluginException(msg); + } + ConnectionManagerUtil.commitDBTransaction(); + if (log.isDebugEnabled()) { + log.debug(msg); + } + return true; + } catch (DBConnectionException e) { + msg = "Error occurred while obtaining the database connection to update device subtype for " + deviceType + + " subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } catch (SubTypeMgtDAOException e) { + msg = "Error occurred in the database level while updating device subtype for " + deviceType + + " subtype & subtype Id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, subTypeId, deviceType); + deviceSubTypeCache.refresh(key); + } + } + + @Override + public DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException { + try { + String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, subTypeId, deviceType); + return deviceSubTypeCache.get(key); + } catch (CacheLoader.InvalidCacheLoadException e) { + String msg = "Not having any sim subtype for subtype id: " + subTypeId; + log.error(msg, e); + return null; + } catch (ExecutionException e) { + String msg = "Error occurred while obtaining device subtype for subtype id: " + subTypeId; + log.error(msg, e); + throw new SubTypeMgtPluginException(msg, e); + } + } + + @Override + public List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException { + try { + ConnectionManagerUtil.openDBConnection(); + return deviceSubTypeDAO.getAllDeviceSubTypes(tenantId, deviceType); + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the database connection to retrieve all device subtype for " + + deviceType + " subtypes"; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } catch (SubTypeMgtDAOException e) { + String msg = "Error occurred in the database level while retrieving all device subtype for " + deviceType + + " subtypes"; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtPluginException { + try { + ConnectionManagerUtil.openDBConnection(); + int result = deviceSubTypeDAO.getDeviceSubTypeCount(deviceType); + if (result <= 0) { + String msg = "There are no any subtypes for device type: " + deviceType; + log.info(msg); + } + return result; + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the database connection to retrieve device subtypes count " + + "for " + deviceType + " subtypes"; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } catch (SubTypeMgtDAOException e) { + String msg = "Error occurred in the database level while retrieving device subtypes count for " + deviceType + + " subtypes"; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, + DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException { + try { + ConnectionManagerUtil.openDBConnection(); + return deviceSubTypeDAO.getDeviceSubTypeByProvider(subTypeName, tenantId, deviceType); + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the database connection to retrieve device subtype for " + + deviceType + " subtype & subtype name: " + subTypeName; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } catch (SubTypeMgtDAOException e) { + String msg = "Error occurred in the database level while retrieving device subtype for " + deviceType + + " subtype & subtype name: " + subTypeName; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java new file mode 100644 index 0000000000..b804810f70 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.internal; + +import io.entgra.device.mgt.subtype.mgt.spi.DeviceSubTypeService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.registry.core.service.RegistryService; + +public class DeviceSubTypeMgtDataHolder { + + public static final DeviceSubTypeMgtDataHolder thisInstance = new DeviceSubTypeMgtDataHolder(); + + private RegistryService registryService; + private DeviceManagementProviderService deviceManagementProviderService; + private DeviceSubTypeService deviceSubTypeService; + + private DeviceSubTypeMgtDataHolder() { + } + + public static DeviceSubTypeMgtDataHolder getInstance() { + return thisInstance; + } + + public RegistryService getRegistryService() { + return registryService; + } + + public void setRegistryService(RegistryService registryService) { + this.registryService = registryService; + } + + public DeviceManagementProviderService getDeviceManagementProviderService() { + return deviceManagementProviderService; + } + + public void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) { + this.deviceManagementProviderService = deviceManagementProviderService; + } + + public DeviceSubTypeService getDeviceSubTypeService() { + return deviceSubTypeService; + } + + public void setDeviceSubTypeService(DeviceSubTypeService deviceSubTypeService) { + this.deviceSubTypeService = deviceSubTypeService; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java new file mode 100644 index 0000000000..32f197a380 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.internal; + +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.subtype.mgt.impl.DeviceSubTypeServiceImpl; +import io.entgra.device.mgt.subtype.mgt.spi.DeviceSubTypeService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; +import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.ndatasource.core.DataSourceService; +import org.wso2.carbon.registry.core.service.RegistryService; + +/** + * @scr.component name="io.entgra.device.mgt.subtype.mgt.internal.DeviceSubTypeMgtServiceComponent" immediate="true" + * @scr.reference name="org.wso2.carbon.device.manager" + * interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDeviceManagementService" + * unbind="unsetDeviceManagementService" + * @scr.reference name="org.wso2.carbon.ndatasource" + * interface="org.wso2.carbon.ndatasource.core.DataSourceService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDataSourceService" + * unbind="unsetDataSourceService" + * @scr.reference name="registry.service" + * interface="org.wso2.carbon.registry.core.service.RegistryService" + * cardinality="0..1" + * policy="dynamic" + * bind="setRegistryService" + * unbind="unsetRegistryService" + */ +public class DeviceSubTypeMgtServiceComponent { + + private static final Log log = LogFactory.getLog(DeviceSubTypeMgtServiceComponent.class); + + protected void activate(ComponentContext componentContext) { + + if (log.isDebugEnabled()) { + log.debug("Activating Device SubType Management Service Component"); + } + try { + BundleContext bundleContext = componentContext.getBundleContext(); + + DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig(); + DeviceSubTypeDAOFactory.init(dsConfig); + + DeviceSubTypeService deviceSubTypeService = new DeviceSubTypeServiceImpl(); + DeviceSubTypeMgtDataHolder.getInstance().setDeviceSubTypeService(deviceSubTypeService); + bundleContext.registerService(DeviceSubTypeService.class, deviceSubTypeService, null); + + if (log.isDebugEnabled()) { + log.debug("Device SubType Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Device SubType Management Service Component", e); + } + } + + protected void deactivate(ComponentContext componentContext) { + if (log.isDebugEnabled()) { + log.debug("De-activating Device SubType Management Service Component"); + } + } + + @SuppressWarnings("unused") + protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { + if (log.isDebugEnabled()) { + log.debug("Setting Device Management Service to Device SubType Mgt SC"); + } + DeviceSubTypeMgtDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); + } + + @SuppressWarnings("unused") + protected void unsetDeviceManagementService(DeviceManagementProviderService deviceManagementService) { + if (log.isDebugEnabled()) { + log.debug("Removing Device Management Service from Device SubType Mgt SC"); + } + DeviceSubTypeMgtDataHolder.getInstance().setDeviceManagementProviderService(null); + } + + protected void setDataSourceService(DataSourceService dataSourceService) { + /* This is to avoid mobile device management component getting initialized before the underlying datasources + are registered */ + if (log.isDebugEnabled()) { + log.debug("Data source service set to Device SubType Mgt component"); + } + } + + protected void unsetDataSourceService(DataSourceService dataSourceService) { + //do nothing + if (log.isDebugEnabled()) { + log.debug("Removing Data Source service from Device SubType Mgt component"); + } + } + + + protected void setRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("RegistryService set to Device SubType Mgt component"); + } + DeviceSubTypeMgtDataHolder.getInstance().setRegistryService(registryService); + } + + protected void unsetRegistryService(RegistryService registryService) { + if (log.isDebugEnabled()) { + log.debug("Removing RegistryService from Device SubType Mgt component"); + } + DeviceSubTypeMgtDataHolder.getInstance().setRegistryService(null); + } + + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java new file mode 100644 index 0000000000..1377d224f1 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.spi; + +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtPluginException; + +import java.util.List; + +public interface DeviceSubTypeService { + + boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtPluginException; + + boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, + String typeDefinition) throws SubTypeMgtPluginException; + + DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException; + + List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException; + + int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtPluginException; + + DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException; +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java new file mode 100644 index 0000000000..7a96cd8581 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.util; + +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubTypeCacheKey; + +public class DeviceSubTypeMgtUtil { + public static String setDeviceSubTypeCacheKey(int tenantId, int subTypeId, DeviceSubType.DeviceType deviceType) { + return tenantId + "|" + subTypeId + "|" + deviceType.toString(); + } + + public static DeviceSubTypeCacheKey getDeviceSubTypeCacheKey(String key) { + String[] keys = key.split("\\|"); + int tenantId = Integer.parseInt(keys[0]); + int subTypeId = Integer.parseInt(keys[1]); + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.valueOf(keys[2]); + + DeviceSubTypeCacheKey deviceSubTypesCacheKey = new DeviceSubTypeCacheKey(); + deviceSubTypesCacheKey.setTenantId(tenantId); + deviceSubTypesCacheKey.setSubTypeId(subTypeId); + deviceSubTypesCacheKey.setDeviceType(deviceType); + return deviceSubTypesCacheKey; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java new file mode 100644 index 0000000000..8806af6731 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt; + +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAO; +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.exception.DBConnectionException; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtDAOException; +import io.entgra.device.mgt.subtype.mgt.mock.BaseDeviceSubTypePluginTest; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +public class DAONegativeTest extends BaseDeviceSubTypePluginTest { + private static final Log log = LogFactory.getLog(DAONegativeTest.class); + + private DeviceSubTypeDAO deviceSubTypeDAO; + + @BeforeClass + public void init() { + deviceSubTypeDAO = DeviceSubTypeDAOFactory.getDeviceSubTypeDAO(); + log.info("DAO Negative test initialized"); + } + + @Test(description = "This method tests the add device subtype method under negative circumstances with null data", + expectedExceptions = {NullPointerException.class} + ) + public void testAddDeviceSubType() throws SubTypeMgtDAOException { + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { + return null; + } + }; + try { + ConnectionManagerUtil.beginDBTransaction(); + deviceSubTypeDAO.addDeviceSubType(deviceSubType); + ConnectionManagerUtil.commitDBTransaction(); + } catch (SubTypeMgtDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + String msg = "Error occurred while processing SQL to insert device subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to insert device subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Test(description = "This method tests the add device subtype method under negative circumstances while missing " + + "required fields", + expectedExceptions = {SubTypeMgtDAOException.class}, + expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype" + ) + public void testAddDeviceSubTypes() throws SubTypeMgtDAOException { + int subTypeId = 1; + String subTypeName = "TestSubType"; + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { + return null; + } + }; + deviceSubType.setSubTypeId(subTypeId); + deviceSubType.setSubTypeName(subTypeName); + deviceSubType.setDeviceType(DeviceSubType.DeviceType.COM); + try { + ConnectionManagerUtil.beginDBTransaction(); + deviceSubTypeDAO.addDeviceSubType(deviceSubType); + ConnectionManagerUtil.commitDBTransaction(); + } catch (SubTypeMgtDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + String msg = "Error occurred while processing SQL to insert device subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to insert device subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Test(description = "This method tests the add device subtype method under negative circumstances while passing " + + "same subtype id & device type", + expectedExceptions = {SubTypeMgtDAOException.class}, + expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype" + ) + public void testAddDeviceSubtypes() throws SubTypeMgtDAOException { + int subTypeId = 1; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String subTypeName = "TestSubType"; + String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { + return null; + } + }; + deviceSubType.setSubTypeName(subTypeName); + deviceSubType.setDeviceType(DeviceSubType.DeviceType.COM); + deviceSubType.setTenantId(tenantId); + deviceSubType.setTypeDefinition(typeDefinition); + try { + ConnectionManagerUtil.beginDBTransaction(); + deviceSubTypeDAO.addDeviceSubType(deviceSubType); + deviceSubTypeDAO.addDeviceSubType(deviceSubType); + ConnectionManagerUtil.commitDBTransaction(); + } catch (SubTypeMgtDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + String msg = "Error occurred while processing SQL to insert device subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining DB connection to insert device subtype"; + log.error(msg); + throw new SubTypeMgtDAOException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java new file mode 100644 index 0000000000..8ead113a40 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt; + +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAO; +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.exception.DBConnectionException; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtDAOException; +import io.entgra.device.mgt.subtype.mgt.mock.BaseDeviceSubTypePluginTest; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import java.util.List; + +public class DAOTest extends BaseDeviceSubTypePluginTest { + private static final Log log = LogFactory.getLog(DAOTest.class); + + private DeviceSubTypeDAO deviceSubTypeDAO; + + @BeforeClass + public void init() { + deviceSubTypeDAO = DeviceSubTypeDAOFactory.getDeviceSubTypeDAO(); + log.info("DAO test initialized"); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + ConnectionManagerUtil.openDBConnection(); + DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType(1, tenantId, + DeviceSubType.DeviceType.COM); + ConnectionManagerUtil.closeDBConnection(); + Assert.assertNotNull(subTypeActual, "Should not be null"); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetAllDeviceSubTypes() throws DBConnectionException, SubTypeMgtDAOException { + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + ConnectionManagerUtil.openDBConnection(); + List subTypesActual = deviceSubTypeDAO.getAllDeviceSubTypes(tenantId, deviceType); + ConnectionManagerUtil.closeDBConnection(); + log.info(deviceType + " sub types count should be " + subTypesActual.size()); + Assert.assertNotNull(subTypesActual, "Should not be null"); + } + + @Test + public void testAddDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { + int subTypeId = 1; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String subTypeName = "TestSubType"; + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); + + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { + return null; + } + }; + deviceSubType.setSubTypeId(subTypeId); + deviceSubType.setSubTypeName(subTypeName); + deviceSubType.setDeviceType(deviceType); + deviceSubType.setTenantId(tenantId); + deviceSubType.setTypeDefinition(typeDefinition); + + ConnectionManagerUtil.beginDBTransaction(); + deviceSubTypeDAO.addDeviceSubType(deviceSubType); + ConnectionManagerUtil.commitDBTransaction(); + DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType(subTypeId, tenantId, deviceType); + ConnectionManagerUtil.closeDBConnection(); + Assert.assertNotNull(subTypeActual, "Cannot be null"); + TestUtils.verifyDeviceSubTypeDAO(subTypeActual); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testUpdateDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { + int subTypeId = 1; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String subTypeName = "TestSubType"; + String subTypeExpected = TestUtils.createUpdateDeviceSubType(subTypeId); + + ConnectionManagerUtil.beginDBTransaction(); + deviceSubTypeDAO.updateDeviceSubType(subTypeId, tenantId, deviceType, subTypeName, subTypeExpected); + ConnectionManagerUtil.commitDBTransaction(); + DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType(subTypeId, tenantId, deviceType); + ConnectionManagerUtil.closeDBConnection(); + + Assert.assertNotNull(subTypeActual, "Cannot be null"); + TestUtils.verifyUpdatedDeviceSubTypeDAO(subTypeActual); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetDeviceTypeCount() throws DBConnectionException, SubTypeMgtDAOException { + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + ConnectionManagerUtil.openDBConnection(); + int subTypeCount = deviceSubTypeDAO.getDeviceSubTypeCount(deviceType); + ConnectionManagerUtil.closeDBConnection(); + log.info(deviceType + " Device subtypes count: " + subTypeCount); + Assert.assertEquals(subTypeCount, 1); + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java new file mode 100644 index 0000000000..72ae35e131 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "DataSourceConfig") +public class DataSourceConfig { + + private String url; + private String driverClassName; + private String user; + private String password; + + @Override + public String toString() { + return "DataSourceConfig[" + + " Url ='" + url + '\'' + + ", DriverClassName ='" + driverClassName + '\'' + + ", UserName ='" + user + '\'' + + ", Password ='" + password + '\'' + + "]"; + } + + @XmlElement(name = "Url", nillable = false) + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @XmlElement(name = "DriverClassName", nillable = false) + public String getDriverClassName() { + return driverClassName; + } + + public void setDriverClassName(String driverClassName) { + this.driverClassName = driverClassName; + } + + @XmlElement(name = "User", nillable = false) + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + @XmlElement(name = "Password", nillable = false) + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java new file mode 100644 index 0000000000..5d0613ca62 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt; + +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtPluginException; +import io.entgra.device.mgt.subtype.mgt.impl.DeviceSubTypeServiceImpl; +import io.entgra.device.mgt.subtype.mgt.mock.BaseDeviceSubTypePluginTest; +import io.entgra.device.mgt.subtype.mgt.spi.DeviceSubTypeService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest { + + private static final Log log = LogFactory.getLog(ServiceNegativeTest.class); + private DeviceSubTypeService deviceSubTypeService; + + @BeforeClass + public void init() { + deviceSubTypeService = new DeviceSubTypeServiceImpl(); + log.info("Service test initialized"); + } + + @Test(description = "This method tests Add Device Subtype method under negative circumstances with null data", + expectedExceptions = {NullPointerException.class}) + public void testAddDeviceSubType() throws SubTypeMgtPluginException { + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { + return null; + } + }; + deviceSubTypeService.addDeviceSubType(deviceSubType); + } + + @Test(description = "This method tests Add Device Subtype method under negative circumstances while missing " + + "required fields", + expectedExceptions = {SubTypeMgtPluginException.class}, + expectedExceptionsMessageRegExp = "Error occurred in the database level while adding device subtype for " + + "SIM subtype & subtype Id: 1") + public void testAddDeviceSubTypes() throws SubTypeMgtPluginException { + String subTypeName = "TestSubType"; + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; + + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { + return null; + } + }; + deviceSubType.setSubTypeName(subTypeName); + deviceSubType.setDeviceType(deviceType); + deviceSubTypeService.addDeviceSubType(deviceSubType); + } + + @Test(description = "This method tests Update Device Subtype method under negative circumstances with invalid " + + "subtype Id", + expectedExceptions = {SubTypeMgtPluginException.class}, + expectedExceptionsMessageRegExp = "Cannot find device subtype for SIM subtype & subtype Id: 15") + public void testUpdateDeviceSubTypes() throws SubTypeMgtPluginException { + int subTypeId = 15; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; + String subTypeName = "TestSubType"; + String subTypeExpected = TestUtils.createUpdateDeviceSubType(subTypeId); + + deviceSubTypeService.updateDeviceSubType(subTypeId, tenantId, deviceType, subTypeName, subTypeExpected); + } + + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java new file mode 100644 index 0000000000..a4e3de177d --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt; + +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.subtype.mgt.exception.SubTypeMgtPluginException; +import io.entgra.device.mgt.subtype.mgt.impl.DeviceSubTypeServiceImpl; +import io.entgra.device.mgt.subtype.mgt.mock.BaseDeviceSubTypePluginTest; +import io.entgra.device.mgt.subtype.mgt.spi.DeviceSubTypeService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import java.util.List; + + +public class ServiceTest extends BaseDeviceSubTypePluginTest { + + private static final Log log = LogFactory.getLog(ServiceTest.class); + private DeviceSubTypeService deviceSubTypeService; + + @BeforeClass + public void init() { + deviceSubTypeService = new DeviceSubTypeServiceImpl(); + log.info("Service test initialized"); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetDeviceType() throws SubTypeMgtPluginException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType(1, tenantId, + DeviceSubType.DeviceType.METER); + TestUtils.verifyDeviceSubType(subTypeActual); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetAllDeviceTypes() throws SubTypeMgtPluginException { + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + List subTypesActual = deviceSubTypeService.getAllDeviceSubTypes(tenantId, deviceType); + log.info(deviceType + " sub types count should be " + subTypesActual.size()); + Assert.assertNotNull(subTypesActual, "Should not be null"); + } + + @Test + public void testAddDeviceSubType() throws SubTypeMgtPluginException { + int subTypeId = 1; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String subTypeName = "TestSubType"; + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); + + DeviceSubType deviceSubType = new DeviceSubType() { + @Override + public DeviceSubType setDeviceSubType(T objType, String typeDef) { + return null; + } + + @Override + public String parseSubTypeToJson(Object objType) { + return null; + } + }; + deviceSubType.setSubTypeName(subTypeName); + deviceSubType.setDeviceType(deviceType); + deviceSubType.setTenantId(tenantId); + deviceSubType.setTypeDefinition(typeDefinition); + deviceSubTypeService.addDeviceSubType(deviceSubType); + + DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType(subTypeId, tenantId, deviceType); + Assert.assertNotNull(subTypeActual, "Cannot be null"); + TestUtils.verifyDeviceSubType(subTypeActual); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testUpdateDeviceSubType() throws SubTypeMgtPluginException { + int subTypeId = 1; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String subTypeName = "TestSubType"; + String subTypeExpected = TestUtils.createUpdateDeviceSubType(subTypeId); + + deviceSubTypeService.updateDeviceSubType(subTypeId, tenantId, deviceType, subTypeName, subTypeExpected); + + DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType(subTypeId, tenantId, deviceType); + + Assert.assertNotNull(subTypeActual, "Cannot be null"); + TestUtils.verifyUpdatedDeviceSubType(subTypeActual); + } + + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetDeviceTypeCount() throws SubTypeMgtPluginException { + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + int subTypeCount = deviceSubTypeService.getDeviceSubTypeCount(deviceType); + log.info(deviceType + " Device subtypes count: " + subTypeCount); + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java new file mode 100644 index 0000000000..538b4be918 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt; + +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class TestUtils { + private static final Log log = LogFactory.getLog(TestUtils.class); + + public static String createNewDeviceSubType(int subtypeId) { + return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM800\", " + + "\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": true, \"hasICMPSupport\": true, " + + "\"socketServerPort\": 8071}"; + } + + public static String createUpdateDeviceSubType(int subtypeId) { + return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM900\", " + + "\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": false, \"hasICMPSupport\": true, " + + "\"socketServerPort\": 8071}"; + } + + public static void verifyDeviceSubType(DeviceSubType deviceSubType) { + String typeDefExpected = TestUtils.createNewDeviceSubType(1); + Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); + Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); + Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); + } + + public static void verifyDeviceSubTypeDAO(DeviceSubType deviceSubType) { + String typeDefExpected = TestUtils.createNewDeviceSubType(1); + Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); + Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); + Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); + } + + public static void verifyUpdatedDeviceSubType(DeviceSubType deviceSubType) { + String typeDefExpected = TestUtils.createUpdateDeviceSubType(1); + Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); + Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); + Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); + } + + public static void verifyUpdatedDeviceSubTypeDAO(DeviceSubType deviceSubType) { + String typeDefExpected = TestUtils.createUpdateDeviceSubType(1); + Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); + Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); + Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); + } + + public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing result set", e); + } + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing prepared statement", e); + } + } + if (conn != null) { + ConnectionManagerUtil.closeDBConnection(); + } + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java new file mode 100644 index 0000000000..892287fc8f --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.mock; + +import io.entgra.device.mgt.subtype.mgt.TestUtils; +import io.entgra.device.mgt.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.subtype.mgt.DataSourceConfig; +import io.entgra.device.mgt.subtype.mgt.dao.util.ConnectionManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.w3c.dom.Document; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; + +import javax.sql.DataSource; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import java.io.File; +import java.lang.reflect.Field; +import java.sql.Connection; +import java.sql.Statement; + +public abstract class BaseDeviceSubTypePluginTest { + + private static final Log log = LogFactory.getLog(BaseDeviceSubTypePluginTest.class); + + private static final String datasourceLocation = "src/test/resources/carbon-home/repository/conf/" + + "datasources/data-source-config.xml"; + + private static boolean mock; + + @BeforeSuite + @Parameters({"isMock"}) + public void setup(@Optional("false") boolean isMock) throws Exception { + log.info("Setting up test suite"); + this.initDataSource(); + this.initSQLScript(); + this.initializeCarbonContext(); + this.initServices(); + mock = isMock; + log.info("Setting up test suite done!"); + } + + protected void initDataSource() throws Exception { + DataSource dataSource = this.getDataSource(this.readDataSourceConfig()); + Class clazz1 = ConnectionManagerUtil.class; + Field f1 = clazz1.getDeclaredField("dataSource"); + f1.setAccessible(true); + f1.set(clazz1, dataSource); + + Class clazz2 = DeviceSubTypeDAOFactory.class; + Field f2 = clazz2.getDeclaredField("databaseEngine"); + f2.setAccessible(true); + f2.set(clazz2, DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2); + } + + private void initServices() { + + } + + @BeforeClass + public abstract void init() throws Exception; + + protected DataSource getDataSource(DataSourceConfig config) { + if (!isMock()) { + PoolProperties properties = new PoolProperties(); + properties.setUrl(config.getUrl()); + properties.setDriverClassName(config.getDriverClassName()); + properties.setUsername(config.getUser()); + properties.setPassword(config.getPassword()); + return new org.apache.tomcat.jdbc.pool.DataSource(properties); + } else { + return new MockDataSource(config.getUrl()); + } + } + + private void initializeCarbonContext() { + if (System.getProperty("carbon.home") == null) { + File file = new File("src/test/resources/carbon-home"); + if (file.exists()) { + System.setProperty("carbon.home", file.getAbsolutePath()); + } + file = new File("../resources/carbon-home"); + if (file.exists()) { + System.setProperty("carbon.home", file.getAbsolutePath()); + } + file = new File("../../resources/carbon-home"); + if (file.exists()) { + System.setProperty("carbon.home", file.getAbsolutePath()); + } + file = new File("../../../resources/carbon-home"); + if (file.exists()) { + System.setProperty("carbon.home", file.getAbsolutePath()); + } + } + + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants + .SUPER_TENANT_DOMAIN_NAME); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID); + } + + protected DataSourceConfig readDataSourceConfig() throws DeviceManagementException { + try { + File file = new File(BaseDeviceSubTypePluginTest.datasourceLocation); + Document doc = DeviceManagerUtil.convertToDocument(file); + JAXBContext testDBContext = JAXBContext.newInstance(DataSourceConfig.class); + Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); + return (DataSourceConfig) unmarshaller.unmarshal(doc); + } catch (JAXBException e) { + throw new DeviceManagementException("Error occurred while reading data source configuration", e); + } + } + + private void initSQLScript() throws Exception { + Connection conn = null; + Statement stmt = null; + try { + ConnectionManagerUtil.beginDBTransaction(); + conn = ConnectionManagerUtil.getDBConnection(); + stmt = conn.createStatement(); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/carbon-home/dbscripts/dm-db-h2.sql'"); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/carbon-home/dbscripts/h2.sql'"); + } finally { + TestUtils.cleanupResources(conn, stmt, null); + } + } + + protected boolean isMock() { + return mock; + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java new file mode 100644 index 0000000000..2a74c56146 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.mock; + +import java.sql.CallableStatement; +import java.sql.SQLWarning; +import java.sql.Savepoint; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.Statement; +import java.sql.Clob; +import java.sql.Blob; +import java.sql.NClob; +import java.sql.SQLXML; +import java.sql.Struct; +import java.sql.Array; +import java.sql.SQLClientInfoException; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +/** + * This is mock class which provides mock database connection. + */ +public class MockConnection implements Connection { + + private final String url; + private final List statements = new ArrayList<>(); + private int statementCounter = 0; + + public MockConnection(String url) { + this.url = url; + } + + @Override + public Statement createStatement() throws SQLException { + return getStatement(); + } + + private MockStatement getStatement() { + if (!statements.isEmpty()) { + MockStatement statement = this.statements.get(this.statementCounter); + statementCounter++; + return statement; + } + return new MockStatement(); + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + return getStatement(); + } + + @Override + public CallableStatement prepareCall(String sql) throws SQLException { + return null; + } + + @Override + public String nativeSQL(String sql) throws SQLException { + return null; + } + + @Override + public boolean getAutoCommit() throws SQLException { + return false; + } + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + + } + + @Override + public void commit() throws SQLException { + + } + + @Override + public void rollback() throws SQLException { + + } + + @Override + public void close() throws SQLException { + + } + + @Override + public boolean isClosed() throws SQLException { + return false; + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + return new MockDatabaseMetaData(this.url); + } + + @Override + public boolean isReadOnly() throws SQLException { + return false; + } + + @Override + public void setReadOnly(boolean readOnly) throws SQLException { + + } + + @Override + public String getCatalog() throws SQLException { + return null; + } + + @Override + public void setCatalog(String catalog) throws SQLException { + + } + + @Override + public int getTransactionIsolation() throws SQLException { + return 0; + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return null; + } + + @Override + public void clearWarnings() throws SQLException { + + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return null; + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return null; + } + + @Override + public Map> getTypeMap() throws SQLException { + return null; + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + + } + + @Override + public int getHoldability() throws SQLException { + return 0; + } + + @Override + public void setHoldability(int holdability) throws SQLException { + + } + + @Override + public Savepoint setSavepoint() throws SQLException { + return null; + } + + @Override + public Savepoint setSavepoint(String name) throws SQLException { + return null; + } + + @Override + public void rollback(Savepoint savepoint) throws SQLException { + + } + + @Override + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return null; + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return null; + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { + return new MockStatement(); + } + + @Override + public Clob createClob() throws SQLException { + return null; + } + + @Override + public Blob createBlob() throws SQLException { + return null; + } + + @Override + public NClob createNClob() throws SQLException { + return null; + } + + @Override + public SQLXML createSQLXML() throws SQLException { + return null; + } + + @Override + public boolean isValid(int timeout) throws SQLException { + return false; + } + + @Override + public void setClientInfo(String name, String value) throws SQLClientInfoException { + + } + + @Override + public String getClientInfo(String name) throws SQLException { + return null; + } + + @Override + public Properties getClientInfo() throws SQLException { + return null; + } + + @Override + public void setClientInfo(Properties properties) throws SQLClientInfoException { + + } + + @Override + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + return null; + } + + @Override + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + return null; + } + + @Override + public String getSchema() throws SQLException { + return null; + } + + @Override + public void setSchema(String schema) throws SQLException { + + } + + @Override + public void abort(Executor executor) throws SQLException { + + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + + } + + @Override + public int getNetworkTimeout() throws SQLException { + return 0; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + public void addMockStatement(MockStatement mockStatement) { + this.statements.add(mockStatement); + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java new file mode 100644 index 0000000000..95502922f6 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.mock; + +import javax.sql.DataSource; +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +/** + * This is the mock data source implementation that will be used in the test cases. + */ +public class MockDataSource implements DataSource { + private final List connections = new ArrayList<>(); + private final String url; + private boolean throwException = false; + private int connectionCounter = 0; + + public MockDataSource(String url) { + this.url = url; + } + + @Override + public Connection getConnection() throws SQLException { + if (throwException) { + throw new SQLException("Cannot created test connection."); + } else { + if (!connections.isEmpty()) { + if (this.connectionCounter < this.connections.size()) { + Connection connection = this.connections.get(this.connectionCounter); + this.connectionCounter++; + return connection; + } else { + return new MockConnection(url); + } + } + return new MockConnection(url); + } + } + + public void setConnection(Connection connection) { + this.connections.add(connection); + } + + @Override + public Connection getConnection(String username, String password) throws SQLException { + return null; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public PrintWriter getLogWriter() throws SQLException { + return null; + } + + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + + } + + @Override + public int getLoginTimeout() throws SQLException { + return 0; + } + + @Override + public void setLoginTimeout(int seconds) throws SQLException { + + } + + @Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + return null; + } + + public void setThrowException(boolean throwException) { + this.throwException = throwException; + } + + public void reset() { + this.throwException = false; + this.connections.clear(); + this.connectionCounter = 0; + } + + public String getUrl() { + return this.url; + } + + public MockConnection getConnection(int id) { + return (MockConnection) this.connections.get(id); + } + +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java new file mode 100644 index 0000000000..5472f93ded --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java @@ -0,0 +1,942 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.mock; + +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.RowIdLifetime; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; + +public class MockDatabaseMetaData implements DatabaseMetaData { + private final String url; + + public MockDatabaseMetaData(String url) { + this.url = url; + } + + @Override + public boolean allProceduresAreCallable() throws SQLException { + return false; + } + + @Override + public boolean allTablesAreSelectable() throws SQLException { + return false; + } + + @Override + public String getURL() throws SQLException { + return null; + } + + @Override + public String getUserName() throws SQLException { + return null; + } + + @Override + public boolean isReadOnly() throws SQLException { + return false; + } + + @Override + public boolean nullsAreSortedHigh() throws SQLException { + return false; + } + + @Override + public boolean nullsAreSortedLow() throws SQLException { + return false; + } + + @Override + public boolean nullsAreSortedAtStart() throws SQLException { + return false; + } + + @Override + public boolean nullsAreSortedAtEnd() throws SQLException { + return false; + } + + @Override + public String getDatabaseProductName() throws SQLException { + if (this.url.contains("mysql")) { + return DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL; + } else if (this.url.contains("h2")) { + return DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2; + } else if (this.url.contains("oracle")) { + return DeviceManagementConstants.DataBaseTypes.DB_TYPE_ORACLE; + } else if (this.url.contains("postgresql")) { + return DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL; + } else if (this.url.contains("sqlserver")) { + return DeviceManagementConstants.DataBaseTypes.DB_TYPE_MSSQL; + } else { + return null; + } + } + + @Override + public String getDatabaseProductVersion() throws SQLException { + return null; + } + + @Override + public String getDriverName() throws SQLException { + return null; + } + + @Override + public String getDriverVersion() throws SQLException { + return null; + } + + @Override + public int getDriverMajorVersion() { + return 0; + } + + @Override + public int getDriverMinorVersion() { + return 0; + } + + @Override + public boolean usesLocalFiles() throws SQLException { + return false; + } + + @Override + public boolean usesLocalFilePerTable() throws SQLException { + return false; + } + + @Override + public boolean supportsMixedCaseIdentifiers() throws SQLException { + return false; + } + + @Override + public boolean storesUpperCaseIdentifiers() throws SQLException { + return false; + } + + @Override + public boolean storesLowerCaseIdentifiers() throws SQLException { + return false; + } + + @Override + public boolean storesMixedCaseIdentifiers() throws SQLException { + return false; + } + + @Override + public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { + return false; + } + + @Override + public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { + return false; + } + + @Override + public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { + return false; + } + + @Override + public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { + return false; + } + + @Override + public String getIdentifierQuoteString() throws SQLException { + return null; + } + + @Override + public String getSQLKeywords() throws SQLException { + return null; + } + + @Override + public String getNumericFunctions() throws SQLException { + return null; + } + + @Override + public String getStringFunctions() throws SQLException { + return null; + } + + @Override + public String getSystemFunctions() throws SQLException { + return null; + } + + @Override + public String getTimeDateFunctions() throws SQLException { + return null; + } + + @Override + public String getSearchStringEscape() throws SQLException { + return null; + } + + @Override + public String getExtraNameCharacters() throws SQLException { + return null; + } + + @Override + public boolean supportsAlterTableWithAddColumn() throws SQLException { + return false; + } + + @Override + public boolean supportsAlterTableWithDropColumn() throws SQLException { + return false; + } + + @Override + public boolean supportsColumnAliasing() throws SQLException { + return false; + } + + @Override + public boolean nullPlusNonNullIsNull() throws SQLException { + return false; + } + + @Override + public boolean supportsConvert() throws SQLException { + return false; + } + + @Override + public boolean supportsConvert(int fromType, int toType) throws SQLException { + return false; + } + + @Override + public boolean supportsTableCorrelationNames() throws SQLException { + return false; + } + + @Override + public boolean supportsDifferentTableCorrelationNames() throws SQLException { + return false; + } + + @Override + public boolean supportsExpressionsInOrderBy() throws SQLException { + return false; + } + + @Override + public boolean supportsOrderByUnrelated() throws SQLException { + return false; + } + + @Override + public boolean supportsGroupBy() throws SQLException { + return false; + } + + @Override + public boolean supportsGroupByUnrelated() throws SQLException { + return false; + } + + @Override + public boolean supportsGroupByBeyondSelect() throws SQLException { + return false; + } + + @Override + public boolean supportsLikeEscapeClause() throws SQLException { + return false; + } + + @Override + public boolean supportsMultipleResultSets() throws SQLException { + return false; + } + + @Override + public boolean supportsMultipleTransactions() throws SQLException { + return false; + } + + @Override + public boolean supportsNonNullableColumns() throws SQLException { + return false; + } + + @Override + public boolean supportsMinimumSQLGrammar() throws SQLException { + return false; + } + + @Override + public boolean supportsCoreSQLGrammar() throws SQLException { + return false; + } + + @Override + public boolean supportsExtendedSQLGrammar() throws SQLException { + return false; + } + + @Override + public boolean supportsANSI92EntryLevelSQL() throws SQLException { + return false; + } + + @Override + public boolean supportsANSI92IntermediateSQL() throws SQLException { + return false; + } + + @Override + public boolean supportsANSI92FullSQL() throws SQLException { + return false; + } + + @Override + public boolean supportsIntegrityEnhancementFacility() throws SQLException { + return false; + } + + @Override + public boolean supportsOuterJoins() throws SQLException { + return false; + } + + @Override + public boolean supportsFullOuterJoins() throws SQLException { + return false; + } + + @Override + public boolean supportsLimitedOuterJoins() throws SQLException { + return false; + } + + @Override + public String getSchemaTerm() throws SQLException { + return null; + } + + @Override + public String getProcedureTerm() throws SQLException { + return null; + } + + @Override + public String getCatalogTerm() throws SQLException { + return null; + } + + @Override + public boolean isCatalogAtStart() throws SQLException { + return false; + } + + @Override + public String getCatalogSeparator() throws SQLException { + return null; + } + + @Override + public boolean supportsSchemasInDataManipulation() throws SQLException { + return false; + } + + @Override + public boolean supportsSchemasInProcedureCalls() throws SQLException { + return false; + } + + @Override + public boolean supportsSchemasInTableDefinitions() throws SQLException { + return false; + } + + @Override + public boolean supportsSchemasInIndexDefinitions() throws SQLException { + return false; + } + + @Override + public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { + return false; + } + + @Override + public boolean supportsCatalogsInDataManipulation() throws SQLException { + return false; + } + + @Override + public boolean supportsCatalogsInProcedureCalls() throws SQLException { + return false; + } + + @Override + public boolean supportsCatalogsInTableDefinitions() throws SQLException { + return false; + } + + @Override + public boolean supportsCatalogsInIndexDefinitions() throws SQLException { + return false; + } + + @Override + public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { + return false; + } + + @Override + public boolean supportsPositionedDelete() throws SQLException { + return false; + } + + @Override + public boolean supportsPositionedUpdate() throws SQLException { + return false; + } + + @Override + public boolean supportsSelectForUpdate() throws SQLException { + return false; + } + + @Override + public boolean supportsStoredProcedures() throws SQLException { + return false; + } + + @Override + public boolean supportsSubqueriesInComparisons() throws SQLException { + return false; + } + + @Override + public boolean supportsSubqueriesInExists() throws SQLException { + return false; + } + + @Override + public boolean supportsSubqueriesInIns() throws SQLException { + return false; + } + + @Override + public boolean supportsSubqueriesInQuantifieds() throws SQLException { + return false; + } + + @Override + public boolean supportsCorrelatedSubqueries() throws SQLException { + return false; + } + + @Override + public boolean supportsUnion() throws SQLException { + return false; + } + + @Override + public boolean supportsUnionAll() throws SQLException { + return false; + } + + @Override + public boolean supportsOpenCursorsAcrossCommit() throws SQLException { + return false; + } + + @Override + public boolean supportsOpenCursorsAcrossRollback() throws SQLException { + return false; + } + + @Override + public boolean supportsOpenStatementsAcrossCommit() throws SQLException { + return false; + } + + @Override + public boolean supportsOpenStatementsAcrossRollback() throws SQLException { + return false; + } + + @Override + public int getMaxBinaryLiteralLength() throws SQLException { + return 0; + } + + @Override + public int getMaxCharLiteralLength() throws SQLException { + return 0; + } + + @Override + public int getMaxColumnNameLength() throws SQLException { + return 0; + } + + @Override + public int getMaxColumnsInGroupBy() throws SQLException { + return 0; + } + + @Override + public int getMaxColumnsInIndex() throws SQLException { + return 0; + } + + @Override + public int getMaxColumnsInOrderBy() throws SQLException { + return 0; + } + + @Override + public int getMaxColumnsInSelect() throws SQLException { + return 0; + } + + @Override + public int getMaxColumnsInTable() throws SQLException { + return 0; + } + + @Override + public int getMaxConnections() throws SQLException { + return 0; + } + + @Override + public int getMaxCursorNameLength() throws SQLException { + return 0; + } + + @Override + public int getMaxIndexLength() throws SQLException { + return 0; + } + + @Override + public int getMaxSchemaNameLength() throws SQLException { + return 0; + } + + @Override + public int getMaxProcedureNameLength() throws SQLException { + return 0; + } + + @Override + public int getMaxCatalogNameLength() throws SQLException { + return 0; + } + + @Override + public int getMaxRowSize() throws SQLException { + return 0; + } + + @Override + public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { + return false; + } + + @Override + public int getMaxStatementLength() throws SQLException { + return 0; + } + + @Override + public int getMaxStatements() throws SQLException { + return 0; + } + + @Override + public int getMaxTableNameLength() throws SQLException { + return 0; + } + + @Override + public int getMaxTablesInSelect() throws SQLException { + return 0; + } + + @Override + public int getMaxUserNameLength() throws SQLException { + return 0; + } + + @Override + public int getDefaultTransactionIsolation() throws SQLException { + return 0; + } + + @Override + public boolean supportsTransactions() throws SQLException { + return false; + } + + @Override + public boolean supportsTransactionIsolationLevel(int level) throws SQLException { + return false; + } + + @Override + public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { + return false; + } + + @Override + public boolean supportsDataManipulationTransactionsOnly() throws SQLException { + return false; + } + + @Override + public boolean dataDefinitionCausesTransactionCommit() throws SQLException { + return false; + } + + @Override + public boolean dataDefinitionIgnoredInTransactions() throws SQLException { + return false; + } + + @Override + public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) + throws SQLException { + return null; + } + + @Override + public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, + String columnNamePattern) throws SQLException { + return null; + } + + @Override + public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) + throws SQLException { + return null; + } + + @Override + public ResultSet getSchemas() throws SQLException { + return null; + } + + @Override + public ResultSet getCatalogs() throws SQLException { + return null; + } + + @Override + public ResultSet getTableTypes() throws SQLException { + return null; + } + + @Override + public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, + String columnNamePattern) throws SQLException { + return null; + } + + @Override + public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) + throws SQLException { + return null; + } + + @Override + public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) + throws SQLException { + return null; + } + + @Override + public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) + throws SQLException { + return null; + } + + @Override + public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { + return null; + } + + @Override + public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { + return null; + } + + @Override + public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { + return null; + } + + @Override + public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException { + return null; + } + + @Override + public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, + String foreignCatalog, String foreignSchema, String foreignTable) + throws SQLException { + return null; + } + + @Override + public ResultSet getTypeInfo() throws SQLException { + return null; + } + + @Override + public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) + throws SQLException { + return null; + } + + @Override + public boolean supportsResultSetType(int type) throws SQLException { + return false; + } + + @Override + public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { + return false; + } + + @Override + public boolean ownUpdatesAreVisible(int type) throws SQLException { + return false; + } + + @Override + public boolean ownDeletesAreVisible(int type) throws SQLException { + return false; + } + + @Override + public boolean ownInsertsAreVisible(int type) throws SQLException { + return false; + } + + @Override + public boolean othersUpdatesAreVisible(int type) throws SQLException { + return false; + } + + @Override + public boolean othersDeletesAreVisible(int type) throws SQLException { + return false; + } + + @Override + public boolean othersInsertsAreVisible(int type) throws SQLException { + return false; + } + + @Override + public boolean updatesAreDetected(int type) throws SQLException { + return false; + } + + @Override + public boolean deletesAreDetected(int type) throws SQLException { + return false; + } + + @Override + public boolean insertsAreDetected(int type) throws SQLException { + return false; + } + + @Override + public boolean supportsBatchUpdates() throws SQLException { + return false; + } + + @Override + public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) + throws SQLException { + return null; + } + + @Override + public Connection getConnection() throws SQLException { + return null; + } + + @Override + public boolean supportsSavepoints() throws SQLException { + return false; + } + + @Override + public boolean supportsNamedParameters() throws SQLException { + return false; + } + + @Override + public boolean supportsMultipleOpenResults() throws SQLException { + return false; + } + + @Override + public boolean supportsGetGeneratedKeys() throws SQLException { + return false; + } + + @Override + public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException { + return null; + } + + @Override + public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { + return null; + } + + @Override + public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, + String attributeNamePattern) throws SQLException { + return null; + } + + @Override + public boolean supportsResultSetHoldability(int holdability) throws SQLException { + return false; + } + + @Override + public int getResultSetHoldability() throws SQLException { + return 0; + } + + @Override + public int getDatabaseMajorVersion() throws SQLException { + return 0; + } + + @Override + public int getDatabaseMinorVersion() throws SQLException { + return 0; + } + + @Override + public int getJDBCMajorVersion() throws SQLException { + return 0; + } + + @Override + public int getJDBCMinorVersion() throws SQLException { + return 0; + } + + @Override + public int getSQLStateType() throws SQLException { + return 0; + } + + @Override + public boolean locatorsUpdateCopy() throws SQLException { + return false; + } + + @Override + public boolean supportsStatementPooling() throws SQLException { + return false; + } + + @Override + public RowIdLifetime getRowIdLifetime() throws SQLException { + return null; + } + + @Override + public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { + return null; + } + + @Override + public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { + return false; + } + + @Override + public boolean autoCommitFailureClosesAllResultSets() throws SQLException { + return false; + } + + @Override + public ResultSet getClientInfoProperties() throws SQLException { + return null; + } + + @Override + public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException { + return null; + } + + @Override + public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, + String columnNamePattern) throws SQLException { + return null; + } + + @Override + public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, + String columnNamePattern) throws SQLException { + return null; + } + + @Override + public boolean generatedKeyAlwaysReturned() throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java new file mode 100644 index 0000000000..75e0bca583 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java @@ -0,0 +1,1114 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.mock; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.ResultSet; +import java.sql.SQLWarning; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Clob; +import java.sql.Blob; +import java.sql.NClob; +import java.sql.SQLXML; +import java.sql.Ref; +import java.sql.Array; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.Statement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +public class MockResultSet implements ResultSet { + private final List stringList = new ArrayList<>(); + private final List integerList = new ArrayList<>(); + private final List doubleList = new ArrayList<>(); + private final List booleanList = new ArrayList<>(); + private final List timestamps = new ArrayList<>(); + + private final AtomicInteger stringCounter = new AtomicInteger(0); + private final AtomicInteger integerCounter = new AtomicInteger(0); + private final AtomicInteger doubleCounter = new AtomicInteger(0); + private final AtomicInteger booleanCounter = new AtomicInteger(0); + private final AtomicInteger timestampCounter = new AtomicInteger(0); + + private boolean iterated = false; + private boolean hasData = false; + + @Override + public boolean next() throws SQLException { + if (!this.iterated && this.hasData) { + this.iterated = true; + return true; + } else { + return false; + } + } + + @Override + public void close() throws SQLException { + + } + + @Override + public boolean wasNull() throws SQLException { + return false; + } + + @Override + public String getString(int columnIndex) throws SQLException { + Object item = getItem(this.stringList, this.stringCounter); + if (item != null) { + return (String) item; + } else { + return ""; + } + } + + private Object getItem(List list, AtomicInteger counter) { + if (!list.isEmpty()) { + return list.get(counter.getAndIncrement()); + } + return null; + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + Object item = getItem(this.booleanList, this.booleanCounter); + if (item != null) { + return (Boolean) item; + } else { + return false; + } + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + return 0; + } + + @Override + public short getShort(int columnIndex) throws SQLException { + return 0; + } + + @Override + public int getInt(int columnIndex) throws SQLException { + Object item = getItem(this.integerList, this.integerCounter); + if (item != null) { + return (Integer) item; + } else { + return 0; + } + } + + @Override + public long getLong(int columnIndex) throws SQLException { + return 0; + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + return 0; + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + Object item = getItem(this.doubleList, this.doubleCounter); + if (item != null) { + return (Double) item; + } else { + return 0.0; + } + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + return null; + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + return new byte[0]; + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + return null; + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + Object item = getItem(this.timestamps, this.timestampCounter); + if (item != null) { + return (Timestamp) item; + } else { + return new Timestamp(System.currentTimeMillis()); + } + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + return null; + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + return null; + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + return null; + } + + @Override + public String getString(String columnLabel) throws SQLException { + Object item = getItem(this.stringList, this.stringCounter); + if (item != null) { + return (String) item; + } else { + return ""; + } + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + Object item = getItem(this.booleanList, this.booleanCounter); + if (item != null) { + return (Boolean) item; + } else { + return false; + } + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + return 0; + } + + @Override + public short getShort(String columnLabel) throws SQLException { + return 0; + } + + @Override + public int getInt(String columnLabel) throws SQLException { + Object item = getItem(this.integerList, this.integerCounter); + if (item != null) { + return (Integer) item; + } else { + return 0; + } + } + + @Override + public long getLong(String columnLabel) throws SQLException { + return 0; + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + return 0; + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + Object item = getItem(this.doubleList, this.doubleCounter); + if (item != null) { + return (Double) item; + } else { + return 0.0; + } + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + return null; + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + return new byte[0]; + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + return null; + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + return null; + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + Object item = getItem(this.timestamps, this.timestampCounter); + if (item != null) { + return (Timestamp) item; + } else { + return new Timestamp(System.currentTimeMillis()); + } + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + return null; + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + return null; + } + + @Override + public InputStream getBinaryStream(String columnLabel) throws SQLException { + return null; + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return null; + } + + @Override + public void clearWarnings() throws SQLException { + + } + + @Override + public String getCursorName() throws SQLException { + return null; + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + return null; + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + return null; + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + return null; + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + return 0; + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + return null; + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + return null; + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + return null; + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + return null; + } + + @Override + public boolean isBeforeFirst() throws SQLException { + return false; + } + + @Override + public boolean isAfterLast() throws SQLException { + return false; + } + + @Override + public boolean isFirst() throws SQLException { + return false; + } + + @Override + public boolean isLast() throws SQLException { + return false; + } + + @Override + public void beforeFirst() throws SQLException { + + } + + @Override + public void afterLast() throws SQLException { + + } + + @Override + public boolean first() throws SQLException { + return false; + } + + @Override + public boolean last() throws SQLException { + return false; + } + + @Override + public int getRow() throws SQLException { + return 0; + } + + @Override + public boolean absolute(int row) throws SQLException { + return false; + } + + @Override + public boolean relative(int rows) throws SQLException { + return false; + } + + @Override + public boolean previous() throws SQLException { + return false; + } + + @Override + public int getFetchDirection() throws SQLException { + return 0; + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + + } + + @Override + public int getFetchSize() throws SQLException { + return 0; + } + + @Override + public void setFetchSize(int rows) throws SQLException { + + } + + @Override + public int getType() throws SQLException { + return 0; + } + + @Override + public int getConcurrency() throws SQLException { + return 0; + } + + @Override + public boolean rowUpdated() throws SQLException { + return false; + } + + @Override + public boolean rowInserted() throws SQLException { + return false; + } + + @Override + public boolean rowDeleted() throws SQLException { + return false; + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + + } + + @Override + public void insertRow() throws SQLException { + + } + + @Override + public void updateRow() throws SQLException { + + } + + @Override + public void deleteRow() throws SQLException { + + } + + @Override + public void refreshRow() throws SQLException { + + } + + @Override + public void cancelRowUpdates() throws SQLException { + + } + + @Override + public void moveToInsertRow() throws SQLException { + + } + + @Override + public void moveToCurrentRow() throws SQLException { + + } + + @Override + public Statement getStatement() throws SQLException { + return null; + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + return null; + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + return null; + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + return null; + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + return null; + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + return null; + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + return null; + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + return null; + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + return null; + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + return null; + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + return null; + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + return null; + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + return null; + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + return null; + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + Object item = getItem(this.timestamps, this.timestampCounter); + if (item != null) { + return (Timestamp) item; + } else { + return new Timestamp(System.currentTimeMillis()); + } + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + Object item = getItem(this.timestamps, this.timestampCounter); + if (item != null) { + return (Timestamp) item; + } else { + return new Timestamp(System.currentTimeMillis()); + } + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + return null; + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + return null; + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + return null; + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + return null; + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + + } + + @Override + public int getHoldability() throws SQLException { + return 0; + } + + @Override + public boolean isClosed() throws SQLException { + return false; + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + return null; + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + return null; + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + return null; + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + return null; + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + + } + + @Override + public String getNString(int columnIndex) throws SQLException { + return null; + } + + @Override + public String getNString(String columnLabel) throws SQLException { + return null; + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + return null; + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + return null; + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + return null; + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + return null; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + public void addString(String string) { + this.stringList.add(string); + this.hasData = true; + } + + public void addInteger(Integer integer) { + this.integerList.add(integer); + this.hasData = true; + } + + public void addBoolean(Boolean bool) { + this.booleanList.add(bool); + this.hasData = true; + } + + public void addDouble(Double doubleVal) { + this.doubleList.add(doubleVal); + this.hasData = true; + } + + public void addTimestamp(Timestamp timestamp) { + this.timestamps.add(timestamp); + this.hasData = true; + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java new file mode 100644 index 0000000000..c65ea9c476 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java @@ -0,0 +1,562 @@ +/* + * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * + * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. + * + * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://entgra.io/licenses/entgra-commercial/1.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 io.entgra.device.mgt.subtype.mgt.mock; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLWarning; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.PreparedStatement; +import java.sql.ParameterMetaData; +import java.sql.Clob; +import java.sql.Blob; +import java.sql.NClob; +import java.sql.SQLXML; +import java.sql.Ref; +import java.sql.Array; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +/** + * This is the mock statement for the test cases. + */ +public class MockStatement implements PreparedStatement { + private final List resultSets = new ArrayList<>(); + private int resultSetCounter; + + @Override + public ResultSet executeQuery(String sql) throws SQLException { + return this.getMockResultSet(); + } + + private ResultSet getMockResultSet() { + if (!this.resultSets.isEmpty()) { + ResultSet resultSet = this.resultSets.get(this.resultSetCounter); + this.resultSetCounter++; + return resultSet; + } else { + return new MockResultSet(); + } + } + + @Override + public int executeUpdate(String sql) throws SQLException { + return 0; + } + + @Override + public void close() throws SQLException { + + } + + @Override + public int getMaxFieldSize() throws SQLException { + return 0; + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + + } + + @Override + public int getMaxRows() throws SQLException { + return 0; + } + + @Override + public void setMaxRows(int max) throws SQLException { + + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + + } + + @Override + public int getQueryTimeout() throws SQLException { + return 0; + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + + } + + @Override + public void cancel() throws SQLException { + + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return null; + } + + @Override + public void clearWarnings() throws SQLException { + + } + + @Override + public void setCursorName(String name) throws SQLException { + + } + + @Override + public boolean execute(String sql) throws SQLException { + return false; + } + + @Override + public ResultSet getResultSet() throws SQLException { + return getMockResultSet(); + } + + @Override + public int getUpdateCount() throws SQLException { + return 0; + } + + @Override + public boolean getMoreResults() throws SQLException { + return false; + } + + @Override + public int getFetchDirection() throws SQLException { + return 0; + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + + } + + @Override + public int getFetchSize() throws SQLException { + return 0; + } + + @Override + public void setFetchSize(int rows) throws SQLException { + + } + + @Override + public int getResultSetConcurrency() throws SQLException { + return 0; + } + + @Override + public int getResultSetType() throws SQLException { + return 0; + } + + @Override + public void addBatch(String sql) throws SQLException { + + } + + @Override + public void clearBatch() throws SQLException { + + } + + @Override + public int[] executeBatch() throws SQLException { + return new int[0]; + } + + @Override + public Connection getConnection() throws SQLException { + return null; + } + + @Override + public boolean getMoreResults(int current) throws SQLException { + return false; + } + + @Override + public ResultSet getGeneratedKeys() throws SQLException { + return getMockResultSet(); + } + + @Override + public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + return 0; + } + + @Override + public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { + return 0; + } + + @Override + public int executeUpdate(String sql, String[] columnNames) throws SQLException { + return 0; + } + + @Override + public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { + return false; + } + + @Override + public boolean execute(String sql, int[] columnIndexes) throws SQLException { + return false; + } + + @Override + public boolean execute(String sql, String[] columnNames) throws SQLException { + return false; + } + + @Override + public int getResultSetHoldability() throws SQLException { + return 0; + } + + @Override + public boolean isClosed() throws SQLException { + return false; + } + + @Override + public boolean isPoolable() throws SQLException { + return false; + } + + @Override + public void setPoolable(boolean poolable) throws SQLException { + + } + + @Override + public void closeOnCompletion() throws SQLException { + + } + + @Override + public boolean isCloseOnCompletion() throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public ResultSet executeQuery() throws SQLException { + return getMockResultSet(); + } + + @Override + public int executeUpdate() throws SQLException { + return 0; + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + + } + + @Override + public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { + + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + + } + + @Override + public void clearParameters() throws SQLException { + + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + + } + + @Override + public boolean execute() throws SQLException { + return false; + } + + @Override + public void addBatch() throws SQLException { + + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + + } + + @Override + public void setRef(int parameterIndex, Ref x) throws SQLException { + + } + + @Override + public void setBlob(int parameterIndex, Blob x) throws SQLException { + + } + + @Override + public void setClob(int parameterIndex, Clob x) throws SQLException { + + } + + @Override + public void setArray(int parameterIndex, Array x) throws SQLException { + + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + return null; + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + + } + + @Override + public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { + + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + + } + + @Override + public ParameterMetaData getParameterMetaData() throws SQLException { + return null; + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { + + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { + + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { + + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { + + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException { + + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + + } + + public void addResultSet(MockResultSet resultSet) { + this.resultSets.add(resultSet); + } +} diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql new file mode 100644 index 0000000000..52b28e950d --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -0,0 +1,738 @@ +CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( + ID INT AUTO_INCREMENT NOT NULL, + NAME VARCHAR(300) NULL DEFAULT NULL, + DEVICE_TYPE_META VARCHAR(20000) NULL DEFAULT NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, + PROVIDER_TENANT_ID INTEGER DEFAULT 0, + SHARED_WITH_ALL_TENANTS BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( + ID INTEGER auto_increment NOT NULL, + SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, + CERTIFICATE BLOB DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + USERNAME VARCHAR(500) DEFAULT NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_GROUP ( + ID INTEGER AUTO_INCREMENT NOT NULL, + GROUP_NAME VARCHAR(100) DEFAULT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + DESCRIPTION TEXT DEFAULT NULL, + OWNER VARCHAR(255) DEFAULT NULL, + PARENT_PATH VARCHAR(255) DEFAULT '/', + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_ROLE_GROUP_MAP ( + ID INTEGER AUTO_INCREMENT NOT NULL, + GROUP_ID INTEGER DEFAULT NULL, + ROLE VARCHAR(45) DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_ROLE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE ( + ID INTEGER auto_increment NOT NULL, + DESCRIPTION TEXT DEFAULT NULL, + NAME VARCHAR(100) DEFAULT NULL, + DEVICE_TYPE_ID INT(11) DEFAULT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID) + REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_DM_DEVICE UNIQUE (NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( + DEVICE_TYPE_NAME VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, + PROPERTY_NAME VARCHAR(100) DEFAULT 0, + PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, + TENANT_ID VARCHAR(100), + PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS GROUP_PROPERTIES ( + GROUP_ID INTEGER NOT NULL, + PROPERTY_NAME VARCHAR(100) DEFAULT 0, + PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, + TENANT_ID VARCHAR(100), + PRIMARY KEY (GROUP_ID, PROPERTY_NAME, TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( + ID INTEGER AUTO_INCREMENT NOT NULL, + DEVICE_ID INTEGER DEFAULT NULL, + GROUP_ID INTEGER DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_DEVICE2 FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE IF NOT EXISTS DM_OPERATION ( + ID INTEGER AUTO_INCREMENT NOT NULL, + TYPE VARCHAR(50) NOT NULL, + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + RECEIVED_TIMESTAMP TIMESTAMP NULL, + OPERATION_CODE VARCHAR(1000) NOT NULL, + INITIATED_BY VARCHAR(100) NULL, + OPERATION_DETAILS BLOB DEFAULT NULL, + ENABLED BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( + ID INTEGER AUTO_INCREMENT NOT NULL, + DEVICE_ID INTEGER NOT NULL, + OWNER VARCHAR(255) NOT NULL, + OWNERSHIP VARCHAR(45) DEFAULT NULL, + STATUS VARCHAR(50) NULL, + IS_TRANSFERRED BOOLEAN NOT NULL DEFAULT FALSE, + DATE_OF_ENROLMENT TIMESTAMP DEFAULT NULL, + DATE_OF_LAST_UPDATE TIMESTAMP DEFAULT NULL, + TENANT_ID INT NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) +); + +CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NOT NULL, + STATUS VARCHAR(50) NULL, + PUSH_NOTIFICATION_STATUS VARCHAR(50) NULL, + CREATED_TIMESTAMP INT NOT NULL, + UPDATED_TIMESTAMP INT NOT NULL, + OPERATION_CODE VARCHAR(50) NOT NULL, + INITIATED_BY VARCHAR(100) NULL, + TYPE VARCHAR(20) NOT NULL, + DEVICE_ID INTEGER DEFAULT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_operation_mapping_device FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_operation_mapping_operation FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NOT NULL, + EN_OP_MAP_ID INTEGER NOT NULL, + OPERATION_RESPONSE VARCHAR(1024) DEFAULT NULL , + IS_LARGE_RESPONSE BOOLEAN NOT NULL DEFAULT FALSE, + RECEIVED_TIMESTAMP TIMESTAMP NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_operation_response_enrollment FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_operation_response_operation FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_en_op_map_response FOREIGN KEY (EN_OP_MAP_ID) REFERENCES + DM_ENROLMENT_OP_MAPPING (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE DM_DEVICE_OPERATION_RESPONSE_LARGE ( + ID INTEGER NOT NULL, + OPERATION_RESPONSE LONGBLOB DEFAULT NULL, + OPERATION_ID INTEGER NOT NULL, + EN_OP_MAP_ID INTEGER NOT NULL, + RECEIVED_TIMESTAMP TIMESTAMP NULL, + DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, + CONSTRAINT fk_dm_device_operation_response_large_mapping FOREIGN KEY (ID) + REFERENCES DM_DEVICE_OPERATION_RESPONSE (ID) + ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_en_op_map_response_large FOREIGN KEY (EN_OP_MAP_ID) + REFERENCES DM_ENROLMENT_OP_MAPPING (ID) + ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- POLICY RELATED TABLES -- + +CREATE TABLE IF NOT EXISTS DM_PROFILE ( + ID INT NOT NULL AUTO_INCREMENT , + PROFILE_NAME VARCHAR(45) NOT NULL , + TENANT_ID INT NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , + CREATED_TIME DATETIME NOT NULL , + UPDATED_TIME DATETIME NOT NULL , + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_POLICY ( + ID INT(11) NOT NULL AUTO_INCREMENT , + NAME VARCHAR(45) DEFAULT NULL , + DESCRIPTION VARCHAR(1000) NULL, + PAYLOAD_VERSION VARCHAR (45) NULL, + TENANT_ID INT(11) NOT NULL , + PROFILE_ID INT(11) NOT NULL , + OWNERSHIP_TYPE VARCHAR(45) NULL, + COMPLIANCE VARCHAR(100) NULL, + PRIORITY INT NOT NULL, + ACTIVE INT(2) NOT NULL, + UPDATED INT(1) NULL, + POLICY_TYPE VARCHAR(45) NULL, + PRIMARY KEY (ID) , + CONSTRAINT FK_DM_PROFILE_DM_POLICY + FOREIGN KEY (PROFILE_ID ) + REFERENCES DM_PROFILE (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( + ID INT(11) NOT NULL AUTO_INCREMENT , + DEVICE_ID INT(11) NOT NULL , + ENROLMENT_ID INT(11) NOT NULL, + DEVICE BLOB NOT NULL, + POLICY_ID INT(11) NOT NULL , + PRIMARY KEY (ID) , + CONSTRAINT FK_POLICY_DEVICE_POLICY + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT FK_DEVICE_DEVICE_POLICY + FOREIGN KEY (DEVICE_ID ) + REFERENCES DM_DEVICE (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( + ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , + POLICY_ID INT(11) NOT NULL , + PRIMARY KEY (ID) , + CONSTRAINT FK_DEVICE_TYPE_POLICY + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( + ID INT(11) NOT NULL AUTO_INCREMENT, + PROFILE_ID INT(11) NOT NULL, + FEATURE_CODE VARCHAR(100) NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + TENANT_ID INT(11) NOT NULL , + CONTENT BLOB NULL DEFAULT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES + FOREIGN KEY (PROFILE_ID) + REFERENCES DM_PROFILE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, + POLICY_ID INT(11) NOT NULL, + FEATURE_ID INT(11) DEFAULT NULL, + IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( + ID INT(11) NOT NULL AUTO_INCREMENT , + ROLE_NAME VARCHAR(45) NOT NULL , + POLICY_ID INT(11) NOT NULL , + PRIMARY KEY (ID) , + CONSTRAINT FK_ROLE_POLICY_POLICY + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( + ID INT NOT NULL AUTO_INCREMENT , + POLICY_ID INT NOT NULL , + USERNAME VARCHAR(45) NOT NULL , + PRIMARY KEY (ID) , + CONSTRAINT DM_POLICY_USER_POLICY + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT(11) NOT NULL, + POLICY_ID INT NOT NULL , + POLICY_CONTENT BLOB NULL , + TENANT_ID INT NOT NULL, + APPLIED TINYINT(1) NULL , + CREATED_TIME TIMESTAMP NULL , + UPDATED_TIME TIMESTAMP NULL , + APPLIED_TIME TIMESTAMP NULL , + PRIMARY KEY (ID) , + CONSTRAINT FK_DM_POLICY_DEVCIE_APPLIED + FOREIGN KEY (DEVICE_ID ) + REFERENCES DM_DEVICE (ID ) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_CRITERIA ( + ID INT NOT NULL AUTO_INCREMENT, + TENANT_ID INT NOT NULL, + NAME VARCHAR(50) NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA ( + ID INT NOT NULL AUTO_INCREMENT, + CRITERIA_ID INT NOT NULL, + POLICY_ID INT NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_CRITERIA_POLICY_CRITERIA + FOREIGN KEY (CRITERIA_ID) + REFERENCES DM_CRITERIA (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT FK_POLICY_POLICY_CRITERIA + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( + ID INT NOT NULL AUTO_INCREMENT, + POLICY_CRITERION_ID INT NOT NULL, + PROP_KEY VARCHAR(45) NULL, + PROP_VALUE VARCHAR(100) NULL, + CONTENT BLOB NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES + FOREIGN KEY (POLICY_CRITERION_ID) + REFERENCES DM_POLICY_CRITERIA (ID) + ON DELETE CASCADE + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, + POLICY_ID INT NOT NULL, + TENANT_ID INT NOT NULL, + STATUS INT NULL, + LAST_SUCCESS_TIME TIMESTAMP NULL, + LAST_REQUESTED_TIME TIMESTAMP NULL, + LAST_FAILED_TIME TIMESTAMP NULL, + ATTEMPTS INT NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( + ID INT NOT NULL AUTO_INCREMENT, + POLICY_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , + TENANT_ID INT(11) NOT NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( + ID INT NOT NULL AUTO_INCREMENT, + COMPLIANCE_STATUS_ID INT NOT NULL, + TENANT_ID INT NOT NULL, + FEATURE_CODE VARCHAR(100) NOT NULL, + STATUS INT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_COMPLIANCE_FEATURES_STATUS + FOREIGN KEY (COMPLIANCE_STATUS_ID) + REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS DM_APPLICATION ( + ID INTEGER AUTO_INCREMENT NOT NULL, + NAME VARCHAR(150) NOT NULL, + APP_IDENTIFIER VARCHAR(150) NOT NULL, + PLATFORM VARCHAR(50) DEFAULT NULL, + CATEGORY VARCHAR(50) NULL, + VERSION VARCHAR(50) NULL, + TYPE VARCHAR(50) NULL, + LOCATION_URL VARCHAR(100) DEFAULT NULL, + IMAGE_URL VARCHAR(100) DEFAULT NULL, + APP_PROPERTIES BLOB NULL, + MEMORY_USAGE INTEGER(10) NULL, + IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, + DEVICE_ID INTEGER NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device + FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT fk_dm_enrolement + FOREIGN KEY (ENROLMENT_ID) + REFERENCES DM_ENROLMENT (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +-- POLICY RELATED TABLES FINISHED -- + +-- NOTIFICATION TABLE -- +CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( + NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, + DEVICE_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, + TENANT_ID INTEGER NOT NULL, + STATUS VARCHAR(10) NULL, + DESCRIPTION VARCHAR(1000) NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, + PRIMARY KEY (NOTIFICATION_ID), + CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); +-- NOTIFICATION TABLE END -- + +CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( + ID INTEGER AUTO_INCREMENT NOT NULL, + DEVICE_ID INT NULL, + ENROLMENT_ID INT NOT NULL, + KEY_FIELD VARCHAR(45) NULL, + VALUE_FIELD VARCHAR(1000) NULL, + PRIMARY KEY (ID), + CONSTRAINT DM_DEVICE_INFO_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT DM_DEVICE_INFO_DEVICE_ENROLLMENT + FOREIGN KEY (ENROLMENT_ID) + REFERENCES DM_ENROLMENT (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE INDEX IDX_DM_DEVICE_INFO_DID_EID_KFIELD ON DM_DEVICE_INFO(DEVICE_ID, ENROLMENT_ID, KEY_FIELD); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( + ID INTEGER AUTO_INCREMENT NOT NULL, + DEVICE_ID INT NULL, + ENROLMENT_ID INT NOT NULL, + LATITUDE DOUBLE NULL, + LONGITUDE DOUBLE NULL, + STREET1 VARCHAR(255) NULL, + STREET2 VARCHAR(45) NULL, + CITY VARCHAR(45) NULL, + ZIP VARCHAR(10) NULL, + STATE VARCHAR(45) NULL, + COUNTRY VARCHAR(45) NULL, + GEO_HASH VARCHAR(45) NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + ALTITUDE DOUBLE NULL, + SPEED FLOAT NULL, + BEARING FLOAT NULL, + DISTANCE DOUBLE NULL, + PRIMARY KEY (ID), + CONSTRAINT DM_DEVICE_LOCATION_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT DM_DEVICE_LOCATION_DM_ENROLLMENT + FOREIGN KEY (ENROLMENT_ID) + REFERENCES DM_ENROLMENT (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); +CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_ID INT NOT NULL, + ENROLMENT_ID INT NOT NULL, + DEVICE_MODEL VARCHAR(45) NULL, + VENDOR VARCHAR(45) NULL, + OS_VERSION VARCHAR(45) NULL, + OS_BUILD_DATE VARCHAR(100) NULL, + BATTERY_LEVEL DECIMAL(4) NULL, + INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL, + INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL, + EXTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL, + EXTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL, + CONNECTION_TYPE VARCHAR(50) NULL, + SSID VARCHAR(45) NULL, + CPU_USAGE DECIMAL(5) NULL, + TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, + AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, + PLUGGED_IN INT(1) NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS + FOREIGN KEY (ENROLMENT_ID) + REFERENCES DM_ENROLMENT (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE INDEX IDX_DM_DEVICE_DETAIL_DID_EID ON DM_DEVICE_DETAIL(DEVICE_ID, ENROLMENT_ID); + +CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS +( + ID INTEGER AUTO_INCREMENT NOT NULL, + DEVICE_ID INT NOT NULL, + DEVICE_ID_NAME VARCHAR(255) NOT NULL, + TENANT_ID INT NOT NULL, + DEVICE_TYPE_NAME VARCHAR(45) NOT NULL, + LATITUDE DOUBLE NULL, + LONGITUDE DOUBLE NULL, + SPEED FLOAT NULL, + HEADING FLOAT NULL, + TIMESTAMP BIGINT(15) NOT NULL, + GEO_HASH VARCHAR(45) NULL, + DEVICE_OWNER VARCHAR(45) NULL, + DEVICE_ALTITUDE DOUBLE NULL, + DISTANCE DOUBLE NULL, + PRIMARY KEY (ID) +); + +-- POLICY AND DEVICE GROUP MAPPING -- +CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_GROUP_ID INT NOT NULL, + POLICY_ID INT NOT NULL, + TENANT_ID INT NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_DEVICE_GROUP_POLICY + FOREIGN KEY (DEVICE_GROUP_ID) + REFERENCES DM_GROUP (ID) + ON DELETE CASCADE + ON UPDATE CASCADE , + CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE CASCADE + ON UPDATE CASCADE +); +-- END OF POLICY AND DEVICE GROUP MAPPING -- + + +CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_PLATFORM ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_TYPE_ID INT NULL DEFAULT 0, + VERSION_NAME VARCHAR(100) NULL, + VERSION_STATUS VARCHAR(100) NULL DEFAULT 'ACTIVE', + PRIMARY KEY (ID), + CONSTRAINT DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING + FOREIGN KEY (DEVICE_TYPE_ID) + REFERENCES DM_DEVICE_TYPE (ID) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT device_type_version_uk + UNIQUE ( + DEVICE_TYPE_ID, + VERSION_NAME + ) +); + +-- METADATA TABLE -- +CREATE TABLE IF NOT EXISTS DM_METADATA ( + METADATA_ID INT AUTO_INCREMENT NOT NULL, + DATA_TYPE VARCHAR(16) NOT NULL, + METADATA_KEY VARCHAR(128) NOT NULL, + METADATA_VALUE VARCHAR(8000) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (METADATA_ID), + CONSTRAINT METADATA_KEY_TENANT_ID UNIQUE (METADATA_KEY, TENANT_ID) +); +-- END OF METADATA TABLE -- + +-- DM_OTP_DATA TABLE -- +CREATE TABLE IF NOT EXISTS DM_OTP_DATA ( + ID INT AUTO_INCREMENT NOT NULL, + OTP_TOKEN VARCHAR(100) NOT NULL, + TENANT_ID INT NOT NULL, + USERNAME VARCHAR(500) DEFAULT NOT NULL, + EMAIL VARCHAR(100) NOT NULL, + EMAIL_TYPE VARCHAR(20) NOT NULL, + META_INFO VARCHAR(20000) NOT NULL, + CREATED_AT TIMESTAMP NOT NULL, + EXPIRY_TIME INT NOT NULL DEFAULT 3600, + IS_EXPIRED BOOLEAN DEFAULT false, + PRIMARY KEY (ID), + CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) +); +-- END OF DM_OTP_DATA TABLE -- + +-- DASHBOARD RELATED VIEWS -- +CREATE VIEW POLICY_COMPLIANCE_INFO AS +SELECT +DEVICE_INFO.DEVICE_ID, +DEVICE_INFO.DEVICE_IDENTIFICATION, +DEVICE_INFO.PLATFORM, +DEVICE_INFO.OWNERSHIP, +DEVICE_INFO.CONNECTIVITY_STATUS, +IFNULL(DEVICE_WITH_POLICY_INFO.POLICY_ID, -1) AS POLICY_ID, +IFNULL(DEVICE_WITH_POLICY_INFO.IS_COMPLIANT, -1) AS IS_COMPLIANT, +DEVICE_INFO.TENANT_ID +FROM +(SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_DEVICE.TENANT_ID +FROM DM_DEVICE, DM_DEVICE_TYPE, DM_ENROLMENT +WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID) DEVICE_INFO +LEFT JOIN +(SELECT +DEVICE_ID, +POLICY_ID, +STATUS AS IS_COMPLIANT +FROM DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO +ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID +ORDER BY DEVICE_INFO.DEVICE_ID; + +CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS +SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, +DM_DEVICE_DETAIL.DEVICE_MODEL, +DM_DEVICE_DETAIL.VENDOR, +DM_DEVICE_DETAIL.OS_VERSION, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.OWNER, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_POLICY_COMPLIANCE_STATUS.POLICY_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_POLICY_COMPLIANCE_FEATURES.FEATURE_CODE, +DM_POLICY_COMPLIANCE_FEATURES.STATUS AS IS_COMPLAINT, +DM_DEVICE.TENANT_ID +FROM +DM_POLICY_COMPLIANCE_FEATURES, DM_POLICY_COMPLIANCE_STATUS, DM_ENROLMENT, DM_DEVICE, DM_DEVICE_TYPE, DM_DEVICE_DETAIL +WHERE +DM_POLICY_COMPLIANCE_FEATURES.COMPLIANCE_STATUS_ID = DM_POLICY_COMPLIANCE_STATUS.ID AND +DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = DM_ENROLMENT.ID AND +DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND +DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND +DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID +ORDER BY TENANT_ID, DEVICE_ID; + +-- END OF DASHBOARD RELATED VIEWS -- + +-- DM_GEOFENCE TABLE-- + +CREATE TABLE IF NOT EXISTS DM_GEOFENCE ( + ID INT NOT NULL AUTO_INCREMENT, + FENCE_NAME VARCHAR(255) NOT NULL, + DESCRIPTION TEXT DEFAULT NULL, + LATITUDE DOUBLE DEFAULT NULL, + LONGITUDE DOUBLE DEFAULT NULL, + RADIUS DOUBLE DEFAULT NULL, + GEO_JSON TEXT DEFAULT NULL, + FENCE_SHAPE VARCHAR(100) DEFAULT NULL, + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + OWNER VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); + +-- END OF DM_GEOFENCE TABLE-- + +-- DM_GEOFENCE_GROUP_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_GEOFENCE_GROUP_MAPPING ( + ID INT NOT NULL AUTO_INCREMENT, + FENCE_ID INT NOT NULL, + GROUP_ID INT NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_geofence_group_mapping_geofence FOREIGN KEY (FENCE_ID) REFERENCES + DM_GEOFENCE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_geofence_group_mapping_group FOREIGN KEY (GROUP_ID) REFERENCES + DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- END OF DM_GEOFENCE_GROUP_MAPPING TABLE-- + +-- DM_DEVICE_EVENT TABLE -- + +CREATE TABLE IF NOT EXISTS DM_DEVICE_EVENT ( + ID INT NOT NULL AUTO_INCREMENT, + EVENT_SOURCE VARCHAR(100) NOT NULL, + EVENT_LOGIC VARCHAR(100) NOT NULL, + ACTIONS TEXT DEFAULT NULL, + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); + +-- END OF DM_DEVICE_EVENT TABLE -- + +-- DM_DEVICE_EVENT_GROUP_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_DEVICE_EVENT_GROUP_MAPPING ( + ID INT NOT NULL AUTO_INCREMENT, + EVENT_ID INT NOT NULL, + GROUP_ID INT NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_event_group_mapping_event FOREIGN KEY (EVENT_ID) REFERENCES + DM_DEVICE_EVENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_event_group_mapping_group FOREIGN KEY (GROUP_ID) REFERENCES + DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- END OF DM_DEVICE_EVENT_GROUP_MAPPING TABLE-- + +-- DM_GEOFENCE_GROUP_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_GEOFENCE_EVENT_MAPPING ( + ID INT NOT NULL AUTO_INCREMENT, + FENCE_ID INT NOT NULL, + EVENT_ID INT NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_geofence_event_mapping_geofence FOREIGN KEY (FENCE_ID) REFERENCES + DM_GEOFENCE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_geofence_event_mapping_event FOREIGN KEY (EVENT_ID) REFERENCES + DM_DEVICE_EVENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- END OF DM_GEOFENCE_GROUP_MAPPING TABLE-- + +-- DM_DEVICE_SUB_TYPE TABLE-- +CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( + TENANT_ID INT DEFAULT 0, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + SUB_TYPE_NAME VARCHAR(45) NOT NULL, + TYPE_DEFINITION TEXT NOT NULL, + PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) +); + +-- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql new file mode 100644 index 0000000000..0d00a78a22 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql @@ -0,0 +1,415 @@ +-- ----------------------------------------------------- +-- Table `POWER_METER_DEVICE` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `POWER_METER_DEVICE` ( + `ID` INTEGER AUTO_INCREMENT NOT NULL, + `SERIAL` VARCHAR(45) NOT NULL, + `IP_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, + `SIM_NUMBER` VARCHAR(45) NULL DEFAULT NULL, + `SUB_TYPE_ID` INT NOT NULL, + `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, + `NODE_TYPE` VARCHAR(45) NULL DEFAULT NULL, + `CATEGORY` VARCHAR(45) NULL DEFAULT NULL, + `BRANCH` VARCHAR(45) NULL DEFAULT NULL, + `DEPOT` VARCHAR(45) NULL DEFAULT NULL, + `SUBSTATION_ID` VARCHAR(45) NULL DEFAULT NULL, + `HAS_EXPORT` VARCHAR(5) NULL DEFAULT NULL, + `COM_MODULE_IMEI` VARCHAR(45) NULL DEFAULT NULL, + `HAS_E_BILLING` VARCHAR(5) NULL DEFAULT NULL, + `IS_FEEDER_END` VARCHAR(5) NULL DEFAULT NULL, + `POLE_ID` VARCHAR(45) NULL DEFAULT NULL, + `METER_FW_VER` VARCHAR(45) NULL DEFAULT NULL, + `ASSIGNED_ON` TIMESTAMP NULL DEFAULT NULL, + PRIMARY KEY (`ID`, `SERIAL`)); + +-- ----------------------------------------------------- +-- Table `COMMUNICATION_MODULE` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `COMMUNICATION_MODULE` ( + `IMEI` VARCHAR(45) NOT NULL, + `SIM_IMSI` VARCHAR(45) NULL DEFAULT NULL, + `FW_VERSION` INT NULL DEFAULT 0, + `SUB_TYPE_ID` INT NOT NULL, + `SMS_PIN` VARCHAR(45) NULL DEFAULT NULL, + `BRANCH` VARCHAR(45) NULL DEFAULT NULL, + PRIMARY KEY (`IMEI`)); + +-- ----------------------------------------------------- +-- Table `METER_AUTHENTICATION_INFO` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `METER_AUTHENTICATION_INFO` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `CLIENT_ADDRESS` INT NOT NULL, + `AUTHENTICATION` VARCHAR(100) NOT NULL, + `USER_ID` INT NOT NULL, + `PASSWORD` VARCHAR(100) NOT NULL, + `METER_SERIAL_ID` VARCHAR(45) NOT NULL, + PRIMARY KEY (`ID`)); + +CREATE INDEX IDX_METER_AUTHENTICATION_INFO +ON METER_AUTHENTICATION_INFO(CLIENT_ADDRESS, METER_SERIAL_ID); + +-- ----------------------------------------------------- +-- Table `METER_READINGS` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `METER_READINGS` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `OPERATION_ID` INT NOT NULL, + `OPERATION_CODE` VARCHAR(45) NOT NULL, + `SUB_TYPE_ID` INT NOT NULL, + `NODE_TYPE` VARCHAR(45) NULL DEFAULT NULL, + `CATEGORY` VARCHAR(45) NULL DEFAULT NULL, + `HAS_EXPORT` BOOLEAN NULL DEFAULT NULL, + `HAS_E_BILLING` BOOLEAN NULL DEFAULT NULL, + `BRANCH` VARCHAR(45) NULL DEFAULT NULL, + `DEPOT` VARCHAR(45) NULL DEFAULT NULL, + `SUBSTATION_ID` VARCHAR(45) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NOT NULL, + `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, + `RESPONSE` BLOB NOT NULL, + `TIMESTAMP` BIGINT(15) NOT NULL, + `IS_PARTIAL_RESULT` BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (`ID`)); + +-- +-- Table structure for table `LAST_METER_READING` +-- +CREATE TABLE IF NOT EXISTS LAST_METER_READING ( + SERIAL VARCHAR(45) NOT NULL, + OPERATION_ID INTEGER NOT NULL, + SUB_TYPE_ID INT NOT NULL DEFAULT 0, + NODE_TYPE VARCHAR(45) NULL DEFAULT NULL, + CATEGORY VARCHAR(45) NULL DEFAULT NULL, + HAS_EXPORT BOOLEAN NULL DEFAULT NULL, + HAS_E_BILLING BOOLEAN NULL DEFAULT NULL, + BRANCH VARCHAR(45) NULL DEFAULT NULL, + DEPOT VARCHAR(45) NULL DEFAULT NULL, + SUBSTATION_ID VARCHAR(45) NULL DEFAULT NULL, + CUSTOMER_REF VARCHAR(45) NULL DEFAULT NULL, + RESPONSE LONGBLOB NOT NULL, + LAST_READING_TIMESTAMP BIGINT NOT NULL, + PRIMARY KEY (SERIAL) +); + +-- ----------------------------------------------------- +-- Table `PROFILE_READINGS` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `PROFILE_READINGS` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `OPERATION_ID` INT NOT NULL, + `OBIS` VARCHAR(45) NULL DEFAULT NULL, + `SUB_TYPE_ID` INT NOT NULL, + `NODE_TYPE` VARCHAR(45) NULL DEFAULT NULL, + `CATEGORY` VARCHAR(45) NULL DEFAULT NULL, + `HAS_EXPORT` BOOLEAN NULL DEFAULT NULL, + `HAS_E_BILLING` BOOLEAN NULL DEFAULT NULL, + `BRANCH` VARCHAR(45) NULL DEFAULT NULL, + `DEPOT` VARCHAR(45) NULL DEFAULT NULL, + `SUBSTATION_ID` VARCHAR(45) NULL DEFAULT NULL, + `SERIAL` VARCHAR(45) NOT NULL, + `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, + `PROFILE_DATA` BLOB NOT NULL, + `TIMESTAMP` BIGINT(15) NOT NULL, + PRIMARY KEY (`ID`)); + +-- ----------------------------------------------------- +-- Table `METER_INSTALL` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `METER_INSTALL` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `SERIAL` VARCHAR(45) NOT NULL, + `USERNAME` VARCHAR(45) NULL DEFAULT NULL, + `JOB_ID` VARCHAR(45) NULL DEFAULT NULL, + `LAB_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `COM_MODULE_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `TERMINAL_COVER_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `METER_ENCLOSURE_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `PRINTED_SERIAL` VARCHAR(45) NULL DEFAULT NULL, + `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, + `IMPORT_READING` DOUBLE DEFAULT 0, + `EXPORT_READING` DOUBLE DEFAULT 0, + `READING_TIMESTAMP` BIGINT(15) DEFAULT 0, + `TIMESTAMP` TIMESTAMP NOT NULL, + PRIMARY KEY (`ID`)); + +-- ----------------------------------------------------- +-- Table `METER_UNINSTALL` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `METER_UNINSTALL` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `SERIAL` VARCHAR(45) NOT NULL, + `USERNAME` VARCHAR(45) NULL DEFAULT NULL, + `JOB_ID` VARCHAR(45) NULL DEFAULT NULL, + `LAB_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `COM_MODULE_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `TERMINAL_COVER_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `METER_ENCLOSURE_SEAL` VARCHAR(45) NULL DEFAULT NULL, + `PRINTED_SERIAL` VARCHAR(45) NULL DEFAULT NULL, + `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, + `IMPORT_READING` DOUBLE DEFAULT 0, + `EXPORT_READING` DOUBLE DEFAULT 0, + `READING_TIMESTAMP` BIGINT(15) DEFAULT 0, + `TIMESTAMP` TIMESTAMP NOT NULL, + PRIMARY KEY (`ID`)); + +-- ----------------------------------------------------- +-- Table `RSSI_LEVEL` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `RSSI_LEVEL` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `IMEI` VARCHAR(45) NOT NULL, + `SIM_IMSI` VARCHAR(45) NULL DEFAULT NULL, + `FW_VERSION` INT NULL DEFAULT 0, + `COM_TYPE_ID` INT NOT NULL, + `RSSI` INT NULL DEFAULT 0, + `NETWORK` VARCHAR(45) NULL DEFAULT NULL, + `CELL_ID` VARCHAR(45) NULL DEFAULT NULL, + `LAC` VARCHAR(45) NULL DEFAULT NULL, + `RSRP` DECIMAL (5, 2) NULL DEFAULT 0, + `RSRQ` DECIMAL (5, 2) NULL DEFAULT 0, + `SNR` DECIMAL (5, 2) NULL DEFAULT 0, + `PCI` INT NULL DEFAULT 0, + `TRANSPORT` VARCHAR(45) NULL DEFAULT NULL, + `TIMESTAMP` BIGINT(15) NOT NULL, + PRIMARY KEY (`ID`)); + +-- ----------------------------------------------------- +-- Table `REQUEST` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `REQUEST` ( + `ID` int NOT NULL AUTO_INCREMENT, + `DUE_DATE` bigint DEFAULT '0', + `REQUESTED_BY` varchar(100) NOT NULL, + `REQUESTED_DATE` bigint DEFAULT '0', + `STATUS` varchar(45) NOT NULL, + `BRANCH` varchar(45) DEFAULT NULL, + `REMARKS` varchar(255) NOT NULL, + `REQUEST_TYPE` int NOT NULL, + PRIMARY KEY (`ID`) +) ; + +-- ----------------------------------------------------- +-- Table `METER_ASSIGNMENT_REQUEST` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `METER_ASSIGNMENT_REQUEST` ( + `ID` int NOT NULL, + `SUB_TYPE_ID` int NOT NULL, + `PRIMARY_CT_RATIO` float DEFAULT '0', + `SECONDARY_CT_RATIO` float DEFAULT '0', + `PRIMARY_PT_RATIO` float DEFAULT '0', + `SECONDARY_PT_RATIO` float DEFAULT '0', + `NODE_TYPE` varchar(45) DEFAULT NULL, + `REQUESTED_COUNT` int NOT NULL, + `ACCEPTED_COUNT` int DEFAULT NULL, + `ASSIGNED_COUNT` int DEFAULT NULL, + `SUBSTATION_ID` varchar(45) DEFAULT NULL, + `CUSTOMER_REF` varchar(45) DEFAULT NULL, + `DEPOT` VARCHAR(45) DEFAULT NULL, + `PURPOSE` VARCHAR(50) DEFAULT NULL, + `ADDRESS` VARCHAR(255) DEFAULT NULL, + `DESCRIPTION` VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_ASSIGNMENT_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) +) ; + +-- ----------------------------------------------------- +-- Table `DISCONNECTION_REQUEST` +-- ------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `DISCONNECTION_REQUEST` ( + `ID` int NOT NULL, + `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_DISCONNECTION_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) +) ; + +-- ----------------------------------------------------- +-- Table `FIELD_TEST_REQUEST` +-- ------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `FIELD_TEST_REQUEST` ( + `ID` int NOT NULL, + `TEAM` varchar(255) DEFAULT NULL, + `SCHEDULED_DATE` bigint DEFAULT '0', + `RESULT` varchar(50) DEFAULT NULL, + `ATTACHMENT` blob, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_ASSIGNMENT_FIELD_TEST_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) +); + +-- ----------------------------------------------------- +-- Table `LOAD_PROFILE_REQUEST` +-- ------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `LOAD_PROFILE_REQUEST` ( + `ID` int NOT NULL, + `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, + `START_DATE` bigint DEFAULT '0', + `END_DATE` bigint DEFAULT '0', + PRIMARY KEY (`ID`), + CONSTRAINT `fk_LOAD_PROFILE_REQUEST_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) +); + +-- ----------------------------------------------------- +-- Table `READOUT_REQUEST` +-- ------------------------------------------------------- + +CREATE TABLE `READOUT_REQUEST` ( + `ID` int NOT NULL, + `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_READUOT_REQUEST_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) +); + +-- ----------------------------------------------------- +-- Table `COM_MODULE_REQUEST` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `COM_MODULE_REQUEST` ( + `ID` INT NOT NULL, + `MODULE_TYPE` VARCHAR(45) NOT NULL, + `REQUESTED_COUNT` INT NOT NULL, + `ACCEPTED_COUNT` INT DEFAULT NULL, + `ASSIGNED_COUNT` INT DEFAULT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_COM_MODULE_REQUEST_REQUEST` FOREIGN KEY (`ID`) + REFERENCES `REQUEST` (`ID`) +); + +-- ----------------------------------------------------- +-- Table `RECONNECTION_REQUEST` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `RECONNECTION_REQUEST` ( + `ID` int NOT NULL, + `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_RECONNECTION_REQUEST_REQUEST` FOREIGN KEY (`ID`) + REFERENCES `REQUEST` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION +); + + +----------------------------------------------------- +-- Table `REQUEST_LIFECYCLE_EVENT` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `REQUEST_LIFECYCLE_EVENT` ( + `ID` int NOT NULL AUTO_INCREMENT, + `REQUEST_ID` int NOT NULL, + `UPDATED_BY` varchar(100) NOT NULL, + `UPDATED_DATE` bigint DEFAULT '0', + `STATUS` varchar(45) NOT NULL, + `REMARKS` varchar(200) DEFAULT NULL, + PRIMARY KEY (`ID`), + CONSTRAINT `fk_REQUEST_LIFECYCLE_EVENT_REQUEST` FOREIGN KEY (`REQUEST_ID`) REFERENCES `REQUEST` (`ID`) +) ; + + +-- ----------------------------------------------------- +-- Table `DEVICE_EVENTS` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `PROCESSED_DEVICE_EVENTS` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `METER_SERIAL` VARCHAR(45), + `IP_ADDRESS` VARCHAR(45), + `NUMBER` VARCHAR(45), + `TYPE` VARCHAR(45) NOT NULL, + `KEY` VARCHAR(100) NOT NULL, + `VALUE` VARCHAR(100) NOT NULL, + `EVENT` VARCHAR(45) NOT NULL, + `TIMESTAMP` BIGINT(15) DEFAULT 0, + PRIMARY KEY (`ID`)); + + -- ----------------------------------------------------- + -- Table `DM_DEVICE_SUB_TYPE` + -- ----------------------------------------------------- + + CREATE TABLE IF NOT EXISTS `DM_DEVICE_SUB_TYPE` ( + `TENANT_ID` INT DEFAULT 0, + `SUB_TYPE_ID` INT NOT NULL, + `DEVICE_TYPE` VARCHAR(25) NOT NULL, + `SUB_TYPE_NAME` VARCHAR(45) NOT NULL, + `TYPE_DEFINITION` TEXT NOT NULL, + PRIMARY KEY (`SUB_TYPE_ID`,`DEVICE_TYPE`) + ); + + -- ----------------------------------------------------- +-- Table `OPERATION_TEMPLATE` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `OPERATION_TEMPLATE`( + `TEMPLATE_ID` INT NOT NULL AUTO_INCREMENT, + `SUB_TYPE_ID` INT NOT NULL, + `OPERATION_CODE` VARCHAR(100) NOT NULL, + `OPERATION_DEFINITION` TEXT DEFAULT NULL, + PRIMARY KEY (`TEMPLATE_ID`) +); + +-- ----------------------------------------------------- +-- Table `GENERIC_METER_REGISTER` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `GENERIC_METER_REGISTER`( + `RRPK_ID` VARCHAR(100) NOT NULL, + `DESCRIPTION` VARCHAR(100) NOT NULL, + `UNIT` VARCHAR(45) NULL DEFAULT NULL, + `ORDER` INT NOT NULL, + PRIMARY KEY (`RRPK_ID`) +); + + + +-- ----------------------------------------------------- +-- Sample data for DAO test cases +-- ----------------------------------------------------- +INSERT INTO DM_DEVICE_TYPE(NAME, DEVICE_TYPE_META, LAST_UPDATED_TIMESTAMP, PROVIDER_TENANT_ID, SHARED_WITH_ALL_TENANTS) VALUES +('android','NULL','2020-10-14 16:05:15',-1234,1),('power-meter','NULL','2020-10-14 16:05:15',-1234,1), +('communication-module','NULL','2020-10-14 16:05:15',-1234,1),('sim','NULL','2020-10-14 16:05:15',-1234,1); +INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, LAST_UPDATED_TIMESTAMP, TENANT_ID) VALUES +('+94713192111', '192.168.118.111', 4, '413012689159555', '2022-04-04 16:55:52', '-1234'), +('NULL', '864495036647555', 3, '864495036647555', '2022-04-04 16:56:52', '-1234'), +('NULL', '000019729555', 2, '000019729555', '2022-04-04 16:56:52', '-1234'); + +INSERT INTO DM_ENROLMENT(DEVICE_ID,OWNER,OWNERSHIP,STATUS,IS_TRANSFERRED,DATE_OF_ENROLMENT,DATE_OF_LAST_UPDATE,TENANT_ID) VALUES +(1,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234), +(2,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234), +(3,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234); +INSERT INTO DM_DEVICE_PROPERTIES (DEVICE_TYPE_NAME,DEVICE_IDENTIFICATION,PROPERTY_NAME,PROPERTY_VALUE,TENANT_ID) VALUES +('sim','413012689159555','APN','LECOSMSTC',-1234), +('sim','413012689159555','IP_ADDRESS','192.168.118.111',-1234), +('sim','413012689159555','MOBILE_NO','+94713192111',-1234), +('sim','413012689159555','SUB_TYPE_ID','1',-1234), +('sim','413012689159555','token',NULL,-1234), +('communication-module','864495036647555','BRANCH','KOTTE',-1234), +('communication-module','864495036647555','FW_VERSION','6',-1234), +('communication-module','864495036647555','SIM_IMSI','413012689159555',-1234), +('communication-module','864495036647555','SIM_PIN','1234',-1234), +('communication-module','864495036647555','SUB_TYPE_ID','1',-1234), +('communication-module','864495036647555','token',NULL,-1234), +('power-meter','000019729555','BRANCH','KOTTE',-1234), +('power-meter','000019729555','CATEGORY','BILLING_BULK',-1234), +('power-meter','000019729555','COM_MODULE_IMEI','864495036647555',-1234), +('power-meter','000019729555','CUSTOMER_REF','0602297555',-1234), +('power-meter','000019729555','DEPOT','PITA-KOTTE',-1234), +('power-meter','000019729555','HAS_EXPORT','false',-1234), +('power-meter','000019729555','HAS_E_BILLING','false',-1234), +('power-meter','000019729555','IP_ADDRESS','192.168.118.111',-1234), +('power-meter','000019729555','IS_FEEDER_END','false',-1234), +('power-meter','000019729555','NODE_TYPE','BILLING',-1234), +('power-meter','000019729555','POLE_ID','NW55/5/15C',-1234), +('power-meter','000019729555','SIM_NUMBER','+94713192111',-1234), +('power-meter','000019729555','SUBSTATION_ID','AZ8555',-1234), +('power-meter','000019729555','SUB_TYPE_ID','1',-1234), +('power-meter','000019729555','token',NULL,-1234); + + +-- INSERT INTO SIM_DEVICE (IMSI,IP_ADDRESS,MOBILE_NO,SUB_TYPE_ID,APN) VALUES ('413012689159555','10.217.55.155','+94713192111',1,'LECOSMSTC'); +INSERT INTO COMMUNICATION_MODULE(IMEI,SIM_IMSI,FW_VERSION,SUB_TYPE_ID,BRANCH,SMS_PIN) VALUES ('864495036647555','413012689159555',6,1,'KOTTE','1234'); +INSERT INTO POWER_METER_DEVICE (SERIAL,IP_ADDRESS,SIM_NUMBER,COM_MODULE_IMEI,SUB_TYPE_ID,CUSTOMER_REF,NODE_TYPE,CATEGORY,BRANCH,DEPOT,SUBSTATION_ID,HAS_EXPORT,HAS_E_BILLING,IS_FEEDER_END,POLE_ID,ASSIGNED_ON) +VALUES ('000019729555','192.168.118.111','+94713192111','864495036647555',1,'0602297555','BILLING','BILLING_BULK','KOTTE','PITA-KOTTE','AZ82555','false','false','false','NW55/5/15C',NULL); + +INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES +(3,-1234,'Meter','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), +(4,-1234,'Meter','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 4, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'); + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml new file mode 100644 index 0000000000..6043bbcf91 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml @@ -0,0 +1,727 @@ + + + + + + + + + + + + + ${hotdeployment} + ${hotupdate} + optional + true + work/mtom + 4000 + + ${childfirstCL} + + + true + + + true + + + + false + + inmemory + + + + + + + services + + + axis2services + + + axis2modules + + + @product.name@-@product.version@ + + + @product.name@-@product.version@ + + + + + + + false + + + + + + false + + + true + + + repository/deployment/server/synapse-configs + + + + . + + + . + + + WSO2 Carbon Server + + + + + + + ${jaxwsparam} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9763 + + + + + + + + + + + + 9443 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 + chunked + + true + + + HTTP/1.1 + chunked + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + multicast + + + + + wso2.carbon.domain + + + + + + 45564 + + 100 + + 60 + + + + + + 127.0.0.1 + + + + + + 4000 + + + + + + + + + + + + + + + + + + 127.0.0.1 + 4000 + + + + + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml new file mode 100644 index 0000000000..6757e67de3 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml @@ -0,0 +1,303 @@ + + + + + + + true + false + false + + + 500 + + 15000 + + + false + + + + true + + + + + + false + + + admin + axis2 + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6071 + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 + chunked + 60000 + 60000 + + + HTTP/1.1 + chunked + 60000 + 60000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml new file mode 100644 index 0000000000..e54e1107bb --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml @@ -0,0 +1,288 @@ + + + + + + + + + true + true + optional + + + true + + + false + + + + true + + + + + + false + + + false + + + axis2services + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml new file mode 100644 index 0000000000..fbc7e4b021 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml @@ -0,0 +1,660 @@ + + + + + + + + + ${product.name} + + + ${product.key} + + + ${product.version} + + + + + + + + + local:/${carbon.context}/services/ + + + + + + + ${default.server.role} + + + + + + + org.wso2.carbon + + + / + + + + + + + + + 15 + + + + + + + + + 0 + + + + + 9999 + + 11111 + + + + + + 10389 + + 8000 + + + + + + 10500 + + + + + + + org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory + + + + + + + + + + java + + + + + + + + + + false + + + false + + + 600 + + + + false + + + + + + + + 30 + + + + + + + + + 15 + + + + + + ${carbon.home}/repository/deployment/server/ + + + 15 + + + ${carbon.home}/repository/conf/axis2/axis2.xml + + + 30000 + + + ${carbon.home}/repository/deployment/client/ + + ${carbon.home}/repository/conf/axis2/axis2_client.xml + + true + + + + + + + + + + admin + Default Administrator Role + + + user + Default User Role + + + + + + + + + + + + ${carbon.home}/repository/resources/security/wso2carbon.jks + + JKS + + wso2carbon + + wso2carbon + + wso2carbon + + + + + + ${carbon.home}/repository/resources/security/client-truststore.jks + + JKS + + wso2carbon + + + + + + + + + + + + + + + + + + + UserManager + + + false + + + + + + + ${carbon.home}/tmp/work + + + + + + true + + + 10 + + + 30 + + + + + + 100 + + + + keystore + certificate + * + + org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor + + + + + jarZip + + org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor + + + + dbs + + org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor + + + + tools + + org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor + + + + toolsAny + + org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor + + + + + + + info + org.wso2.carbon.core.transports.util.InfoProcessor + + + wsdl + org.wso2.carbon.core.transports.util.Wsdl11Processor + + + wsdl2 + org.wso2.carbon.core.transports.util.Wsdl20Processor + + + xsd + org.wso2.carbon.core.transports.util.XsdProcessor + + + + + + false + false + true + svn + http://svnrepo.example.com/repos/ + username + password + true + + + + + + + + + + + + + + + ${require.carbon.servlet} + + + + + true + + + + + + + default repository + ${p2.repo.url} + + + + + + + + true + + + + + + true + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml new file mode 100644 index 0000000000..0e53e2b7d6 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -0,0 +1,172 @@ + + + + + + + + jdbc/DM_DS + + + + + 1000 + 60000 + 60000 + true + + + org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + + + org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + + + org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + + + org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider + + + + + false + + + https://localhost:9443 + admin + admin + + + https://localhost:9443 + admin + admin + + + org.wso2.carbon.policy.mgt + true + 60000 + 5 + 8 + 20 + + + + Simple + true + + + + 20 + 20 + 20 + 20 + 20 + 20 + 20 + + + + true + + + + false + 600 + + 10000 + + + false + 600 + + 10000 + + + true + + + false + 86400 + + + + + jdbc/DM_ARCHIVAL_DS + + + + false + org.wso2.carbon.device.mgt.core.task.impl.ArchivalTask + + 0 0 0 1/1 * ? * + + 30 + 1000 + + false + org.wso2.carbon.device.mgt.core.task.impl.ArchivedDataDeletionTask + + 0 0 3 1/1 * ? * + + 365 + + + + + false + + + false + false + + false + + + + + * + + + + + + true + wss://localhost:9443 + 2 + 100 + 20 + 15 + 640 + + BYOD,COPE + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml new file mode 100644 index 0000000000..b2f8c12a6f --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -0,0 +1,26 @@ + + + + + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + org.h2.Driver + wso2carbon + wso2carbon + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt new file mode 100644 index 0000000000..ffa7c79264 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt @@ -0,0 +1,12 @@ +This directory supports adding third-pary config files to specific bundles during runtime. + +Explanation: Each OSGi bundle has its own classLoader. Some thirdpary libs read configs from classPath. This scenario fails in OSGi runtime, since OSGi runtime does not share a common classPath for individual bundles. Bundling config files during the bundle creation process itself will solve the issue. However it limits the ability to edit the configs during restarts. + +Here we are providing a workaround for such scenarios. The given config file will get resolved to a fragment bundle and will get attached to the specified host bundle. The host bundle name(symbolic name) is resolved by looking at the directory structure. Hence host bundle name should be directory name of the config file directory. + + +Example: The bundle with symbolic name, 'org.foo.bar' expects a config file named 'foobar.properties' from its classPath. + +create a directory named 'org.foo.bar' inside 'repository/conf/etc/bundle-config' - (this directory) and place the foobar.properties file. + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties new file mode 100644 index 0000000000..eb0f2e8493 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties @@ -0,0 +1,22 @@ +# +# Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. +# +# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. +# +# Licensed under the Entgra Commercial License, Version 1.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://entgra.io/licenses/entgra-commercial/1.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. +# + +#osgi.service.1 = org.wso2.carbon.client.configcontext.provider.Axis2ClientConfigContextProvider +#osgi.service.2 = org.wso2.carbon.user.core.UserManager +#osgi.service.3 = org.wso2.carbon.user.api.UserRealmService \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml new file mode 100644 index 0000000000..5cb755588f --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml @@ -0,0 +1,56 @@ + + + + + + + + 800 + 2047 + 2047 + 1024 + 4096 + 02:FB:AA:5F:20:64:49:4A:27:29:55:71:83:F7:46:CD + + + 256 + 512 + 256 + + + carbon.home + carbon.config.dir.path + axis2.home + + + Linux + Unix + Mac OS + Windows Server 2003 + Windows XP + Windows Vista + Windows 7 + Mac OS X + Windows Server 2008 + Windows Server 2008 R2 + AIX + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml new file mode 100644 index 0000000000..b9f2bed216 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml @@ -0,0 +1,35 @@ + + + + + true + + + localhost + + + ${Ports.JMX.RMIRegistryPort} + + + ${Ports.JMX.RMIServerPort} + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/launch.ini b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/launch.ini new file mode 100644 index 0000000000..8b9f5ad190 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/launch.ini @@ -0,0 +1,258 @@ +# Eclipse Runtime Configuration Overrides +# These properties are loaded prior to starting the framework and can also be used to override System Properties +# @null is a special value used to override and clear the framework's copy of a System Property prior to starting the framework +# "*" can be used together with @null to clear System Properties that match a prefix name. + +osgi.*=@null +org.osgi.*=@null +eclipse.*=@null + +osgi.parentClassloader=app +osgi.contextClassLoaderParent=app + +# When osgi.clean is set to "true", any cached data used by the OSGi framework +# will be wiped clean. This will clean the caches used to store bundle +# dependency resolution and eclipse extension registry data. Using this +# option will force OSGi framework to reinitialize these caches. +# The following setting is put in place to get rid of the problems +# faced when re-starting the system. Please note that, when this setting is +# true, if you manually start a bundle, it would not be available when +# you re-start the system. To avid this, copy the bundle jar to the plugins +# folder, before you re-start the system. +osgi.clean=true + +# Uncomment the following line to turn on Eclipse Equinox debugging. +# You may also edit the osgi-debug.options file and fine tune the debugging +# options to suite your needs. +#osgi.debug=./repository/conf/osgi-debug.options + +# Following system property allows us to control the public JDK packages exported through the system bundle. +org.osgi.framework.system.packages=javax.accessibility,\ +javax.activity,\ +javax.crypto,\ +javax.crypto.interfaces,\ +javax.crypto.spec,\ +javax.imageio,\ +javax.imageio.event,\ +javax.imageio.metadata,\ +javax.imageio.plugins.bmp,\ +javax.imageio.plugins.jpeg,\ +javax.imageio.spi,\ +javax.imageio.stream,\ +javax.jms,\ +javax.management,\ +javax.management.loading,\ +javax.management.modelmbean,\ +javax.management.monitor,\ +javax.management.openmbean,\ +javax.management.relation,\ +javax.management.remote,\ +javax.management.remote.rmi,\ +javax.management.timer,\ +javax.naming,\ +javax.naming.directory,\ +javax.naming.event,\ +javax.naming.ldap,\ +javax.naming.spi,\ +javax.net,\ +javax.net.ssl,\ +javax.print,\ +javax.print.attribute,\ +javax.print.attribute.standard,\ +javax.print.event,\ +javax.rmi,\ +javax.rmi.CORBA,\ +javax.rmi.ssl,\ +javax.script,\ +javax.security.auth,\ +javax.security.auth.callback,\ +javax.security.auth.kerberos,\ +javax.security.auth.login,\ +javax.security.auth.spi,\ +javax.security.auth.x500,\ +javax.security.cert,\ +javax.security.sasl,\ +javax.sound.midi,\ +javax.sound.midi.spi,\ +javax.sound.sampled,\ +javax.sound.sampled.spi,\ +javax.sql,\ +javax.sql.rowset,\ +javax.sql.rowset.serial,\ +javax.sql.rowset.spi,\ +javax.swing,\ +javax.swing.border,\ +javax.swing.colorchooser,\ +javax.swing.event,\ +javax.swing.filechooser,\ +javax.swing.plaf,\ +javax.swing.plaf.basic,\ +javax.swing.plaf.metal,\ +javax.swing.plaf.multi,\ +javax.swing.plaf.synth,\ +javax.swing.table,\ +javax.swing.text,\ +javax.swing.text.html,\ +javax.swing.text.html.parser,\ +javax.swing.text.rtf,\ +javax.swing.tree,\ +javax.swing.undo,\ +javax.transaction,\ +javax.transaction.xa,\ +javax.xml.namespace,\ +javax.xml.parsers,\ +javax.xml.stream,\ +javax.xml.stream.events,\ +javax.xml.stream.util,\ +javax.xml.transform,\ +javax.xml.transform.stream,\ +javax.xml.transform.dom,\ +javax.xml.transform.sax,\ +javax.xml,\ +javax.xml.validation,\ +javax.xml.datatype,\ +javax.xml.xpath,\ +javax.activation,\ +com.sun.activation.registries,\ +com.sun.activation.viewers,\ +org.ietf.jgss,\ +org.omg.CORBA,\ +org.omg.CORBA_2_3,\ +org.omg.CORBA_2_3.portable,\ +org.omg.CORBA.DynAnyPackage,\ +org.omg.CORBA.ORBPackage,\ +org.omg.CORBA.portable,\ +org.omg.CORBA.TypeCodePackage,\ +org.omg.CosNaming,\ +org.omg.CosNaming.NamingContextExtPackage,\ +org.omg.CosNaming.NamingContextPackage,\ +org.omg.Dynamic,\ +org.omg.DynamicAny,\ +org.omg.DynamicAny.DynAnyFactoryPackage,\ +org.omg.DynamicAny.DynAnyPackage,\ +org.omg.IOP,\ +org.omg.IOP.CodecFactoryPackage,\ +org.omg.IOP.CodecPackage,\ +org.omg.Messaging,\ +org.omg.PortableInterceptor,\ +org.omg.PortableInterceptor.ORBInitInfoPackage,\ +org.omg.PortableServer,\ +org.omg.PortableServer.CurrentPackage,\ +org.omg.PortableServer.POAManagerPackage,\ +org.omg.PortableServer.POAPackage,\ +org.omg.PortableServer.portable,\ +org.omg.PortableServer.ServantLocatorPackage,\ +org.omg.SendingContext,\ +org.omg.stub.java.rmi,\ +org.w3c.dom,\ +org.w3c.dom.bootstrap,\ +org.w3c.dom.css,\ +org.w3c.dom.events,\ +org.w3c.dom.html,\ +org.w3c.dom.ls,\ +org.w3c.dom.ranges,\ +org.w3c.dom.stylesheets,\ +org.w3c.dom.traversal,\ +org.w3c.dom.views ,\ +org.xml.sax,\ +org.xml.sax.ext,\ +org.xml.sax.helpers,\ +org.apache.xerces.xpointer,\ +org.apache.xerces.xni.grammars,\ +org.apache.xerces.impl.xs.util,\ +org.apache.xerces.jaxp.validation,\ +org.apache.xerces.impl.dtd.models,\ +org.apache.xerces.impl.xpath,\ +org.apache.xerces.dom3.as,\ +org.apache.xerces.impl.dv.xs,\ +org.apache.xerces.util,\ +org.apache.xerces.impl.xs.identity,\ +org.apache.xerces.impl.xs.opti,\ +org.apache.xerces.jaxp,\ +org.apache.xerces.impl.dv,\ +org.apache.xerces.xs.datatypes,\ +org.apache.xerces.dom.events,\ +org.apache.xerces.impl.msg,\ +org.apache.xerces.xni,\ +org.apache.xerces.impl.xs,\ +org.apache.xerces.impl,\ +org.apache.xerces.impl.io,\ +org.apache.xerces.xinclude,\ +org.apache.xerces.jaxp.datatype,\ +org.apache.xerces.parsers,\ +org.apache.xerces.impl.dv.util,\ +org.apache.xerces.xni.parser,\ +org.apache.xerces.impl.xs.traversers,\ +org.apache.xerces.impl.dv.dtd,\ +org.apache.xerces.xs,\ +org.apache.xerces.impl.dtd,\ +org.apache.xerces.impl.validation,\ +org.apache.xerces.impl.xs.models,\ +org.apache.xerces.impl.xpath.regex,\ +org.apache.xml.serialize,\ +org.apache.xerces.dom,\ +org.apache.xalan,\ +org.apache.xalan.xslt,\ +org.apache.xalan.templates,\ +org.apache.xalan.xsltc,\ +org.apache.xalan.xsltc.cmdline,\ +org.apache.xalan.xsltc.cmdline.getopt,\ +org.apache.xalan.xsltc.trax,\ +org.apache.xalan.xsltc.dom,\ +org.apache.xalan.xsltc.runtime,\ +org.apache.xalan.xsltc.runtime.output,\ +org.apache.xalan.xsltc.util,\ +org.apache.xalan.xsltc.compiler,\ +org.apache.xalan.xsltc.compiler.util,\ +org.apache.xalan.serialize,\ +org.apache.xalan.client,\ +org.apache.xalan.res,\ +org.apache.xalan.transformer,\ +org.apache.xalan.extensions,\ +org.apache.xalan.lib,\ +org.apache.xalan.lib.sql,\ +org.apache.xalan.processor,\ +org.apache.xalan.trace,\ +org.apache.xml.dtm,\ +org.apache.xml.dtm.ref,\ +org.apache.xml.dtm.ref.sax2dtm,\ +org.apache.xml.dtm.ref.dom2dtm,\ +org.apache.xml.utils,\ +org.apache.xml.utils.res,\ +org.apache.xml.res,\ +org.apache.xml.serializer,\ +org.apache.xml.serializer.utils,\ +org.apache.xpath,\ +org.apache.xpath.domapi,\ +org.apache.xpath.objects,\ +org.apache.xpath.patterns,\ +org.apache.xpath.jaxp,\ +org.apache.xpath.res,\ +org.apache.xpath.operations,\ +org.apache.xpath.functions,\ +org.apache.xpath.axes,\ +org.apache.xpath.compiler,\ +org.apache.xml.resolver,\ +org.apache.xml.resolver.tools,\ +org.apache.xml.resolver.helpers,\ +org.apache.xml.resolver.readers,\ +org.apache.xml.resolver.etc,\ +org.apache.xml.resolver.apps,\ +javax.xml.ws,\ +javax.xml.ws.handler,\ +javax.xml.ws.handler.soap,\ +javax.xml.ws.http,\ +javax.xml.ws.soap,\ +javax.xml.ws.spi,\ +javax.xml.ws.spi.http,\ +javax.xml.ws.wsaddressing,\ +javax.xml.bind,\ +javax.xml.bind.annotation,\ +javax.xml.bind.annotation.adapters,\ +javax.annotation,\ +javax.jws,\ +javax.jws.soap,\ +com.sun.xml.internal.messaging.saaj.soap.ver1_1,\ +com.sun.xml.internal.messaging.saaj.soap,\ +com.sun.tools.internal.ws.spi,\ +org.wso2.carbon.bootstrap diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties new file mode 100644 index 0000000000..8385072039 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties @@ -0,0 +1,73 @@ +# +# Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. +# +# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. +# +# Licensed under the Entgra Commercial License, Version 1.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://entgra.io/licenses/entgra-commercial/1.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. +# + +############################################################ +# Default Logging Configuration File +# +# You can use a different file by specifying a filename +# with the java.util.logging.config.file system property. +# For example java -Djava.util.logging.config.file=myfile +############################################################ +############################################################ +# Global properties +# NOTE: this configuration file use to get the handler list, +# Properties(except level property) define for each handler +# may be not available because LogRecords handover to log4j +# appenders in runtime. +############################################################ +# "handlers" specifies a comma separated list of log Handler +# classes. These handlers will be installed during VM startup. +# Note that these classes must be on the system classpath. +# By default we only configure a ConsoleHandler, which will only +# show messages at the INFO and above levels. +#handlers= java.util.logging.ConsoleHandler +# To also add the FileHandler, use the following line instead. +#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler +# Add org.wso2.carbon.bootstrap.logging.handlers.LogEventHandler to handlers if you need to push java logs to LOGEVENT appender +handlers=org.wso2.carbon.bootstrap.logging.handlers.LoggingConsoleHandler, org.wso2.carbon.bootstrap.logging.handlers.LoggingFileHandler +# Default global logging level. +# This specifies which kinds of events are logged across +# all loggers. For any given facility this global level +# can be overriden by a facility specific level +# Note that the ConsoleHandler also has a separate level +# setting to limit messages printed to the console. +.level=INFO +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +# +############################################################ +# This FileHandler pushed LogRecords to a log4j FileAppander in runtime +org.wso2.carbon.bootstrap.logging.handlers.LoggingFileHandler.level=INFO +#org.wso2.carbon.bootstrap.logging.handlers.LoggingFileHandler.formatter = java.util.logging.SimpleFormatter +# This ConsoleHandler pushed LogRecords to q log4j ConsoleAppander in runtime +org.wso2.carbon.bootstrap.logging.handlers.LoggingConsoleHandler.level=INFO +#org.wso2.carbon.bootstrap.logging.handlers.LoggingConsoleHandler.formatter = java.util.logging.SimpleFormatter +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ +# For example, set the com.xyz.foo logger to only log SEVERE +# messages: +#com.xyz.foo.level = SEVERE +org.apache.coyote.level=SEVERE +org.apache.catalina.level=SEVERE +com.hazelcast.level=SEVERE + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.mappings b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.mappings new file mode 100644 index 0000000000..97a5c5a5fc --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.mappings @@ -0,0 +1,27 @@ +# +# Copyright 2005-2011 WSO2, Inc. (http://wso2.com) +# +# Licensed 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. +# + +# This file is to define the human readable media type for a mime type. +# Eg:- +# text/plain txt text +application/wsdl+xml WSDL +application/x-xsd+xml Schema +application/policy+xml Policy +application/vnd.wso2-service+xml Service +application/vnd.wso2-hyperlink Hyperlink +application/vnd.wso2.endpoint Endpoint +application/vnd.wso2-api+xml API +application/vnd.wso2-uri+xml URI diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.types b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.types new file mode 100644 index 0000000000..21c386da00 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/mime.types @@ -0,0 +1,734 @@ +# +# Copyright 2005-2009 WSO2, Inc. (http://wso2.com) +# +# Licensed 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. +# + +# Media type for wsdl files. This is not defined in the original mime.types file. +chemical/x-alchemy alc +application/andrew-inset ez +application/wsdl+xml wsdl +application/vnd.sun.wadl+xml wadl +application/activemessage +application/applefile +application/atomicmail +application/batch-SMTP +application/beep+xml +application/cals-1840 +application/commonground +application/cu-seeme cu +application/cybercash +application/dca-rft +application/dec-dx +application/docbook+xml +application/dsptype tsp +application/dvcs +application/edi-consent +application/edi-x12 +application/edifact +application/eshop +application/font-tdpfr +application/futuresplash spl +application/ghostview +application/hta hta +application/http +application/hyperstudio +application/iges +application/index +application/index.cmd +application/index.obj +application/index.response +application/index.vnd +application/iotp +application/ipp +application/isup +application/java-archive jar +application/java-serialized-object ser +application/java-vm class +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/macwriteii +application/marc +application/mathematica nb +application/mathematica-old +application/msaccess mdb +application/msword doc dot +application/news-message-id +application/news-transmission +application/ocsp-request +application/ocsp-response +application/octet-stream bin +application/oda oda +application/ogg ogg +application/parityfec +application/pdf pdf +application/pgp-encrypted +application/pgp-keys key +application/pgp-signature pgp +application/pics-rules prf +application/pkcs10 +application/pkcs7-mime +application/pkcs7-signature +application/pkix-cert +application/pkix-crl +application/pkixcmp +application/policy+xml +application/postscript ps ai eps +application/prs.alvestrand.titrax-sheet +application/prs.cww +application/prs.nprend +application/qsig +application/rar rar +application/rdf+xml rdf +application/remote-printing +application/riscos +application/rss+xml rss +application/rtf +application/sdp +application/set-payment +application/set-payment-initiation +application/set-registration +application/set-registration-initiation +application/sgml +application/sgml-open-catalog +application/sieve +application/slate +application/smil smi smil +application/timestamp-query +application/timestamp-reply +application/vemmi +application/whoispp-query +application/whoispp-response +application/wita +application/wordperfect wpd +application/wordperfect5.1 wp5 +application/x400-bp +application/xhtml+xml xhtml xht +application/xml xml xsl xslt jrxml +application/xml-dtd +application/xml-external-parsed-entity +application/zip zip +application/vnd.3M.Post-it-Notes +application/vnd.accpac.simply.aso +application/vnd.accpac.simply.imp +application/vnd.acucobol +application/vnd.aether.imp +application/vnd.anser-web-certificate-issue-initiation +application/vnd.anser-web-funds-transfer-initiation +application/vnd.audiograph +application/vnd.bmi +application/vnd.businessobjects +application/vnd.canon-cpdl +application/vnd.canon-lips +application/vnd.cinderella cdy +application/vnd.claymore +application/vnd.commerce-battelle +application/vnd.commonspace +application/vnd.comsocaller +application/vnd.contact.cmsg +application/vnd.cosmocaller +application/vnd.ctc-posml +application/vnd.cups-postscript +application/vnd.cups-raster +application/vnd.cups-raw +application/vnd.cybank +application/vnd.dna +application/vnd.dpgraph +application/vnd.dxr +application/vnd.ecdis-update +application/vnd.ecowin.chart +application/vnd.ecowin.filerequest +application/vnd.ecowin.fileupdate +application/vnd.ecowin.series +application/vnd.ecowin.seriesrequest +application/vnd.ecowin.seriesupdate +application/vnd.enliven +application/vnd.epson.esf +application/vnd.epson.msf +application/vnd.epson.quickanime +application/vnd.epson.salt +application/vnd.epson.ssf +application/vnd.ericsson.quickcall +application/vnd.eudora.data +application/vnd.fdf +application/vnd.ffsns +application/vnd.flographit +application/vnd.framemaker +application/vnd.fsc.weblaunch +application/vnd.fujitsu.oasys +application/vnd.fujitsu.oasys2 +application/vnd.fujitsu.oasys3 +application/vnd.fujitsu.oasysgp +application/vnd.fujitsu.oasysprs +application/vnd.fujixerox.ddd +application/vnd.fujixerox.docuworks +application/vnd.fujixerox.docuworks.binder +application/vnd.fut-misnet +application/vnd.grafeq +application/vnd.groove-account +application/vnd.groove-identity-message +application/vnd.groove-injector +application/vnd.groove-tool-message +application/vnd.groove-tool-template +application/vnd.groove-vcard +application/vnd.hhe.lesson-player +application/vnd.hp-HPGL +application/vnd.hp-PCL +application/vnd.hp-PCLXL +application/vnd.hp-hpid +application/vnd.hp-hps +application/vnd.httphone +application/vnd.hzn-3d-crossword +application/vnd.ibm.MiniPay +application/vnd.ibm.afplinedata +application/vnd.ibm.modcap +application/vnd.informix-visionary +application/vnd.intercon.formnet +application/vnd.intertrust.digibox +application/vnd.intertrust.nncp +application/vnd.intu.qbo +application/vnd.intu.qfx +application/vnd.irepository.package+xml +application/vnd.is-xpr +application/vnd.japannet-directory-service +application/vnd.japannet-jpnstore-wakeup +application/vnd.japannet-payment-wakeup +application/vnd.japannet-registration +application/vnd.japannet-registration-wakeup +application/vnd.japannet-setstore-wakeup +application/vnd.japannet-verification +application/vnd.japannet-verification-wakeup +application/vnd.koan +application/vnd.lotus-1-2-3 +application/vnd.lotus-approach +application/vnd.lotus-freelance +application/vnd.lotus-notes +application/vnd.lotus-organizer +application/vnd.lotus-screencam +application/vnd.lotus-wordpro +application/vnd.mcd +application/vnd.mediastation.cdkey +application/vnd.meridian-slingshot +application/vnd.mif +application/vnd.minisoft-hp3000-save +application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf +application/vnd.mobius.dis +application/vnd.mobius.msl +application/vnd.mobius.plc +application/vnd.mobius.txf +application/vnd.motorola.flexsuite +application/vnd.motorola.flexsuite.adsi +application/vnd.motorola.flexsuite.fis +application/vnd.motorola.flexsuite.gotap +application/vnd.motorola.flexsuite.kmr +application/vnd.motorola.flexsuite.ttc +application/vnd.motorola.flexsuite.wem +application/vnd.mozilla.xul+xml xul +application/vnd.ms-artgalry +application/vnd.ms-asf +application/vnd.ms-excel xls xlb xlt +application/vnd.ms-lrm +application/vnd.ms-pki.seccat cat +application/vnd.ms-pki.stl stl +application/vnd.ms-powerpoint ppt pps +application/vnd.ms-project +application/vnd.ms-tnef +application/vnd.ms-works +application/vnd.mseq +application/vnd.msign +application/vnd.music-niff +application/vnd.musician +application/vnd.netfpx +application/vnd.noblenet-directory +application/vnd.noblenet-sealer +application/vnd.noblenet-web +application/vnd.novadigm.EDM +application/vnd.novadigm.EDX +application/vnd.novadigm.EXT +application/vnd.oasis.opendocument.chart odc +application/vnd.oasis.opendocument.database odb +application/vnd.oasis.opendocument.formula odf +application/vnd.oasis.opendocument.graphics odg +application/vnd.oasis.opendocument.graphics-template otg +application/vnd.oasis.opendocument.image odi +application/vnd.oasis.opendocument.presentation odp +application/vnd.oasis.opendocument.presentation-template otp +application/vnd.oasis.opendocument.spreadsheet ods +application/vnd.oasis.opendocument.spreadsheet-template ots +application/vnd.oasis.opendocument.text odt +application/vnd.oasis.opendocument.text-master odm +application/vnd.oasis.opendocument.text-template ott +application/vnd.oasis.opendocument.text-web oth +application/vnd.osa.netdeploy +application/vnd.palm +application/vnd.pg.format +application/vnd.pg.osasli +application/vnd.powerbuilder6 +application/vnd.powerbuilder6-s +application/vnd.powerbuilder7 +application/vnd.powerbuilder7-s +application/vnd.powerbuilder75 +application/vnd.powerbuilder75-s +application/vnd.previewsystems.box +application/vnd.publishare-delta-tree +application/vnd.pvi.ptid1 +application/vnd.pwg-xhtml-print+xml +application/vnd.rapid +application/vnd.rim.cod cod +application/vnd.s3sms +application/vnd.seemail +application/vnd.shana.informed.formdata +application/vnd.shana.informed.formtemplate +application/vnd.shana.informed.interchange +application/vnd.shana.informed.package +application/vnd.smaf mmf +application/vnd.sss-cod +application/vnd.sss-dtf +application/vnd.sss-ntf +application/vnd.stardivision.calc sdc +application/vnd.stardivision.draw sda +application/vnd.stardivision.impress sdd sdp +application/vnd.stardivision.math smf +application/vnd.stardivision.writer sdw vor +application/vnd.stardivision.writer-global sgl +application/vnd.street-stream +application/vnd.sun.xml.calc sxc +application/vnd.sun.xml.calc.template stc +application/vnd.sun.xml.draw sxd +application/vnd.sun.xml.draw.template std +application/vnd.sun.xml.impress sxi +application/vnd.sun.xml.impress.template sti +application/vnd.sun.xml.math sxm +application/vnd.sun.xml.writer sxw +application/vnd.sun.xml.writer.global sxg +application/vnd.sun.xml.writer.template stw +application/vnd.svd +application/vnd.swiftview-ics +application/vnd.symbian.install sis +application/vnd.triscape.mxs +application/vnd.trueapp +application/vnd.truedoc +application/vnd.tve-trigger +application/vnd.ufdl +application/vnd.uplanet.alert +application/vnd.uplanet.alert-wbxml +application/vnd.uplanet.bearer-choice +application/vnd.uplanet.bearer-choice-wbxml +application/vnd.uplanet.cacheop +application/vnd.uplanet.cacheop-wbxml +application/vnd.uplanet.channel +application/vnd.uplanet.channel-wbxml +application/vnd.uplanet.list +application/vnd.uplanet.list-wbxml +application/vnd.uplanet.listcmd +application/vnd.uplanet.listcmd-wbxml +application/vnd.uplanet.signal +application/vnd.vcx +application/vnd.vectorworks +application/vnd.vidsoft.vidconference +application/vnd.visio vsd +application/vnd.vividence.scriptfile +application/vnd.wap.sic +application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo +application/vnd.wrq-hp3000-labelled +application/vnd.wso2.bpel+xml bpel +application/vnd.wso2.bpmn+xml bpmn +application/vnd.wso2.endpoint +application/vnd.wso2.governance-archive gar +application/vnd.wso2-hyperlink +application/vnd.wso2.registry-ext-type+xml rxt +application/vnd.wso2-service+xml +application/vnd.wso2.xpdl+xml xpdl +application/vnd.wt.stf +application/vnd.xara +application/vnd.xfdl +application/vnd.yellowriver-custom-menu +application/x-123 wk +application/x-abiword abw +application/x-apple-diskimage dmg +application/x-bcpio bcpio +application/x-bittorrent torrent +application/x-cdf cdf +application/x-cdlink vcd +application/x-chess-pgn pgn +application/x-core +application/x-cpio cpio +application/x-csh csh +application/x-debian-package deb udeb +application/x-director dcr dir dxr +application/x-dms dms +application/x-doom wad +application/x-dvi dvi +application/x-executable +application/x-flac flac +application/x-font pfa pfb gsf pcf pcf.Z +application/x-freemind mm +application/x-futuresplash spl +application/x-gnumeric gnumeric +application/x-go-sgf sgf +application/x-graphing-calculator gcf +application/x-gtar gtar tgz taz +application/x-hdf hdf +application/x-httpd-php phtml pht php +application/x-httpd-php-source phps +application/x-httpd-php3 php3 +application/x-httpd-php3-preprocessed php3p +application/x-httpd-php4 php4 +application/x-httpd-eruby rhtml +application/x-ica ica +application/x-internet-signup ins isp +application/x-iphone iii +application/x-iso9660-image iso +application/x-java-applet +application/x-java-bean +application/x-java-jnlp-file jnlp +application/x-javascript js +application/x-jmol jmz +application/x-kchart chrt +application/x-kdelnk +application/x-killustrator kil +application/x-koan skp skd skt skm +application/x-kpresenter kpr kpt +application/x-kspread ksp +application/x-kword kwd kwt +application/x-latex latex +application/x-lha lha +application/x-lzh lzh +application/x-lzx lzx +application/x-maker frm maker frame fm fb book fbdoc +application/x-mif mif +application/x-ms-wmd wmd +application/x-ms-wmz wmz +application/x-msdos-program com exe bat dll +application/x-msi msi +application/x-netcdf nc +application/x-ns-proxy-autoconfig pac +application/x-nwc nwc +application/x-object o +application/x-oz-application oza +application/x-pkcs7-certreqresp p7r +application/x-pkcs7-crl crl +application/x-python-code pyc pyo +application/x-quicktimeplayer qtl +application/x-redhat-package-manager rpm +application/x-rx +application/x-sh sh +application/x-shar shar +application/x-shellscript +application/x-shockwave-flash swf swfl +application/x-stuffit sit +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex-gf gf +application/x-tex-pk pk +application/x-texinfo texinfo texi +application/x-trash ~ % bak old sik +application/x-troff t tr roff +application/x-troff-man man +application/x-troff-me me +application/x-troff-ms ms +application/x-ustar ustar +application/x-videolan +application/x-wais-source src +application/x-wingz wz +application/x-x509-ca-cert crt +application/x-xcf xcf +application/x-xfig fig +application/x-xpinstall xpi +application/x-xsd+xml xsd + +audio/32kadpcm +audio/basic au snd +audio/g.722.1 +audio/l16 +audio/midi mid midi kar +audio/mp4a-latm +audio/mpa-robust +audio/mpeg mpga mpega mp2 mp3 m4a +audio/mpegurl m3u +audio/parityfec +audio/prs.sid sid +audio/telephone-event +audio/tone +audio/vnd.cisco.nse +audio/vnd.cns.anp1 +audio/vnd.cns.inf1 +audio/vnd.digital-winds +audio/vnd.everad.plj +audio/vnd.lucent.voice +audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 +audio/vnd.nuera.ecelp7470 +audio/vnd.nuera.ecelp9600 +audio/vnd.octel.sbc +audio/vnd.qcelp +audio/vnd.rhetorex.32kadpcm +audio/vnd.vmx.cvsd +audio/x-aiff aif aiff aifc +audio/x-gsm gsm +audio/x-mpegurl m3u +audio/x-ms-wma wma +audio/x-ms-wax wax +audio/x-pn-realaudio-plugin +audio/x-pn-realaudio ra rm ram +audio/x-realaudio ra +audio/x-scpls pls +audio/x-sd2 sd2 +audio/x-wav wav + +chemical/x-alchemy alc +chemical/x-cache cac cache +chemical/x-cache-csf csf +chemical/x-cactvs-binary cbin cascii ctab +chemical/x-cdx cdx +chemical/x-cerius cer +chemical/x-chem3d c3d +chemical/x-chemdraw chm +chemical/x-cif cif +chemical/x-cmdf cmdf +chemical/x-cml cml +chemical/x-compass cpa +chemical/x-crossfire bsd +chemical/x-csml csml csm +chemical/x-ctx ctx +chemical/x-cxf cxf cef +#chemical/x-daylight-smiles smi +chemical/x-embl-dl-nucleotide emb embl +chemical/x-galactic-spc spc +chemical/x-gamess-input inp gam gamin +chemical/x-gaussian-checkpoint fch fchk +chemical/x-gaussian-cube cub +chemical/x-gaussian-input gau gjc gjf +chemical/x-gaussian-log gal +chemical/x-gcg8-sequence gcg +chemical/x-genbank gen +chemical/x-hin hin +chemical/x-isostar istr ist +chemical/x-jcamp-dx jdx dx +chemical/x-kinemage kin +chemical/x-macmolecule mcm +chemical/x-macromodel-input mmd mmod +chemical/x-mdl-molfile mol +chemical/x-mdl-rdfile rd +chemical/x-mdl-rxnfile rxn +chemical/x-mdl-sdfile sd sdf +chemical/x-mdl-tgf tgf +#chemical/x-mif mif +chemical/x-mmcif mcif +chemical/x-mol2 mol2 +chemical/x-molconn-Z b +chemical/x-mopac-graph gpt +chemical/x-mopac-input mop mopcrt mpc dat zmt +chemical/x-mopac-out moo +chemical/x-mopac-vib mvb +chemical/x-ncbi-asn1 asn +chemical/x-ncbi-asn1-ascii prt ent +chemical/x-ncbi-asn1-binary val aso +chemical/x-ncbi-asn1-spec asn +chemical/x-pdb pdb ent +chemical/x-rosdal ros +chemical/x-swissprot sw +chemical/x-vamas-iso14976 vms +chemical/x-vmd vmd +chemical/x-xtel xtel +chemical/x-xyz xyz + +image/cgm +image/g3fax +image/gif gif +image/ief ief +image/jpeg jpeg jpg jpe +image/naplps +image/pcx pcx +image/png png +image/prs.btif +image/prs.pti +image/svg+xml svg svgz +image/tiff tiff tif +image/vnd.cns.inf2 +image/vnd.djvu djvu djv +image/vnd.dwg +image/vnd.dxf +image/vnd.fastbidsheet +image/vnd.fpx +image/vnd.fst +image/vnd.fujixerox.edmics-mmr +image/vnd.fujixerox.edmics-rlc +image/vnd.mix +image/vnd.net-fpx +image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff +image/x-cmu-raster ras +image/x-coreldraw cdr +image/x-coreldrawpattern pat +image/x-coreldrawtemplate cdt +image/x-corelphotopaint cpt +image/x-icon ico +image/x-jg art +image/x-jng jng +image/x-ms-bmp bmp +image/x-photoshop psd +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd + +inode/chardevice +inode/blockdevice +inode/directory-locked +inode/directory +inode/fifo +inode/socket + +message/delivery-status +message/disposition-notification +message/external-body +message/http +message/s-http +message/news +message/partial +message/rfc822 + +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf +model/vnd.flatland.3dml +model/vnd.gdl +model/vnd.gs-gdl +model/vnd.gtw +model/vnd.mts +model/vnd.vtu +model/vrml wrl vrml + +multipart/alternative +multipart/appledouble +multipart/byteranges +multipart/digest +multipart/encrypted +multipart/form-data +multipart/header-set +multipart/mixed +multipart/parallel +multipart/related +multipart/report +multipart/signed +multipart/voice-message + +text/calendar ics icz +text/comma-separated-values csv +text/css css +text/directory +text/english +text/enriched +text/h323 323 +text/html html htm shtml +text/iuls uls +text/mathml mml +text/parityfec +text/plain asc txt text diff pot sql +text/prs.lines.tag +text/rfc822-headers +text/richtext rtx +text/rtf rtf +text/scriptlet sct wsc +text/t140 +text/texmacs tm ts +text/tab-separated-values tsv +text/uri-list +text/vnd.abc +text/vnd.curl +text/vnd.DMClientScript +text/vnd.flatland.3dml +text/vnd.fly +text/vnd.fmi.flexstor +text/vnd.in3d.3dml +text/vnd.in3d.spot +text/vnd.IPTC.NewsML +text/vnd.IPTC.NITF +text/vnd.latex-z +text/vnd.motorola.reflex +text/vnd.ms-mediapackage +text/vnd.sun.j2me.app-descriptor jad +text/vnd.wap.si +text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-bibtex bib +text/x-boo boo +text/x-c++hdr h++ hpp hxx hh +text/x-c++src c++ cpp cxx cc +text/x-chdr h +text/x-component htc +text/x-crontab +text/x-csh csh +text/x-csrc c +text/x-dsrc d +text/x-haskell hs +text/x-java java +text/x-literate-haskell lhs +text/x-makefile +text/x-moc moc +text/x-pascal p pas +text/x-pcs-gcd gcd +text/x-perl pl pm +text/x-python py +text/x-server-parsed-html +text/x-setext etx +text/x-sh sh +text/x-tcl tcl tk +text/x-tex tex ltx sty cls +text/x-vcalendar vcs +text/x-vcard vcf + +video/dl dl +video/dv dif dv +video/fli fli +video/gl gl +video/mpeg mpeg mpg mpe +video/mp4 mp4 +video/quicktime qt mov +video/mp4v-es +video/parityfec +video/pointer +video/vnd.fvt +video/vnd.motorola.video +video/vnd.motorola.videop +video/vnd.mpegurl mxu +video/vnd.mts +video/vnd.nokia.interleaved-multimedia +video/vnd.vivo +video/x-la-asf lsf lsx +video/x-mng mng +video/x-ms-asf asf asx +video/x-ms-wm wm +video/x-ms-wmv wmv +video/x-ms-wmx wmx +video/x-ms-wvx wvx +video/x-msvideo avi +video/x-sgi-movie movie + +x-conference/x-cooltalk ice + +x-world/x-vrml vrm vrml wrl diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options new file mode 100644 index 0000000000..32ffd87393 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options @@ -0,0 +1,95 @@ +#### Debugging options for org.eclipse.osgi + +# Turn on general debugging for org.eclipse.osgi +org.eclipse.osgi/debug=true +# Prints out class loading debug information +org.eclipse.osgi/debug/loader=false +# Prints out event (FrameworkEvent/BundleEvent/ServiceEvent) and listener debug information +org.eclipse.osgi/debug/events=false +# Prints out OSGi service debug information (registration/getting/ungetting etc.) +org.eclipse.osgi/debug/services=false +# Prints out bundle manifest parsing debug information +org.eclipse.osgi/debug/manifest=false +# Prints out LDAP filter debug information +org.eclipse.osgi/debug/filter=false +# Prints out security (PermissionAdmin service) debug information +org.eclipse.osgi/debug/security=false +# Prints out start level service debug information +org.eclipse.osgi/debug/startlevel=true +# Prints out package admin service debug information +org.eclipse.osgi/debug/packageadmin=false +# Prints out timing information for bundle activation +org.eclipse.osgi/debug/bundleTime=false +# Debug the loading of message bundles +org.eclipse.osgi/debug/messageBundles=false + +# Eclipse adaptor options +org.eclipse.osgi/eclipseadaptor/debug = false +org.eclipse.osgi/eclipseadaptor/debug/location = false +org.eclipse.osgi/eclipseadaptor/debug/platformadmin=false +org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver=false +org.eclipse.osgi/eclipseadaptor/converter/debug = false + +### OSGi resolver options +# Turns on debugging for the resolver +org.eclipse.osgi/resolver/debug = false +# Prints out wiring information after the resolver has completed the resolve process +org.eclipse.osgi/resolver/wiring = false +# Prints out Import-Package information +org.eclipse.osgi/resolver/imports = false +# Prints out Require-Bundle information +org.eclipse.osgi/resolver/requires = false +# Prints out package grouping information form the "uses" clause +org.eclipse.osgi/resolver/grouping = false +# Prints out cycle information +org.eclipse.osgi/resolver/cycles = false +# Prints out Eclipse-GenericRequire information +org.eclipse.osgi/resolver/generics = false + +#### Profile settings +org.eclipse.osgi/profile/startup = false +org.eclipse.osgi/profile/benchmark = false +org.eclipse.osgi/profile/debug = true + +# Override the default implemenation +org.eclipse.osgi/profile/impl = org.eclipse.osgi.internal.profile.DefaultProfileLogger + +# Append all profile messages to the filename specified +org.eclipse.osgi/defaultprofile/logfilename = + +# Output all profile log messages synchronously to the jvm console. +# By default, all log messages are cached until the log buffer is +# requested. +org.eclipse.osgi/defaultprofile/logsynchronously = false + +# Specify the size of the default profile implementation log buffer. +org.eclipse.osgi/defaultprofile/buffersize = 256 + +#### Monitoring settings +# monitor class loading +org.eclipse.osgi/monitor/classes=false + +# monitor bundle activation +org.eclipse.osgi/monitor/activation=false + +# monitor resource bundle (*.properties) loading +org.eclipse.osgi/monitor/resources=false + + +#### Trace settings +# trace class loading - snapshot the execution stack when a class is loaded +org.eclipse.osgi/trace/classLoading=false + +# trace location - file in which execution traces are written +org.eclipse.osgi/trace/filename=runtime.traces + +# trace filters - Java properties file defining which classes should +# be traced (if trace/classLoading is true) +# File format: +# plugins= +# packages= +# Note that there may be many 'plugins' and 'packages' lines in one file. +org.eclipse.osgi/trace/filters=trace.properties + +# trace bundle activation - snapshot the execution stack when a bundle is activated +org.eclipse.osgi/trace/activation=false diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml new file mode 100644 index 0000000000..9793d0b47d --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml @@ -0,0 +1,70 @@ + + + + + + STANDALONE + + + 2 + + + + org.wso2.carbon.ntask.core.impl.RoundRobinTaskLocationResolver + + + + + + + https://localhost:9448 + + + https://localhost:9443 + + + admin + + + admin + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties new file mode 100644 index 0000000000..957603a504 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties @@ -0,0 +1,33 @@ +# +# Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. +# +# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. +# +# Licensed under the Entgra Commercial License, Version 1.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://entgra.io/licenses/entgra-commercial/1.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. +# +log4j.rootLogger=DEBUG, console, Default +#Automation file appender +log4j.appender.Default=org.apache.log4j.RollingFileAppender +log4j.appender.Default.File=target/logs/automation.log +log4j.appender.Default.Append=true +log4j.appender.Default.MaxFileSize=10MB +log4j.appender.Default.MaxBackupIndex=10 +log4j.appender.Default.layout=org.apache.log4j.PatternLayout +log4j.appender.Default.layout.ConversionPattern=%d{ISO8601} %-5p [%c] [%t] - %m%n +#Automation console appender +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.Target=System.out +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%c] [%t] - %m%n +log4j.logger.io.entgra=TRACE \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml new file mode 100644 index 0000000000..ffe6d66224 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml @@ -0,0 +1,109 @@ + + + + + + + + wso2registry + false + true + / + + + jdbc:h2:./target/databasetest/CARBON_TEST + + org.h2.Driver + 80 + 60000 + 5 + + + + + + + + + + + + false + + + + true + true + true + true + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml new file mode 100644 index 0000000000..327ac142bb --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml @@ -0,0 +1,76 @@ + + + + + + + + + + 5 + + + + + 10 + + /carbon/admin/login.jsp + carbonServer + https://localhost:9443/samlsso + urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml new file mode 100644 index 0000000000..ac237a2b3a --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml @@ -0,0 +1,36 @@ + + + + + + + WEB-INF/web.xml + + + + + + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml new file mode 100644 index 0000000000..3288cfb01c --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml @@ -0,0 +1,62 @@ + + + + + + + bridgeservlet + Carbon Bridge Servlet + Carbon Bridge Servlet + org.wso2.carbon.tomcat.ext.servlet.DelegationServlet + + 1 + + + bridgeservlet + /* + + + + bridgeservlet + *.jsp + + + + + CharsetFilter + org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter + + requestEncoding + UTF-8 + + + + + CharsetFilter + /* + + + + 15 + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml new file mode 100644 index 0000000000..5ba201f26d --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml new file mode 100644 index 0000000000..1df2d7e53a --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/web.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/web.xml new file mode 100644 index 0000000000..765febb1ad --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/tomcat/web.xml @@ -0,0 +1,1223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + default + org.apache.catalina.servlets.DefaultServlet + + debug + 0 + + + sendfileSize + -1 + + + listings + false + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jsp + org.apache.jasper.servlet.JspServlet + + fork + false + + + xpoweredBy + false + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jsp + *.jsp + + + + jsp + *.jspx + + + + default + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 30 + + + + + + + + + + + + abs + audio/x-mpeg + + + ai + application/postscript + + + aif + audio/x-aiff + + + aifc + audio/x-aiff + + + aiff + audio/x-aiff + + + aim + application/x-aim + + + art + image/x-jg + + + asf + video/x-ms-asf + + + asx + video/x-ms-asf + + + au + audio/basic + + + avi + video/x-msvideo + + + avx + video/x-rad-screenplay + + + bcpio + application/x-bcpio + + + bin + application/octet-stream + + + bmp + image/bmp + + + body + text/html + + + cdf + application/x-cdf + + + cer + application/x-x509-ca-cert + + + class + application/java + + + cpio + application/x-cpio + + + csh + application/x-csh + + + css + text/css + + + dib + image/bmp + + + doc + application/msword + + + dtd + application/xml-dtd + + + dv + video/x-dv + + + dvi + application/x-dvi + + + eps + application/postscript + + + etx + text/x-setext + + + exe + application/octet-stream + + + gif + image/gif + + + gtar + application/x-gtar + + + gz + application/x-gzip + + + hdf + application/x-hdf + + + hqx + application/mac-binhex40 + + + htc + text/x-component + + + htm + text/html + + + html + text/html + + + ief + image/ief + + + jad + text/vnd.sun.j2me.app-descriptor + + + jar + application/java-archive + + + java + text/plain + + + jnlp + application/x-java-jnlp-file + + + jpe + image/jpeg + + + jpeg + image/jpeg + + + jpg + image/jpeg + + + js + application/javascript + + + jsf + text/plain + + + jspf + text/plain + + + kar + audio/x-midi + + + latex + application/x-latex + + + m3u + audio/x-mpegurl + + + mac + image/x-macpaint + + + man + application/x-troff-man + + + mathml + application/mathml+xml + + + me + application/x-troff-me + + + mid + audio/x-midi + + + midi + audio/x-midi + + + mif + application/x-mif + + + mov + video/quicktime + + + movie + video/x-sgi-movie + + + mp1 + audio/x-mpeg + + + mp2 + audio/x-mpeg + + + mp3 + audio/x-mpeg + + + mp4 + video/mp4 + + + mpa + audio/x-mpeg + + + mpe + video/mpeg + + + mpeg + video/mpeg + + + mpega + audio/x-mpeg + + + mpg + video/mpeg + + + mpv2 + video/mpeg2 + + + ms + application/x-wais-source + + + nc + application/x-netcdf + + + oda + application/oda + + + + odb + application/vnd.oasis.opendocument.database + + + + odc + application/vnd.oasis.opendocument.chart + + + + odf + application/vnd.oasis.opendocument.formula + + + + odg + application/vnd.oasis.opendocument.graphics + + + + odi + application/vnd.oasis.opendocument.image + + + + odm + application/vnd.oasis.opendocument.text-master + + + + odp + application/vnd.oasis.opendocument.presentation + + + + ods + application/vnd.oasis.opendocument.spreadsheet + + + + odt + application/vnd.oasis.opendocument.text + + + + otg + application/vnd.oasis.opendocument.graphics-template + + + + oth + application/vnd.oasis.opendocument.text-web + + + + otp + application/vnd.oasis.opendocument.presentation-template + + + + ots + application/vnd.oasis.opendocument.spreadsheet-template + + + + ott + application/vnd.oasis.opendocument.text-template + + + + ogx + application/ogg + + + ogv + video/ogg + + + oga + audio/ogg + + + ogg + audio/ogg + + + spx + audio/ogg + + + flac + audio/flac + + + anx + application/annodex + + + axa + audio/annodex + + + axv + video/annodex + + + xspf + application/xspf+xml + + + pbm + image/x-portable-bitmap + + + pct + image/pict + + + pdf + application/pdf + + + pgm + image/x-portable-graymap + + + pic + image/pict + + + pict + image/pict + + + pls + audio/x-scpls + + + png + image/png + + + pnm + image/x-portable-anymap + + + pnt + image/x-macpaint + + + ppm + image/x-portable-pixmap + + + ppt + application/vnd.ms-powerpoint + + + pps + application/vnd.ms-powerpoint + + + ps + application/postscript + + + psd + image/x-photoshop + + + qt + video/quicktime + + + qti + image/x-quicktime + + + qtif + image/x-quicktime + + + ras + image/x-cmu-raster + + + rdf + application/rdf+xml + + + rgb + image/x-rgb + + + rm + application/vnd.rn-realmedia + + + roff + application/x-troff + + + rtf + application/rtf + + + rtx + text/richtext + + + sh + application/x-sh + + + shar + application/x-shar + + + + smf + audio/x-midi + + + sit + application/x-stuffit + + + snd + audio/basic + + + src + application/x-wais-source + + + sv4cpio + application/x-sv4cpio + + + sv4crc + application/x-sv4crc + + + svg + image/svg+xml + + + svgz + image/svg+xml + + + swf + application/x-shockwave-flash + + + t + application/x-troff + + + tar + application/x-tar + + + tcl + application/x-tcl + + + tex + application/x-tex + + + texi + application/x-texinfo + + + texinfo + application/x-texinfo + + + tif + image/tiff + + + tiff + image/tiff + + + tr + application/x-troff + + + tsv + text/tab-separated-values + + + txt + text/plain + + + ulw + audio/basic + + + ustar + application/x-ustar + + + vxml + application/voicexml+xml + + + xbm + image/x-xbitmap + + + xht + application/xhtml+xml + + + xhtml + application/xhtml+xml + + + xls + application/vnd.ms-excel + + + xml + application/xml + + + xpm + image/x-xpixmap + + + xsl + application/xml + + + xslt + application/xslt+xml + + + xul + application/vnd.mozilla.xul+xml + + + xwd + image/x-xwindowdump + + + vsd + application/x-visio + + + wav + audio/x-wav + + + + wbmp + image/vnd.wap.wbmp + + + + wml + text/vnd.wap.wml + + + + wmlc + application/vnd.wap.wmlc + + + + wmls + text/vnd.wap.wmlscript + + + + wmlscriptc + application/vnd.wap.wmlscriptc + + + wmv + video/x-ms-wmv + + + wrl + x-world/x-vrml + + + wspolicy + application/wspolicy+xml + + + Z + application/x-compress + + + z + application/x-compress + + + zip + application/zip + + + + + + + + + + + + + + + + + + index.html + index.htm + index.jsp + + + \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml new file mode 100644 index 0000000000..b754597ebc --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml @@ -0,0 +1,383 @@ + + + + + + true + admin + + admin + admin + + everyone + jdbc/WSO2CarbonDB + + + + + + + org.wso2.carbon.user.core.tenant.JDBCTenantManager + false + 100 + false + default + SHA-256 + true + true + true + false + ^[\S]{5,30}$ + Password length should be between 5 to 30 characters + + ^[\S]{5,30}$ + [a-zA-Z0-9._-|//]{3,30}$ + ^[\S]{3,30}$ + ^[^~!#$;%^*+={}\\|\\\\<>,\'\"]{3,30}$ + ^[\S]{3,30}$ + true + 100 + 100 + false + false + true + , + true + + + + + + + + + + + + + + + + + + + /permission + true + true + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml new file mode 100644 index 0000000000..af6e8d9ad4 --- /dev/null +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml new file mode 100644 index 0000000000..1fef0dfc2e --- /dev/null +++ b/components/subtype-mgt/pom.xml @@ -0,0 +1,39 @@ + + + + + org.wso2.carbon.devicemgt + carbon-devicemgt + 5.0.20-SNAPSHOT + ../../pom.xml + + + 4.0.0 + subtype-mgt + pom + Entgra IoT - Subtype Mgt + http://entgra.io + + + io.entgra.device.mgt.subtype.mgt + + + \ No newline at end of file diff --git a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml new file mode 100644 index 0000000000..d8fb04a212 --- /dev/null +++ b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml @@ -0,0 +1,107 @@ + + + + + + + org.wso2.carbon.devicemgt + carbon-devicemgt + 5.0.20-SNAPSHOT + ../../../pom.xml + + + 4.0.0 + io.entgra.device.mgt.subtype.mgt.feature + pom + Entgra IoT - Subtype Management Feature Impl + http://entgra.io + + This feature contains the core bundles required for Subtype management functionality + + + + + org.wso2.carbon.devicemgt + io.entgra.device.mgt.subtype.mgt + + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + io.entgra.device.mgt.subtype.mgt + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:true + + + + + + org.wso2.carbon.devicemgt:io.entgra.device.mgt.subtype.mgt:${carbon.device.mgt.version} + + + + + + + + + diff --git a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/build.properties b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/build.properties new file mode 100644 index 0000000000..9c86577d76 --- /dev/null +++ b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/p2.inf b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..7ab37b9d7d --- /dev/null +++ b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/src/main/resources/p2.inf @@ -0,0 +1 @@ +instructions.configure = \ \ No newline at end of file diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml new file mode 100644 index 0000000000..cb4d5ea62c --- /dev/null +++ b/features/subtype-mgt/pom.xml @@ -0,0 +1,41 @@ + + + + + + + carbon-devicemgt + org.wso2.carbon.devicemgt + 5.0.20-SNAPSHOT + ../../pom.xml + + + 4.0.0 + subtype-mgt-feature + pom + Entgra IoT - Subtype Management Feature + http://entgra.io + + + io.entgra.device.mgt.subtype.mgt.feature + + + diff --git a/pom.xml b/pom.xml index baed2c7543..cdbff6a866 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,7 @@ components/analytics-mgt components/webapp-authenticator-framework components/task-mgt + components/subtype-mgt features/device-mgt features/apimgt-extensions features/application-mgt @@ -60,6 +61,7 @@ features/analytics-mgt features/webapp-authenticator-framework features/task-mgt + features/subtype-mgt @@ -376,6 +378,20 @@ ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + io.entgra.device.mgt.subtype.mgt + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + io.entgra.device.mgt.subtype.mgt.feature + zip + ${carbon.device.mgt.version} + + + org.wso2.carbon @@ -2091,6 +2107,10 @@ 1.1.wso2v1 1.9.0 + + 20220924 + 2.4.5 + 1.60.0.wso2v1 1.60.0.wso2v1 From 680992f88c7b7277f389de56c8b9f08b3f4b690e Mon Sep 17 00:00:00 2001 From: kavindya_devindi Date: Wed, 8 Mar 2023 10:37:56 +0530 Subject: [PATCH 02/29] Update license headers --- .../io.entgra.device.mgt.subtype.mgt/pom.xml | 13 ++++++------- .../cache/GetDeviceSubTypeCacheLoader.java | 13 ++++++------- .../mgt/subtype/mgt/dao/DeviceSubTypeDAO.java | 13 ++++++------- .../mgt/dao/DeviceSubTypeDAOFactory.java | 13 ++++++------- .../mgt/dao/impl/DeviceSubTypeDAOImpl.java | 13 ++++++------- .../dao/impl/DeviceSubTypeMySQLDAOImpl.java | 13 ++++++------- .../mgt/dao/util/ConnectionManagerUtil.java | 13 ++++++------- .../mgt/subtype/mgt/dao/util/DAOUtil.java | 13 ++++++------- .../mgt/subtype/mgt/dto/DeviceSubType.java | 13 ++++++------- .../mgt/dto/DeviceSubTypeCacheKey.java | 13 ++++++------- .../mgt/exception/BadRequestException.java | 13 ++++++------- .../mgt/exception/DBConnectionException.java | 13 ++++++------- .../mgt/exception/SubTypeMgtDAOException.java | 13 ++++++------- .../exception/SubTypeMgtPluginException.java | 13 ++++++------- .../mgt/impl/DeviceSubTypeServiceImpl.java | 13 ++++++------- .../internal/DeviceSubTypeMgtDataHolder.java | 13 ++++++------- .../DeviceSubTypeMgtServiceComponent.java | 13 ++++++------- .../subtype/mgt/spi/DeviceSubTypeService.java | 13 ++++++------- .../mgt/util/DeviceSubTypeMgtUtil.java | 13 ++++++------- .../mgt/subtype/mgt/DAONegativeTest.java | 13 ++++++------- .../device/mgt/subtype/mgt/DAOTest.java | 13 ++++++------- .../mgt/subtype/mgt/DataSourceConfig.java | 13 ++++++------- .../mgt/subtype/mgt/ServiceNegativeTest.java | 14 ++++++-------- .../device/mgt/subtype/mgt/ServiceTest.java | 13 ++++++------- .../device/mgt/subtype/mgt/TestUtils.java | 13 ++++++------- .../mgt/mock/BaseDeviceSubTypePluginTest.java | 13 ++++++------- .../mgt/subtype/mgt/mock/MockConnection.java | 13 ++++++------- .../mgt/subtype/mgt/mock/MockDataSource.java | 13 ++++++------- .../mgt/mock/MockDatabaseMetaData.java | 13 ++++++------- .../mgt/subtype/mgt/mock/MockResultSet.java | 13 ++++++------- .../mgt/subtype/mgt/mock/MockStatement.java | 13 ++++++------- .../repository/conf/axis2/axis2.xml | 13 ++++++------- .../repository/conf/axis2/axis2_client.xml | 13 ++++++------- .../repository/conf/axis2/tenant-axis2.xml | 13 ++++++------- .../carbon-home/repository/conf/carbon.xml | 13 ++++++------- .../repository/conf/cdm-config.xml | 13 ++++++------- .../conf/datasources/data-source-config.xml | 13 ++++++------- .../carboncontext-osgi-services.properties | 19 ++++++++----------- .../repository/conf/etc/config-validation.xml | 13 ++++++------- .../carbon-home/repository/conf/etc/jmx.xml | 13 ++++++------- .../conf/etc/logging-bridge.properties | 19 ++++++++----------- .../repository/conf/etc/tasks-config.xml | 13 ++++++------- .../repository/conf/log4j.properties | 19 ++++++++----------- .../carbon-home/repository/conf/registry.xml | 13 ++++++------- .../conf/security/authenticators.xml | 13 ++++++------- .../carbon-home/repository/conf/user-mgt.xml | 13 ++++++------- .../src/test/resources/testng.xml | 13 ++++++------- components/subtype-mgt/pom.xml | 13 ++++++------- .../pom.xml | 13 ++++++------- features/subtype-mgt/pom.xml | 13 ++++++------- 50 files changed, 306 insertions(+), 363 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml index 53b037ff52..4fa1a8b206 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml @@ -1,19 +1,18 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java index 3070f38c63..ebefb213a1 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java index 1b3ca0ce41..2838423e13 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAO.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java index d92fc28352..79ab3f304a 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/DeviceSubTypeDAOFactory.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java index 6d7dcf5e25..e1348b1f73 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java index defb15afa7..972d16e1c5 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeMySQLDAOImpl.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java index f6615254ed..7663ae94fc 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/ConnectionManagerUtil.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java index 187924f09a..0ab3f8e45c 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java index 6d93bafa48..b29b802f30 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java index 78d74ab89c..c1aa7eeab2 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java index 24cf90438a..57138e35f8 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/BadRequestException.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java index e5f3edec1c..ec2920d8fb 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/DBConnectionException.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java index 645d387b5b..d80793b778 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtDAOException.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java index b6ee6b6526..5b0c355184 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/exception/SubTypeMgtPluginException.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java index 368f39c8f8..d6e6eba6ea 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java index b804810f70..58652dfafb 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java index 32f197a380..ecf22a6581 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java index 1377d224f1..73afb32f70 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java index 7a96cd8581..2535266724 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java index 8806af6731..d1ff711262 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java index 8ead113a40..54a164a9aa 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java index 72ae35e131..1bb8afee84 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DataSourceConfig.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java index 5d0613ca62..bca0bc6c61 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java @@ -1,22 +1,20 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ - package io.entgra.device.mgt.subtype.mgt; import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java index a4e3de177d..93670db4ba 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java index 538b4be918..29016fda8a 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java index 892287fc8f..166bafc281 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java index 2a74c56146..2ce68a6ded 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockConnection.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java index 95502922f6..1fd43e0ab3 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDataSource.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java index 5472f93ded..0bf75cc2bb 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockDatabaseMetaData.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java index 75e0bca583..0a4208f634 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockResultSet.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java index c65ea9c476..44483abe1e 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/mock/MockStatement.java @@ -1,18 +1,17 @@ /* - * Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. + * Copyright (c) 2023, Entgra Pvt Ltd. (http://www.wso2.org) All Rights Reserved. * - * Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. - * - * Licensed under the Entgra Commercial License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. + * Entgra Pvt Ltd. 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 * - * https://entgra.io/licenses/entgra-commercial/1.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml index 6043bbcf91..a30b6dac01 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml @@ -1,18 +1,17 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml index 6757e67de3..4dc7e2cbfd 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml @@ -1,18 +1,17 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml index e54e1107bb..a1e4a378f4 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml @@ -1,20 +1,19 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml index fbc7e4b021..7a6bf0858b 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/carbon.xml @@ -1,20 +1,19 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml index 0e53e2b7d6..4abba45769 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -1,19 +1,18 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index b2f8c12a6f..e3b9d0ae6b 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -1,19 +1,18 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties index eb0f2e8493..305bda8f82 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties @@ -1,20 +1,17 @@ # -# Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. +# Copyright 2023 WSO2, Inc. (http://wso2.com) # -# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. -# -# Licensed under the Entgra Commercial License, Version 1.0 (the "License"); +# Licensed 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 # -# https://entgra.io/licenses/entgra-commercial/1.0 +# 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. +# 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. # #osgi.service.1 = org.wso2.carbon.client.configcontext.provider.Axis2ClientConfigContextProvider diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml index 5cb755588f..ed37b59ec9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml @@ -1,19 +1,18 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml index b9f2bed216..0e012b5d2e 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/jmx.xml @@ -1,18 +1,17 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties index 8385072039..5fd86209df 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties @@ -1,20 +1,17 @@ # -# Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. +# Copyright 2023 WSO2, Inc. (http://wso2.com) # -# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. -# -# Licensed under the Entgra Commercial License, Version 1.0 (the "License"); +# Licensed 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 # -# https://entgra.io/licenses/entgra-commercial/1.0 +# 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. +# 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. # ############################################################ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml index 9793d0b47d..d5a392ca82 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml @@ -1,18 +1,17 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties index 957603a504..32f8b97483 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/log4j.properties @@ -1,20 +1,17 @@ # -# Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved. +# Copyright 2023 WSO2, Inc. (http://wso2.com) # -# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited. -# -# Licensed under the Entgra Commercial License, Version 1.0 (the "License"); +# Licensed 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 # -# https://entgra.io/licenses/entgra-commercial/1.0 +# 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. +# 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. # log4j.rootLogger=DEBUG, console, Default #Automation file appender diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml index ffe6d66224..944d391ea7 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/registry.xml @@ -1,20 +1,19 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml index 327ac142bb..674e8149fc 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/security/authenticators.xml @@ -1,20 +1,19 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml index b754597ebc..d54f7bbbf6 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/repository/conf/user-mgt.xml @@ -1,18 +1,17 @@ diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml index af6e8d9ad4..c245837db6 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/testng.xml @@ -1,18 +1,17 @@ diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 1fef0dfc2e..d2894ffb18 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -1,19 +1,18 @@ diff --git a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml index d8fb04a212..ac9e4962ef 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml @@ -1,19 +1,18 @@ diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index cb4d5ea62c..6c4f5489e2 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -1,19 +1,18 @@ From 9ab437a324db1e58e97f5164f6cf9ca9d4e78169 Mon Sep 17 00:00:00 2001 From: kavindya_devindi Date: Thu, 23 Mar 2023 08:00:55 +0530 Subject: [PATCH 03/29] remove power meter related things --- .../mgt/subtype/mgt/dao/util/DAOUtil.java | 4 - .../carbon-home/dbscripts/dm-db-h2.sql | 51 +++ .../resources/carbon-home/dbscripts/h2.sql | 382 ------------------ 3 files changed, 51 insertions(+), 386 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java index 0ab3f8e45c..61c1305923 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java @@ -19,8 +19,6 @@ package io.entgra.device.mgt.subtype.mgt.dao.util; import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.sql.ResultSet; import java.sql.SQLException; @@ -29,8 +27,6 @@ import java.util.List; public class DAOUtil { - private static final Log log = LogFactory.getLog(DAOUtil.class); - public static DeviceSubType loadDeviceSubType(ResultSet rs) throws SQLException { DeviceSubType deviceSubType = new DeviceSubType() { @Override diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 52b28e950d..2f5ae6c677 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -725,6 +725,57 @@ CREATE TABLE IF NOT EXISTS DM_GEOFENCE_EVENT_MAPPING ( -- END OF DM_GEOFENCE_GROUP_MAPPING TABLE-- +-- DM_EXT_GROUP_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_EXT_GROUP_MAPPING ( + ID INT NOT NULL AUTO_INCREMENT, + TRACCAR_GROUP_ID INT DEFAULT 0, + GROUP_ID INT NOT NULL, + TENANT_ID INT NOT NULL, + STATUS INT DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_EXT_GROUP_MAPPING TABLE-- + +-- END OF DM_EXT_DEVICE_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( + ID INT NOT NULL AUTO_INCREMENT, + TRACCAR_DEVICE_ID INT DEFAULT 0, + DEVICE_ID INT NOT NULL, + TENANT_ID INT NOT NULL, + STATUS INT DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_EXT_DEVICE_MAPPING TABLE-- + +-- END OF DM_EXT_PERMISSION_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( + TRACCAR_DEVICE_ID INT DEFAULT 0, + TRACCAR_USER_ID INT DEFAULT 0 +); +-- END OF DM_EXT_PERMISSION_MAPPING TABLE-- + +-- DYNAMIC TASK TABLES-- +CREATE TABLE IF NOT EXISTS DYNAMIC_TASK ( + DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL, + NAME VARCHAR(300) DEFAULT NULL , + CRON VARCHAR(8000) DEFAULT NULL, + IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE, + TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (DYNAMIC_TASK_ID) +); + +CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( + DYNAMIC_TASK_ID INTEGER NOT NULL, + PROPERTY_NAME VARCHAR(100) DEFAULT 0, + PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, + TENANT_ID VARCHAR(100), + PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID), + CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES + DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE +); +-- END OF DYNAMIC TASK TABLE-- + -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql index 0d00a78a22..0ed4a1d638 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql @@ -1,326 +1,3 @@ --- ----------------------------------------------------- --- Table `POWER_METER_DEVICE` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `POWER_METER_DEVICE` ( - `ID` INTEGER AUTO_INCREMENT NOT NULL, - `SERIAL` VARCHAR(45) NOT NULL, - `IP_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, - `SIM_NUMBER` VARCHAR(45) NULL DEFAULT NULL, - `SUB_TYPE_ID` INT NOT NULL, - `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, - `NODE_TYPE` VARCHAR(45) NULL DEFAULT NULL, - `CATEGORY` VARCHAR(45) NULL DEFAULT NULL, - `BRANCH` VARCHAR(45) NULL DEFAULT NULL, - `DEPOT` VARCHAR(45) NULL DEFAULT NULL, - `SUBSTATION_ID` VARCHAR(45) NULL DEFAULT NULL, - `HAS_EXPORT` VARCHAR(5) NULL DEFAULT NULL, - `COM_MODULE_IMEI` VARCHAR(45) NULL DEFAULT NULL, - `HAS_E_BILLING` VARCHAR(5) NULL DEFAULT NULL, - `IS_FEEDER_END` VARCHAR(5) NULL DEFAULT NULL, - `POLE_ID` VARCHAR(45) NULL DEFAULT NULL, - `METER_FW_VER` VARCHAR(45) NULL DEFAULT NULL, - `ASSIGNED_ON` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`ID`, `SERIAL`)); - --- ----------------------------------------------------- --- Table `COMMUNICATION_MODULE` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `COMMUNICATION_MODULE` ( - `IMEI` VARCHAR(45) NOT NULL, - `SIM_IMSI` VARCHAR(45) NULL DEFAULT NULL, - `FW_VERSION` INT NULL DEFAULT 0, - `SUB_TYPE_ID` INT NOT NULL, - `SMS_PIN` VARCHAR(45) NULL DEFAULT NULL, - `BRANCH` VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (`IMEI`)); - --- ----------------------------------------------------- --- Table `METER_AUTHENTICATION_INFO` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `METER_AUTHENTICATION_INFO` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `CLIENT_ADDRESS` INT NOT NULL, - `AUTHENTICATION` VARCHAR(100) NOT NULL, - `USER_ID` INT NOT NULL, - `PASSWORD` VARCHAR(100) NOT NULL, - `METER_SERIAL_ID` VARCHAR(45) NOT NULL, - PRIMARY KEY (`ID`)); - -CREATE INDEX IDX_METER_AUTHENTICATION_INFO -ON METER_AUTHENTICATION_INFO(CLIENT_ADDRESS, METER_SERIAL_ID); - --- ----------------------------------------------------- --- Table `METER_READINGS` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `METER_READINGS` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `OPERATION_ID` INT NOT NULL, - `OPERATION_CODE` VARCHAR(45) NOT NULL, - `SUB_TYPE_ID` INT NOT NULL, - `NODE_TYPE` VARCHAR(45) NULL DEFAULT NULL, - `CATEGORY` VARCHAR(45) NULL DEFAULT NULL, - `HAS_EXPORT` BOOLEAN NULL DEFAULT NULL, - `HAS_E_BILLING` BOOLEAN NULL DEFAULT NULL, - `BRANCH` VARCHAR(45) NULL DEFAULT NULL, - `DEPOT` VARCHAR(45) NULL DEFAULT NULL, - `SUBSTATION_ID` VARCHAR(45) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NOT NULL, - `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, - `RESPONSE` BLOB NOT NULL, - `TIMESTAMP` BIGINT(15) NOT NULL, - `IS_PARTIAL_RESULT` BOOLEAN NOT NULL DEFAULT FALSE, - PRIMARY KEY (`ID`)); - --- --- Table structure for table `LAST_METER_READING` --- -CREATE TABLE IF NOT EXISTS LAST_METER_READING ( - SERIAL VARCHAR(45) NOT NULL, - OPERATION_ID INTEGER NOT NULL, - SUB_TYPE_ID INT NOT NULL DEFAULT 0, - NODE_TYPE VARCHAR(45) NULL DEFAULT NULL, - CATEGORY VARCHAR(45) NULL DEFAULT NULL, - HAS_EXPORT BOOLEAN NULL DEFAULT NULL, - HAS_E_BILLING BOOLEAN NULL DEFAULT NULL, - BRANCH VARCHAR(45) NULL DEFAULT NULL, - DEPOT VARCHAR(45) NULL DEFAULT NULL, - SUBSTATION_ID VARCHAR(45) NULL DEFAULT NULL, - CUSTOMER_REF VARCHAR(45) NULL DEFAULT NULL, - RESPONSE LONGBLOB NOT NULL, - LAST_READING_TIMESTAMP BIGINT NOT NULL, - PRIMARY KEY (SERIAL) -); - --- ----------------------------------------------------- --- Table `PROFILE_READINGS` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `PROFILE_READINGS` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `OPERATION_ID` INT NOT NULL, - `OBIS` VARCHAR(45) NULL DEFAULT NULL, - `SUB_TYPE_ID` INT NOT NULL, - `NODE_TYPE` VARCHAR(45) NULL DEFAULT NULL, - `CATEGORY` VARCHAR(45) NULL DEFAULT NULL, - `HAS_EXPORT` BOOLEAN NULL DEFAULT NULL, - `HAS_E_BILLING` BOOLEAN NULL DEFAULT NULL, - `BRANCH` VARCHAR(45) NULL DEFAULT NULL, - `DEPOT` VARCHAR(45) NULL DEFAULT NULL, - `SUBSTATION_ID` VARCHAR(45) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NOT NULL, - `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, - `PROFILE_DATA` BLOB NOT NULL, - `TIMESTAMP` BIGINT(15) NOT NULL, - PRIMARY KEY (`ID`)); - --- ----------------------------------------------------- --- Table `METER_INSTALL` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `METER_INSTALL` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `SERIAL` VARCHAR(45) NOT NULL, - `USERNAME` VARCHAR(45) NULL DEFAULT NULL, - `JOB_ID` VARCHAR(45) NULL DEFAULT NULL, - `LAB_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `COM_MODULE_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `TERMINAL_COVER_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `METER_ENCLOSURE_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `PRINTED_SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, - `IMPORT_READING` DOUBLE DEFAULT 0, - `EXPORT_READING` DOUBLE DEFAULT 0, - `READING_TIMESTAMP` BIGINT(15) DEFAULT 0, - `TIMESTAMP` TIMESTAMP NOT NULL, - PRIMARY KEY (`ID`)); - --- ----------------------------------------------------- --- Table `METER_UNINSTALL` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `METER_UNINSTALL` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `SERIAL` VARCHAR(45) NOT NULL, - `USERNAME` VARCHAR(45) NULL DEFAULT NULL, - `JOB_ID` VARCHAR(45) NULL DEFAULT NULL, - `LAB_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `COM_MODULE_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `TERMINAL_COVER_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `METER_ENCLOSURE_SEAL` VARCHAR(45) NULL DEFAULT NULL, - `PRINTED_SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `CUSTOMER_REF` VARCHAR(45) NULL DEFAULT NULL, - `IMPORT_READING` DOUBLE DEFAULT 0, - `EXPORT_READING` DOUBLE DEFAULT 0, - `READING_TIMESTAMP` BIGINT(15) DEFAULT 0, - `TIMESTAMP` TIMESTAMP NOT NULL, - PRIMARY KEY (`ID`)); - --- ----------------------------------------------------- --- Table `RSSI_LEVEL` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `RSSI_LEVEL` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `IMEI` VARCHAR(45) NOT NULL, - `SIM_IMSI` VARCHAR(45) NULL DEFAULT NULL, - `FW_VERSION` INT NULL DEFAULT 0, - `COM_TYPE_ID` INT NOT NULL, - `RSSI` INT NULL DEFAULT 0, - `NETWORK` VARCHAR(45) NULL DEFAULT NULL, - `CELL_ID` VARCHAR(45) NULL DEFAULT NULL, - `LAC` VARCHAR(45) NULL DEFAULT NULL, - `RSRP` DECIMAL (5, 2) NULL DEFAULT 0, - `RSRQ` DECIMAL (5, 2) NULL DEFAULT 0, - `SNR` DECIMAL (5, 2) NULL DEFAULT 0, - `PCI` INT NULL DEFAULT 0, - `TRANSPORT` VARCHAR(45) NULL DEFAULT NULL, - `TIMESTAMP` BIGINT(15) NOT NULL, - PRIMARY KEY (`ID`)); - --- ----------------------------------------------------- --- Table `REQUEST` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `REQUEST` ( - `ID` int NOT NULL AUTO_INCREMENT, - `DUE_DATE` bigint DEFAULT '0', - `REQUESTED_BY` varchar(100) NOT NULL, - `REQUESTED_DATE` bigint DEFAULT '0', - `STATUS` varchar(45) NOT NULL, - `BRANCH` varchar(45) DEFAULT NULL, - `REMARKS` varchar(255) NOT NULL, - `REQUEST_TYPE` int NOT NULL, - PRIMARY KEY (`ID`) -) ; - --- ----------------------------------------------------- --- Table `METER_ASSIGNMENT_REQUEST` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `METER_ASSIGNMENT_REQUEST` ( - `ID` int NOT NULL, - `SUB_TYPE_ID` int NOT NULL, - `PRIMARY_CT_RATIO` float DEFAULT '0', - `SECONDARY_CT_RATIO` float DEFAULT '0', - `PRIMARY_PT_RATIO` float DEFAULT '0', - `SECONDARY_PT_RATIO` float DEFAULT '0', - `NODE_TYPE` varchar(45) DEFAULT NULL, - `REQUESTED_COUNT` int NOT NULL, - `ACCEPTED_COUNT` int DEFAULT NULL, - `ASSIGNED_COUNT` int DEFAULT NULL, - `SUBSTATION_ID` varchar(45) DEFAULT NULL, - `CUSTOMER_REF` varchar(45) DEFAULT NULL, - `DEPOT` VARCHAR(45) DEFAULT NULL, - `PURPOSE` VARCHAR(50) DEFAULT NULL, - `ADDRESS` VARCHAR(255) DEFAULT NULL, - `DESCRIPTION` VARCHAR(100) DEFAULT NULL, - PRIMARY KEY (`ID`), - CONSTRAINT `fk_ASSIGNMENT_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) -) ; - --- ----------------------------------------------------- --- Table `DISCONNECTION_REQUEST` --- ------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `DISCONNECTION_REQUEST` ( - `ID` int NOT NULL, - `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, - PRIMARY KEY (`ID`), - CONSTRAINT `fk_DISCONNECTION_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) -) ; - --- ----------------------------------------------------- --- Table `FIELD_TEST_REQUEST` --- ------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `FIELD_TEST_REQUEST` ( - `ID` int NOT NULL, - `TEAM` varchar(255) DEFAULT NULL, - `SCHEDULED_DATE` bigint DEFAULT '0', - `RESULT` varchar(50) DEFAULT NULL, - `ATTACHMENT` blob, - PRIMARY KEY (`ID`), - CONSTRAINT `fk_ASSIGNMENT_FIELD_TEST_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) -); - --- ----------------------------------------------------- --- Table `LOAD_PROFILE_REQUEST` --- ------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `LOAD_PROFILE_REQUEST` ( - `ID` int NOT NULL, - `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, - `START_DATE` bigint DEFAULT '0', - `END_DATE` bigint DEFAULT '0', - PRIMARY KEY (`ID`), - CONSTRAINT `fk_LOAD_PROFILE_REQUEST_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) -); - --- ----------------------------------------------------- --- Table `READOUT_REQUEST` --- ------------------------------------------------------- - -CREATE TABLE `READOUT_REQUEST` ( - `ID` int NOT NULL, - `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, - PRIMARY KEY (`ID`), - CONSTRAINT `fk_READUOT_REQUEST_REQUEST_REQUEST` FOREIGN KEY (`ID`) REFERENCES `REQUEST` (`ID`) -); - --- ----------------------------------------------------- --- Table `COM_MODULE_REQUEST` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `COM_MODULE_REQUEST` ( - `ID` INT NOT NULL, - `MODULE_TYPE` VARCHAR(45) NOT NULL, - `REQUESTED_COUNT` INT NOT NULL, - `ACCEPTED_COUNT` INT DEFAULT NULL, - `ASSIGNED_COUNT` INT DEFAULT NULL, - PRIMARY KEY (`ID`), - CONSTRAINT `fk_COM_MODULE_REQUEST_REQUEST` FOREIGN KEY (`ID`) - REFERENCES `REQUEST` (`ID`) -); - --- ----------------------------------------------------- --- Table `RECONNECTION_REQUEST` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `RECONNECTION_REQUEST` ( - `ID` int NOT NULL, - `ACTIVITY_ID` VARCHAR(45) DEFAULT NULL, - PRIMARY KEY (`ID`), - CONSTRAINT `fk_RECONNECTION_REQUEST_REQUEST` FOREIGN KEY (`ID`) - REFERENCES `REQUEST` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION -); - - ------------------------------------------------------ --- Table `REQUEST_LIFECYCLE_EVENT` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `REQUEST_LIFECYCLE_EVENT` ( - `ID` int NOT NULL AUTO_INCREMENT, - `REQUEST_ID` int NOT NULL, - `UPDATED_BY` varchar(100) NOT NULL, - `UPDATED_DATE` bigint DEFAULT '0', - `STATUS` varchar(45) NOT NULL, - `REMARKS` varchar(200) DEFAULT NULL, - PRIMARY KEY (`ID`), - CONSTRAINT `fk_REQUEST_LIFECYCLE_EVENT_REQUEST` FOREIGN KEY (`REQUEST_ID`) REFERENCES `REQUEST` (`ID`) -) ; - - --- ----------------------------------------------------- --- Table `DEVICE_EVENTS` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `PROCESSED_DEVICE_EVENTS` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `METER_SERIAL` VARCHAR(45), - `IP_ADDRESS` VARCHAR(45), - `NUMBER` VARCHAR(45), - `TYPE` VARCHAR(45) NOT NULL, - `KEY` VARCHAR(100) NOT NULL, - `VALUE` VARCHAR(100) NOT NULL, - `EVENT` VARCHAR(45) NOT NULL, - `TIMESTAMP` BIGINT(15) DEFAULT 0, - PRIMARY KEY (`ID`)); - -- ----------------------------------------------------- -- Table `DM_DEVICE_SUB_TYPE` -- ----------------------------------------------------- @@ -334,32 +11,6 @@ CREATE TABLE IF NOT EXISTS `PROCESSED_DEVICE_EVENTS` ( PRIMARY KEY (`SUB_TYPE_ID`,`DEVICE_TYPE`) ); - -- ----------------------------------------------------- --- Table `OPERATION_TEMPLATE` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `OPERATION_TEMPLATE`( - `TEMPLATE_ID` INT NOT NULL AUTO_INCREMENT, - `SUB_TYPE_ID` INT NOT NULL, - `OPERATION_CODE` VARCHAR(100) NOT NULL, - `OPERATION_DEFINITION` TEXT DEFAULT NULL, - PRIMARY KEY (`TEMPLATE_ID`) -); - --- ----------------------------------------------------- --- Table `GENERIC_METER_REGISTER` --- ----------------------------------------------------- - -CREATE TABLE IF NOT EXISTS `GENERIC_METER_REGISTER`( - `RRPK_ID` VARCHAR(100) NOT NULL, - `DESCRIPTION` VARCHAR(100) NOT NULL, - `UNIT` VARCHAR(45) NULL DEFAULT NULL, - `ORDER` INT NOT NULL, - PRIMARY KEY (`RRPK_ID`) -); - - - -- ----------------------------------------------------- -- Sample data for DAO test cases -- ----------------------------------------------------- @@ -375,39 +26,6 @@ INSERT INTO DM_ENROLMENT(DEVICE_ID,OWNER,OWNERSHIP,STATUS,IS_TRANSFERRED,DATE_OF (1,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234), (2,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234), (3,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234); -INSERT INTO DM_DEVICE_PROPERTIES (DEVICE_TYPE_NAME,DEVICE_IDENTIFICATION,PROPERTY_NAME,PROPERTY_VALUE,TENANT_ID) VALUES -('sim','413012689159555','APN','LECOSMSTC',-1234), -('sim','413012689159555','IP_ADDRESS','192.168.118.111',-1234), -('sim','413012689159555','MOBILE_NO','+94713192111',-1234), -('sim','413012689159555','SUB_TYPE_ID','1',-1234), -('sim','413012689159555','token',NULL,-1234), -('communication-module','864495036647555','BRANCH','KOTTE',-1234), -('communication-module','864495036647555','FW_VERSION','6',-1234), -('communication-module','864495036647555','SIM_IMSI','413012689159555',-1234), -('communication-module','864495036647555','SIM_PIN','1234',-1234), -('communication-module','864495036647555','SUB_TYPE_ID','1',-1234), -('communication-module','864495036647555','token',NULL,-1234), -('power-meter','000019729555','BRANCH','KOTTE',-1234), -('power-meter','000019729555','CATEGORY','BILLING_BULK',-1234), -('power-meter','000019729555','COM_MODULE_IMEI','864495036647555',-1234), -('power-meter','000019729555','CUSTOMER_REF','0602297555',-1234), -('power-meter','000019729555','DEPOT','PITA-KOTTE',-1234), -('power-meter','000019729555','HAS_EXPORT','false',-1234), -('power-meter','000019729555','HAS_E_BILLING','false',-1234), -('power-meter','000019729555','IP_ADDRESS','192.168.118.111',-1234), -('power-meter','000019729555','IS_FEEDER_END','false',-1234), -('power-meter','000019729555','NODE_TYPE','BILLING',-1234), -('power-meter','000019729555','POLE_ID','NW55/5/15C',-1234), -('power-meter','000019729555','SIM_NUMBER','+94713192111',-1234), -('power-meter','000019729555','SUBSTATION_ID','AZ8555',-1234), -('power-meter','000019729555','SUB_TYPE_ID','1',-1234), -('power-meter','000019729555','token',NULL,-1234); - - --- INSERT INTO SIM_DEVICE (IMSI,IP_ADDRESS,MOBILE_NO,SUB_TYPE_ID,APN) VALUES ('413012689159555','10.217.55.155','+94713192111',1,'LECOSMSTC'); -INSERT INTO COMMUNICATION_MODULE(IMEI,SIM_IMSI,FW_VERSION,SUB_TYPE_ID,BRANCH,SMS_PIN) VALUES ('864495036647555','413012689159555',6,1,'KOTTE','1234'); -INSERT INTO POWER_METER_DEVICE (SERIAL,IP_ADDRESS,SIM_NUMBER,COM_MODULE_IMEI,SUB_TYPE_ID,CUSTOMER_REF,NODE_TYPE,CATEGORY,BRANCH,DEPOT,SUBSTATION_ID,HAS_EXPORT,HAS_E_BILLING,IS_FEEDER_END,POLE_ID,ASSIGNED_ON) -VALUES ('000019729555','192.168.118.111','+94713192111','864495036647555',1,'0602297555','BILLING','BILLING_BULK','KOTTE','PITA-KOTTE','AZ82555','false','false','false','NW55/5/15C',NULL); INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES (3,-1234,'Meter','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), From 0c0300e2fc4dbc17f4ec22b2d867e3549e29a0ba Mon Sep 17 00:00:00 2001 From: kavindya_devindi Date: Thu, 23 Mar 2023 08:04:31 +0530 Subject: [PATCH 04/29] add device subtype table in feature's dbscripts --- .../src/main/resources/dbscripts/cdm/h2.sql | 14 +++++++++++++- .../src/main/resources/dbscripts/cdm/mssql.sql | 15 ++++++++++++++- .../src/main/resources/dbscripts/cdm/mysql.sql | 12 ++++++++++++ .../src/main/resources/dbscripts/cdm/oracle.sql | 12 ++++++++++++ .../main/resources/dbscripts/cdm/postgresql.sql | 13 +++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index f383c5d5b9..1542733b82 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -786,4 +786,16 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ); --- END OF DYNAMIC TASK TABLE-- \ No newline at end of file +-- END OF DYNAMIC TASK TABLE-- + +-- DM_DEVICE_SUB_TYPE TABLE-- +CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( + TENANT_ID INT DEFAULT 0, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + SUB_TYPE_NAME VARCHAR(45) NOT NULL, + TYPE_DEFINITION TEXT NOT NULL, + PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) +); + +-- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 1c22ba25fc..292c25c4f1 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -753,4 +753,17 @@ CREATE TABLE DYNAMIC_TASK_PROPERTIES ( CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ); --- END OF DYNAMIC TASK TABLE-- \ No newline at end of file +-- END OF DYNAMIC TASK TABLE-- + +-- DM_DEVICE_SUB_TYPE TABLE-- +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_SUB_TYPE]') AND TYPE IN (N'U')) +CREATE TABLE DM_DEVICE_SUB_TYPE ( + TENANT_ID INT DEFAULT 0, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + SUB_TYPE_NAME VARCHAR(45) NOT NULL, + TYPE_DEFINITION TEXT NOT NULL, + PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) +); + +-- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 17c7460c97..f18484b048 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -851,3 +851,15 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; -- END OF DYNAMIC TASK TABLE-- + +-- DM_DEVICE_SUB_TYPE TABLE-- +CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( + TENANT_ID INT DEFAULT 0, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + SUB_TYPE_NAME VARCHAR(45) NOT NULL, + TYPE_DEFINITION TEXT NOT NULL, + PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) +) ENGINE=InnoDB; + +-- END OF DM_DEVICE_SUB_TYPE TABLE-- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index a5d3725548..bd83ae4e72 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1119,3 +1119,15 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; -- END OF DYNAMIC TASK TABLE-- + +-- DM_DEVICE_SUB_TYPE TABLE-- +CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( + TENANT_ID INT DEFAULT 0, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + SUB_TYPE_NAME VARCHAR(45) NOT NULL, + TYPE_DEFINITION TEXT NOT NULL, + PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) +) ENGINE=InnoDB; + +-- END OF DM_DEVICE_SUB_TYPE TABLE-- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 731f086c61..f0ad9975b7 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -772,3 +772,16 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; -- END OF DYNAMIC TASK TABLE-- + + +-- DM_DEVICE_SUB_TYPE TABLE-- +CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( + TENANT_ID INT DEFAULT 0, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + SUB_TYPE_NAME VARCHAR(45) NOT NULL, + TYPE_DEFINITION TEXT NOT NULL, + PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) +) ENGINE=InnoDB; + +-- END OF DM_DEVICE_SUB_TYPE TABLE-- From 93ad9a3fd06e37ec0a2d25d905d177cc383c0442 Mon Sep 17 00:00:00 2001 From: kavindya_devindi Date: Wed, 19 Apr 2023 09:38:39 +0530 Subject: [PATCH 05/29] change subtype id as String field & add review changes --- .../cache/GetDeviceSubTypeCacheLoader.java | 2 +- .../mgt/subtype/mgt/dao/DeviceSubTypeDAO.java | 7 ++- .../mgt/dao/impl/DeviceSubTypeDAOImpl.java | 36 +++++------ .../mgt/subtype/mgt/dao/util/DAOUtil.java | 2 +- .../mgt/subtype/mgt/dto/DeviceSubType.java | 6 +- .../mgt/dto/DeviceSubTypeCacheKey.java | 6 +- .../mgt/impl/DeviceSubTypeServiceImpl.java | 60 ++++++++++++------- .../subtype/mgt/spi/DeviceSubTypeService.java | 7 ++- .../mgt/util/DeviceSubTypeMgtUtil.java | 4 +- .../mgt/subtype/mgt/DAONegativeTest.java | 4 +- .../device/mgt/subtype/mgt/DAOTest.java | 17 +++++- .../mgt/subtype/mgt/ServiceNegativeTest.java | 5 +- .../device/mgt/subtype/mgt/ServiceTest.java | 17 +++++- .../device/mgt/subtype/mgt/TestUtils.java | 20 +++---- .../carbon-home/dbscripts/dm-db-h2.sql | 2 +- .../resources/carbon-home/dbscripts/h2.sql | 16 +---- .../src/main/resources/dbscripts/cdm/h2.sql | 2 +- .../main/resources/dbscripts/cdm/mssql.sql | 2 +- .../main/resources/dbscripts/cdm/mysql.sql | 2 +- .../main/resources/dbscripts/cdm/oracle.sql | 2 +- .../resources/dbscripts/cdm/postgresql.sql | 2 +- 21 files changed, 126 insertions(+), 95 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java index ebefb213a1..d6296e4a73 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java @@ -46,7 +46,7 @@ public class GetDeviceSubTypeCacheLoader extends CacheLoader getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) @@ -37,7 +37,8 @@ public interface DeviceSubTypeDAO { int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; - int getMaxSubTypeId(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; + boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException; DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java index e1348b1f73..2b18e261b7 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java @@ -38,15 +38,14 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { private static final Log log = LogFactory.getLog(DeviceSubTypeDAOImpl.class); @Override - public boolean addDeviceSubType(DeviceSubType deviceSubType) - throws SubTypeMgtDAOException { + public boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtDAOException { try { String sql = "INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, " + "TYPE_DEFINITION) VALUES (?, ?, ?, ?, ?)"; Connection conn = ConnectionManagerUtil.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, deviceSubType.getSubTypeId()); + stmt.setString(1, deviceSubType.getSubTypeId()); stmt.setInt(2, deviceSubType.getTenantId()); stmt.setString(3, deviceSubType.getDeviceType().toString()); stmt.setString(4, deviceSubType.getSubTypeName()); @@ -68,7 +67,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, + public boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, String typeDefinition) throws SubTypeMgtDAOException { try { @@ -79,7 +78,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, typeDefinition); stmt.setString(2, subTypeName); - stmt.setInt(3, subTypeId); + stmt.setString(3, subTypeId); stmt.setInt(4, tenantId); stmt.setString(5, deviceType.toString()); return stmt.executeUpdate() > 0; @@ -99,14 +98,14 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException { try { String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE = ?"; Connection conn = ConnectionManagerUtil.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, subTypeId); + stmt.setString(1, subTypeId); stmt.setInt(2, tenantId); stmt.setString(3, deviceType.toString()); try (ResultSet rs = stmt.executeQuery()) { @@ -189,29 +188,30 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public int getMaxSubTypeId(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException { + public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtDAOException { try { - String sql = "SELECT COALESCE(MAX(SUB_TYPE_ID),0) as MAX_ID FROM DM_DEVICE_SUB_TYPE WHERE DEVICE_TYPE = ? "; + String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE " + + "= ? "; Connection conn = ConnectionManagerUtil.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, deviceType.toString()); + stmt.setString(1, subTypeId); + stmt.setInt(2, tenantId); + stmt.setString(3, deviceType.toString()); try (ResultSet rs = stmt.executeQuery()) { - if (rs.next()) { - return rs.getInt("MAX_ID"); - } - return 0; + return rs.next(); } } } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining DB connection to retrieve max device subtype id for " + - deviceType + " subtype"; + String msg = "Error occurred while obtaining DB connection to check device subtype exist for " + deviceType + + " subtype & subtype id: " + subTypeId; log.error(msg); throw new SubTypeMgtDAOException(msg, e); } catch (SQLException e) { - String msg = "Error occurred while processing SQL to retrieve max device subtype id for " + deviceType - + " subtype"; + String msg = "Error occurred while processing SQL to check device subtype exist for " + deviceType + " " + + "subtype & subtype id: " + subTypeId; log.error(msg); throw new SubTypeMgtDAOException(msg, e); } diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java index 61c1305923..a50c75f703 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dao/util/DAOUtil.java @@ -38,7 +38,7 @@ public class DAOUtil { public String parseSubTypeToJson(Object objType) { return null; } }; deviceSubType.setTenantId(rs.getInt("TENANT_ID")); - deviceSubType.setSubTypeId(rs.getInt("SUB_TYPE_ID")); + deviceSubType.setSubTypeId(rs.getString("SUB_TYPE_ID")); deviceSubType.setSubTypeName(rs.getString("SUB_TYPE_NAME")); deviceSubType.setDeviceType(DeviceSubType.DeviceType.valueOf(rs.getString("DEVICE_TYPE"))); deviceSubType.setTypeDefinition(rs.getString("TYPE_DEFINITION")); diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java index b29b802f30..8918588f6c 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubType.java @@ -24,17 +24,17 @@ import com.fasterxml.jackson.core.JsonProcessingException; public abstract class DeviceSubType { - private int subTypeId; + private String subTypeId; private int tenantId; private DeviceType deviceType; private String subTypeName; private String typeDefinition; - public int getSubTypeId() { + public String getSubTypeId() { return subTypeId; } - public void setSubTypeId(int subTypeId) { + public void setSubTypeId(String subTypeId) { this.subTypeId = subTypeId; } diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java index c1aa7eeab2..206a57461d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/dto/DeviceSubTypeCacheKey.java @@ -20,7 +20,7 @@ package io.entgra.device.mgt.subtype.mgt.dto; public class DeviceSubTypeCacheKey { int tenantId; - int subTypeId; + String subTypeId; DeviceSubType.DeviceType deviceType; public int getTenantId() { @@ -31,11 +31,11 @@ public class DeviceSubTypeCacheKey { this.tenantId = tenantId; } - public int getSubTypeId() { + public String getSubTypeId() { return subTypeId; } - public void setSubTypeId(int subTypeId) { + public void setSubTypeId(String subTypeId) { this.subTypeId = subTypeId; } diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java index d6e6eba6ea..24c5f2750a 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/impl/DeviceSubTypeServiceImpl.java @@ -51,27 +51,22 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public boolean addDeviceSubType(DeviceSubType deviceSubType) - throws SubTypeMgtPluginException { + public boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtPluginException { String msg = ""; int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); deviceSubType.setTenantId(tenantId); try { ConnectionManagerUtil.beginDBTransaction(); - - //TODO This is done as a temporary... we need to implement addDeviceSubType method either with uuid - // or auto incrementing subtype id. In order to that we have to fix hardcoded subtype id in code level.. - // ex: transport code level - - int maxSubTypeId = deviceSubTypeDAO.getMaxSubTypeId(deviceSubType.getDeviceType()); - deviceSubType.setSubTypeId(maxSubTypeId + 1); boolean result = deviceSubTypeDAO.addDeviceSubType(deviceSubType); if (result) { msg = "Device subtype added successfully,for " + deviceSubType.getDeviceType() + " subtype & subtype " + - "Id: " - + deviceSubType.getSubTypeId(); + "Id: " + deviceSubType.getSubTypeId(); + if (log.isDebugEnabled()) { + log.debug(msg); + } } else { + ConnectionManagerUtil.rollbackDBTransaction(); msg = "Device subtype failed to add,for " + deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId(); throw new SubTypeMgtPluginException(msg); @@ -80,9 +75,6 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, deviceSubType.getSubTypeId(), deviceSubType.getDeviceType()); deviceSubTypeCache.put(key, deviceSubType); - if (log.isDebugEnabled()) { - log.debug(msg); - } return true; } catch (DBConnectionException e) { msg = "Error occurred while obtaining the database connection to add device subtype for " + @@ -90,6 +82,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { log.error(msg); throw new SubTypeMgtPluginException(msg, e); } catch (SubTypeMgtDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); msg = "Error occurred in the database level while adding device subtype for " + deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId(); log.error(msg); @@ -100,9 +93,9 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, - String subTypeName, - String typeDefinition) throws SubTypeMgtPluginException { + public boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, + String subTypeName, String typeDefinition) + throws SubTypeMgtPluginException { String msg = ""; DeviceSubType deviceSubTypeOld = getDeviceSubType(subTypeId, tenantId, deviceType); @@ -117,14 +110,15 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { typeDefinition); if (result) { msg = "Device subtype updated successfully,for " + deviceType + " subtype & subtype Id: " + subTypeId; + if (log.isDebugEnabled()) { + log.debug(msg); + } } else { + ConnectionManagerUtil.rollbackDBTransaction(); msg = "Device subtype failed to update,for " + deviceType + " subtype & subtype Id: " + subTypeId; throw new SubTypeMgtPluginException(msg); } ConnectionManagerUtil.commitDBTransaction(); - if (log.isDebugEnabled()) { - log.debug(msg); - } return true; } catch (DBConnectionException e) { msg = "Error occurred while obtaining the database connection to update device subtype for " + deviceType @@ -132,6 +126,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { log.error(msg); throw new SubTypeMgtPluginException(msg, e); } catch (SubTypeMgtDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); msg = "Error occurred in the database level while updating device subtype for " + deviceType + " subtype & subtype Id: " + subTypeId; log.error(msg); @@ -144,7 +139,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) throws SubTypeMgtPluginException { try { String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, subTypeId, deviceType); @@ -188,7 +183,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { int result = deviceSubTypeDAO.getDeviceSubTypeCount(deviceType); if (result <= 0) { String msg = "There are no any subtypes for device type: " + deviceType; - log.info(msg); + log.error(msg); } return result; } catch (DBConnectionException e) { @@ -228,5 +223,24 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } } - + @Override + public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException { + try { + ConnectionManagerUtil.openDBConnection(); + return deviceSubTypeDAO.checkDeviceSubTypeExist(subTypeId, tenantId, deviceType); + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the database connection to check device subtype exist for " + + deviceType + " subtype & subtype id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } catch (SubTypeMgtDAOException e) { + String msg = "Error occurred in the database level while checking device subtype exist for " + deviceType + + " subtype & subtype id: " + subTypeId; + log.error(msg); + throw new SubTypeMgtPluginException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } } diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java index 73afb32f70..24aa2fd431 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/spi/DeviceSubTypeService.java @@ -27,10 +27,10 @@ public interface DeviceSubTypeService { boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtPluginException; - boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, + boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, String typeDefinition) throws SubTypeMgtPluginException; - DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) throws SubTypeMgtPluginException; List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) @@ -40,4 +40,7 @@ public interface DeviceSubTypeService { DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) throws SubTypeMgtPluginException; + + boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + throws SubTypeMgtPluginException; } diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java index 2535266724..171d621945 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/main/java/io/entgra/device/mgt/subtype/mgt/util/DeviceSubTypeMgtUtil.java @@ -22,14 +22,14 @@ import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubTypeCacheKey; public class DeviceSubTypeMgtUtil { - public static String setDeviceSubTypeCacheKey(int tenantId, int subTypeId, DeviceSubType.DeviceType deviceType) { + public static String setDeviceSubTypeCacheKey(int tenantId, String subTypeId, DeviceSubType.DeviceType deviceType) { return tenantId + "|" + subTypeId + "|" + deviceType.toString(); } public static DeviceSubTypeCacheKey getDeviceSubTypeCacheKey(String key) { String[] keys = key.split("\\|"); int tenantId = Integer.parseInt(keys[0]); - int subTypeId = Integer.parseInt(keys[1]); + String subTypeId = keys[1]; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.valueOf(keys[2]); DeviceSubTypeCacheKey deviceSubTypesCacheKey = new DeviceSubTypeCacheKey(); diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java index d1ff711262..fd0b659fda 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAONegativeTest.java @@ -81,7 +81,7 @@ public class DAONegativeTest extends BaseDeviceSubTypePluginTest { expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype" ) public void testAddDeviceSubTypes() throws SubTypeMgtDAOException { - int subTypeId = 1; + String subTypeId = "1"; String subTypeName = "TestSubType"; DeviceSubType deviceSubType = new DeviceSubType() { @Override @@ -121,7 +121,7 @@ public class DAONegativeTest extends BaseDeviceSubTypePluginTest { expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype" ) public void testAddDeviceSubtypes() throws SubTypeMgtDAOException { - int subTypeId = 1; + String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String subTypeName = "TestSubType"; String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java index 54a164a9aa..5592326962 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/DAOTest.java @@ -49,7 +49,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { public void testGetDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); ConnectionManagerUtil.openDBConnection(); - DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType(1, tenantId, + DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType("1", tenantId, DeviceSubType.DeviceType.COM); ConnectionManagerUtil.closeDBConnection(); Assert.assertNotNull(subTypeActual, "Should not be null"); @@ -68,7 +68,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { @Test public void testAddDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { - int subTypeId = 1; + String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String subTypeName = "TestSubType"; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; @@ -102,7 +102,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { @Test(dependsOnMethods = "testAddDeviceSubType") public void testUpdateDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { - int subTypeId = 1; + String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; String subTypeName = "TestSubType"; @@ -118,6 +118,17 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { TestUtils.verifyUpdatedDeviceSubTypeDAO(subTypeActual); } + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetDeviceTypeByProvider() throws DBConnectionException, SubTypeMgtDAOException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String subTypeName = "TestSubType"; + ConnectionManagerUtil.openDBConnection(); + DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubTypeByProvider(subTypeName, tenantId, deviceType); + ConnectionManagerUtil.closeDBConnection(); + Assert.assertNotNull(subTypeActual, "Should not be null"); + } + @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetDeviceTypeCount() throws DBConnectionException, SubTypeMgtDAOException { DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java index bca0bc6c61..3562525ade 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceNegativeTest.java @@ -15,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ + package io.entgra.device.mgt.subtype.mgt; import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; @@ -62,6 +63,7 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest { expectedExceptionsMessageRegExp = "Error occurred in the database level while adding device subtype for " + "SIM subtype & subtype Id: 1") public void testAddDeviceSubTypes() throws SubTypeMgtPluginException { + String subTypeId = "1"; String subTypeName = "TestSubType"; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; @@ -76,6 +78,7 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest { return null; } }; + deviceSubType.setSubTypeId(subTypeId); deviceSubType.setSubTypeName(subTypeName); deviceSubType.setDeviceType(deviceType); deviceSubTypeService.addDeviceSubType(deviceSubType); @@ -86,7 +89,7 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest { expectedExceptions = {SubTypeMgtPluginException.class}, expectedExceptionsMessageRegExp = "Cannot find device subtype for SIM subtype & subtype Id: 15") public void testUpdateDeviceSubTypes() throws SubTypeMgtPluginException { - int subTypeId = 15; + String subTypeId = "15"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; String subTypeName = "TestSubType"; diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java index 93670db4ba..07694bcce7 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/ServiceTest.java @@ -47,7 +47,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetDeviceType() throws SubTypeMgtPluginException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType(1, tenantId, + DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType("1", tenantId, DeviceSubType.DeviceType.METER); TestUtils.verifyDeviceSubType(subTypeActual); } @@ -63,7 +63,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { @Test public void testAddDeviceSubType() throws SubTypeMgtPluginException { - int subTypeId = 1; + String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String subTypeName = "TestSubType"; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; @@ -80,6 +80,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { return null; } }; + deviceSubType.setSubTypeId(subTypeId); deviceSubType.setSubTypeName(subTypeName); deviceSubType.setDeviceType(deviceType); deviceSubType.setTenantId(tenantId); @@ -93,7 +94,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { @Test(dependsOnMethods = "testAddDeviceSubType") public void testUpdateDeviceSubType() throws SubTypeMgtPluginException { - int subTypeId = 1; + String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; String subTypeName = "TestSubType"; @@ -107,6 +108,16 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { TestUtils.verifyUpdatedDeviceSubType(subTypeActual); } + @Test(dependsOnMethods = "testAddDeviceSubType") + public void testGetDeviceTypeByProvider() throws SubTypeMgtPluginException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String subTypeName = "TestSubType"; + DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubTypeByProvider(subTypeName, tenantId, + deviceType); + TestUtils.verifyDeviceSubType(subTypeActual); + } + @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetDeviceTypeCount() throws SubTypeMgtPluginException { DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java index 29016fda8a..d8e913831c 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/java/io/entgra/device/mgt/subtype/mgt/TestUtils.java @@ -32,45 +32,45 @@ import java.sql.Statement; public class TestUtils { private static final Log log = LogFactory.getLog(TestUtils.class); - public static String createNewDeviceSubType(int subtypeId) { + public static String createNewDeviceSubType(String subtypeId) { return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM800\", " + "\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": true, \"hasICMPSupport\": true, " + "\"socketServerPort\": 8071}"; } - public static String createUpdateDeviceSubType(int subtypeId) { + public static String createUpdateDeviceSubType(String subtypeId) { return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM900\", " + "\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": false, \"hasICMPSupport\": true, " + "\"socketServerPort\": 8071}"; } public static void verifyDeviceSubType(DeviceSubType deviceSubType) { - String typeDefExpected = TestUtils.createNewDeviceSubType(1); - Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + String typeDefExpected = TestUtils.createNewDeviceSubType("1"); + Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); } public static void verifyDeviceSubTypeDAO(DeviceSubType deviceSubType) { - String typeDefExpected = TestUtils.createNewDeviceSubType(1); - Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + String typeDefExpected = TestUtils.createNewDeviceSubType("1"); + Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); } public static void verifyUpdatedDeviceSubType(DeviceSubType deviceSubType) { - String typeDefExpected = TestUtils.createUpdateDeviceSubType(1); - Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + String typeDefExpected = TestUtils.createUpdateDeviceSubType("1"); + Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); } public static void verifyUpdatedDeviceSubTypeDAO(DeviceSubType deviceSubType) { - String typeDefExpected = TestUtils.createUpdateDeviceSubType(1); - Assert.assertEquals(deviceSubType.getSubTypeId(), 1); + String typeDefExpected = TestUtils.createUpdateDeviceSubType("1"); + Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 2f5ae6c677..9737fd3df0 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -779,7 +779,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID INT NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql index 0ed4a1d638..cd3d81c566 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS `DM_DEVICE_SUB_TYPE` ( `TENANT_ID` INT DEFAULT 0, - `SUB_TYPE_ID` INT NOT NULL, + `SUB_TYPE_ID` VARCHAR(45) NOT NULL, `DEVICE_TYPE` VARCHAR(25) NOT NULL, `SUB_TYPE_NAME` VARCHAR(45) NOT NULL, `TYPE_DEFINITION` TEXT NOT NULL, @@ -12,20 +12,8 @@ ); -- ----------------------------------------------------- --- Sample data for DAO test cases +-- Sample data for test cases -- ----------------------------------------------------- -INSERT INTO DM_DEVICE_TYPE(NAME, DEVICE_TYPE_META, LAST_UPDATED_TIMESTAMP, PROVIDER_TENANT_ID, SHARED_WITH_ALL_TENANTS) VALUES -('android','NULL','2020-10-14 16:05:15',-1234,1),('power-meter','NULL','2020-10-14 16:05:15',-1234,1), -('communication-module','NULL','2020-10-14 16:05:15',-1234,1),('sim','NULL','2020-10-14 16:05:15',-1234,1); -INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, LAST_UPDATED_TIMESTAMP, TENANT_ID) VALUES -('+94713192111', '192.168.118.111', 4, '413012689159555', '2022-04-04 16:55:52', '-1234'), -('NULL', '864495036647555', 3, '864495036647555', '2022-04-04 16:56:52', '-1234'), -('NULL', '000019729555', 2, '000019729555', '2022-04-04 16:56:52', '-1234'); - -INSERT INTO DM_ENROLMENT(DEVICE_ID,OWNER,OWNERSHIP,STATUS,IS_TRANSFERRED,DATE_OF_ENROLMENT,DATE_OF_LAST_UPDATE,TENANT_ID) VALUES -(1,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234), -(2,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234), -(3,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234); INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES (3,-1234,'Meter','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 1542733b82..02ec2638f7 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -791,7 +791,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID INT NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 292c25c4f1..458dde6069 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -759,7 +759,7 @@ CREATE TABLE DYNAMIC_TASK_PROPERTIES ( IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_SUB_TYPE]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID INT NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index f18484b048..c4fb6a94f8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -855,7 +855,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID INT NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index bd83ae4e72..030d3aa9c3 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1123,7 +1123,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID INT NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index f0ad9975b7..c09e26a679 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -777,7 +777,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID INT NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, From 03110f1ebae9dcb764a2ca80ab5e3545e4cf6e54 Mon Sep 17 00:00:00 2001 From: kavindya_devindi Date: Wed, 19 Apr 2023 11:24:43 +0530 Subject: [PATCH 06/29] Bump new versions for device subtype --- components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- .../src/main/resources/dbscripts/cdm/h2.sql | 2 +- .../src/main/resources/dbscripts/cdm/mssql.sql | 2 +- .../src/main/resources/dbscripts/cdm/mysql.sql | 2 +- .../src/main/resources/dbscripts/cdm/oracle.sql | 2 +- .../src/main/resources/dbscripts/cdm/postgresql.sql | 2 +- .../io.entgra.device.mgt.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml index 4fa1a8b206..905ed65f0f 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt subtype-mgt - 5.0.20-SNAPSHOT + 5.0.25-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index d2894ffb18..063cd9e767 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.20-SNAPSHOT + 5.0.25-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index b60819e102..30ef1d7d79 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -797,8 +797,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); - -- END OF DM_DEVICE_SUB_TYPE TABLE-- + -- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( ID INT NOT NULL AUTO_INCREMENT, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 7ffa7dba87..2d8bdd30c3 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -766,8 +766,8 @@ CREATE TABLE DM_DEVICE_SUB_TYPE ( TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); - -- END OF DM_DEVICE_SUB_TYPE TABLE-- + -- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( ID INT NOT NULL IDENTITY(1,1), diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 3334105c85..afebcf6150 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -861,8 +861,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ) ENGINE=InnoDB; - -- END OF DM_DEVICE_SUB_TYPE TABLE-- + -- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( ID INT NOT NULL AUTO_INCREMENT, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 97f76cceea..73dcb320b4 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1129,8 +1129,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ) ENGINE=InnoDB; - -- END OF DM_DEVICE_SUB_TYPE TABLE-- + -- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- CREATE TABLE DM_TRACCAR_UNSYNCED_DEVICES ( ID NUMBER(10) NOT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 6b61dc4cad..530083d967 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -783,8 +783,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ) ENGINE=InnoDB; - -- END OF DM_DEVICE_SUB_TYPE TABLE-- + -- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( ID SERIAL NOT NULL, diff --git a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml index ac9e4962ef..e6d23c6d08 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.20-SNAPSHOT + 5.0.25-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 6c4f5489e2..96f3ae4aad 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -23,7 +23,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.20-SNAPSHOT + 5.0.25-SNAPSHOT ../../pom.xml From 71007cc03ceb470e6efb3e636afb243b1d5090bb Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 26 Apr 2023 09:20:33 +0530 Subject: [PATCH 07/29] [maven-release-plugin] prepare release v5.0.25 --- .../io.entgra.analytics.mgt.grafana.proxy.api/pom.xml | 2 +- .../io.entgra.analytics.mgt.grafana.proxy.common/pom.xml | 2 +- .../io.entgra.analytics.mgt.grafana.proxy.core/pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.apimgt.application.extension/pom.xml | 2 +- .../org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml | 2 +- .../org.wso2.carbon.apimgt.keymgt.extension/pom.xml | 2 +- .../org.wso2.carbon.apimgt.webapp.publisher/pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../io.entgra.application.mgt.addons/pom.xml | 2 +- .../application-mgt/io.entgra.application.mgt.api/pom.xml | 2 +- .../io.entgra.application.mgt.common/pom.xml | 2 +- .../application-mgt/io.entgra.application.mgt.core/pom.xml | 2 +- .../io.entgra.application.mgt.publisher.api/pom.xml | 2 +- .../io.entgra.application.mgt.store.api/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.api/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.extensions.logger/pom.xml | 2 +- .../io.entgra.device.mgt.extensions.stateengine/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.carbon.device.mgt.config.api/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.api/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.common/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.core/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.extensions/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.url.printer/pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../io.entgra.server.bootup.heartbeat.beacon/pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.oauth.extensions/pom.xml | 2 +- .../org.wso2.carbon.identity.jwt.client.extension/pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- components/logger/io.entgra.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../org.wso2.carbon.policy.decision.point/pom.xml | 2 +- .../org.wso2.carbon.policy.information.point/pom.xml | 2 +- .../policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml | 2 +- .../policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml | 5 ++--- components/subtype-mgt/pom.xml | 5 ++--- components/task-mgt/pom.xml | 2 +- .../task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml | 2 +- .../task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../task-watcher/io.entgra.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml | 6 ++---- components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml | 6 ++---- components/tenant-mgt/pom.xml | 6 ++---- .../email-sender/org.wso2.carbon.email.sender.core/pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.api/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.common/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.core/pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor/pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../org.wso2.carbon.webapp.authenticator.framework/pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml | 2 +- .../org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../io.entgra.application.mgt.api.feature/pom.xml | 2 +- .../io.entgra.application.mgt.server.feature/pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.api.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.server.feature/pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.extensions.logger.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.api.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.basics.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.extensions.feature/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.server.feature/pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../io.entgra.server.heart.beat.feature/pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../logger/io.entgra.notification.logger.feature/pom.xml | 2 +- features/logger/pom.xml | 2 +- .../org.wso2.carbon.policy.mgt.server.feature/pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.subtype.mgt.feature/pom.xml | 5 ++--- features/subtype-mgt/pom.xml | 5 ++--- features/task-mgt/io.entgra.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml | 6 ++---- features/tenant-mgt/pom.xml | 2 +- .../org.wso2.carbon.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.api.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor.feature/pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 131 files changed, 141 insertions(+), 153 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml index b0bb0b1788..f74a1d0880 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml index b48dfaad13..d2610de9fb 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml index dc7de95714..e84d5ee565 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index dec81b3aa5..3c858ad42f 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 7722cd4868..3b385ccefb 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index c4dbc2d834..1e943eb93c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 4.0.0 diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 147df32e6a..603d58d9c1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index eae69d7327..d38fe0e849 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 9634e1ffe0..7612b6a2e6 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml index 2716ef61de..c715d1dbb1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml @@ -3,7 +3,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 4.0.0 diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml index c5db4f8668..3480848e1e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml @@ -3,7 +3,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 3289983dd2..53fe085988 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 5d84e68023..2885a51721 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml index 95d6aaeeff..f5660866bf 100644 --- a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml @@ -20,7 +20,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.api/pom.xml index 0b4be779e1..71c12b9c7c 100644 --- a/components/application-mgt/io.entgra.application.mgt.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.application.mgt.common/pom.xml index 35e4696bda..c6ac200342 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.application.mgt.core/pom.xml index 43ea757d71..e2e54a8ac8 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml index b10691e62c..f129a61277 100644 --- a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml index 1ca97cfc0e..073a4360c5 100644 --- a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index ef99d4dbf9..a36ff45b4b 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 3794a69341..6ac41a449e 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 05fd5a7ae6..e012c94725 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index daa86010f3..9c2c252c6c 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -38,7 +38,7 @@ org.wso2.carbon.devicemgt certificate-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 577a4ff1f4..b305c96b59 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml index 5311acc66c..8c93ceef4d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml @@ -23,7 +23,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml index 53ec6cf0e6..c4d827240f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml index 224941c71d..747f4fc70a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml @@ -23,7 +23,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 2cc77447ed..34bc10a209 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index cd95a6fe39..ce84a89a12 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index fe857c4bcf..eab9ddf49c 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index a5c33e4a3a..bfd1500e28 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 3e9bf65388..1a0d77c144 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index d07439f4f4..7b48c6fb54 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 2f906d4fcd..95472f963c 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index 356ab22c75..6d43ffd85e 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 7077d97672..be0ab829d7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index a93ef7f3ad..c5d026d27d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 1265503f18..ece6b4cc02 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 2a420a91ef..10b8e9997a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index a110b174ac..833d477918 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 251617c237..f1abf7f061 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml index 08e4484825..4dc1a3ca4a 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heartbeat-management - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index a35a88f848..68e8b9bd21 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 699a82cc62..f87517fb0c 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index 190eabc785..f2f9c80019 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index a217060c94..1556364599 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/logger/io.entgra.notification.logger/pom.xml b/components/logger/io.entgra.notification.logger/pom.xml index 4cafda1771..e8a589a226 100644 --- a/components/logger/io.entgra.notification.logger/pom.xml +++ b/components/logger/io.entgra.notification.logger/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt logger - 5.0.25-SNAPSHOT + 5.0.25 io.entgra.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 6ca86be582..f00b30ef0e 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index 82dc852bed..aa24a96a29 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 290b78bee6..28c82cdad1 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 06d4ec3256..240c652685 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index 715349438d..73569a10cc 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 6cdec66ca3..ba3256b8cb 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml index 905ed65f0f..8a83dade4f 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml @@ -16,12 +16,11 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + org.wso2.carbon.devicemgt subtype-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 063cd9e767..685d8a7092 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -16,12 +16,11 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 1d7fc8d2ef..52c12193a9 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml index cc8bd84340..034a212353 100755 --- a/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml index 897f9a612b..e37eac0ac8 100755 --- a/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-manager - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 6edd1e33dc..df1f091f33 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml index 21fea0cd51..3a0d7ae10b 100755 --- a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-watcher - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 005dbeed26..f915dc579b 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml index b69c2bb112..0ca08ff365 100644 --- a/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml @@ -16,13 +16,11 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + tenant-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml index a91e831ed5..fb207fd72a 100644 --- a/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml @@ -16,13 +16,11 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + tenant-mgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 7d13f340c8..21a623e39e 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -16,13 +16,11 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml index 7bdf992249..3b5f0c58fc 100644 --- a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 35c8d36c06..2deb9dec3a 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 69f1f2b02f..5d101e542c 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml index 1bc860ed3d..3b6a9a15bd 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml index 908957c988..96686e5fbb 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml index 0a64c24297..f79e0e1304 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 60742becc6..d2889df91f 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml index b4c89c0eaa..c5a4f55d1d 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 692ea26977..49a1a7398b 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 8f23a1cb63..4394d61d4a 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 266aa06eb6..f253e90eea 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml index 0f8eef6292..d9b5b0d2a1 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml index f63f0dab76..d5cb525a8f 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 198de84f7a..28795bddc1 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 0782957fd1..398cdcbff7 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index 6703c23a7d..4075d99e35 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index ab7dad3cd4..a55b894cb5 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml index 5f7c41c612..eefb3d4fd3 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 2fbefd8457..2040e5154d 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 950a6bb76d..9be30cfb0c 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml index b65017bbdb..5b5e66d9b0 100644 --- a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml index f1d0f4ae1c..c5b32a54ac 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index a8c8e7d1f0..807f6ed9a3 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index dd5b7736bc..a92cbe4fe9 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index 10bccb16ce..e55e753c7c 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index d9cc05af65..fada447f19 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index e8ab115dd7..826e51ee93 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml index c5a49e8396..ea9cf23db6 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml index 213f436a61..5bc42eae1d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml index ce45313eda..5f43d24ce1 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index e236aa8914..acdf8c282d 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 0f6a8c9df9..888a863a27 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 6cfddf491c..39bf6577fb 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 6ba02faac5..35fdff48a3 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 1a9beb136e..422e23195f 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index bdfa204a19..db161cd47e 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index c16be537ad..bdfcf93d89 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index 7e4c7203c6..51e9c25fb8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index 2128ddce78..d36d2f187d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,7 +4,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 463215e173..c56b01442a 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index 63b3a3229c..dbbeabe660 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 11f50bc7d7..82798be5b4 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml index 31a16abe9c..3b3992aa7e 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heart-beat-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 38eb878036..701c7837ea 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index 2425ea317f..c180f6a68c 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt jwt-client-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 7dafdc7135..8de990c3e9 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/logger/io.entgra.notification.logger.feature/pom.xml b/features/logger/io.entgra.notification.logger.feature/pom.xml index d897352777..49396a6eaa 100644 --- a/features/logger/io.entgra.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt logger-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index fbfdbc7656..a887f1b624 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index c08fc4052b..77cda40df1 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index c36d7e0024..4826354966 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml index e6d23c6d08..e3cc7fb122 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml @@ -17,13 +17,12 @@ ~ under the License. --> - + org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 96f3ae4aad..dbc40f06dc 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -17,13 +17,12 @@ ~ under the License. --> - + carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/task-mgt/io.entgra.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.task.mgt.feature/pom.xml index 16bc2d5723..fd50e447d6 100755 --- a/features/task-mgt/io.entgra.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 3678b617ad..7229a4983f 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml index 87e3214a43..9c2b69a1f5 100644 --- a/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml @@ -16,13 +16,11 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + tenant-mgt-feature org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 44befb4240..ef1ec06c84 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index b05bb2be06..9a5a000af7 100644 --- a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 8e790a7122..573147280c 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index c80b598894..e5cad84b92 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml index 512ca7a4c3..47253acbca 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml index 8d6c87d736..435fb08aa5 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index e9039888d3..642b3fd0fb 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml index 1bd46be14b..91cf1cf968 100644 --- a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 8a01acd528..2f32271b65 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index 218e08e58e..db58ecd12e 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 5.0.25-SNAPSHOT + 5.0.25 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index bade36ba10..af16f34637 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25-SNAPSHOT + 5.0.25 ../../pom.xml diff --git a/pom.xml b/pom.xml index b7c402aeb8..662effdbe2 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 5.0.25-SNAPSHOT + 5.0.25 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1918,7 +1918,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - HEAD + v5.0.25 @@ -2130,7 +2130,7 @@ 1.2.11.wso2v10 - 5.0.25-SNAPSHOT + 5.0.25 4.7.35 From fa7ee67aed18ac915083b235f4ed2ad4c08c08ac Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 26 Apr 2023 09:20:38 +0530 Subject: [PATCH 08/29] [maven-release-plugin] prepare for next development iteration --- .../io.entgra.analytics.mgt.grafana.proxy.api/pom.xml | 2 +- .../io.entgra.analytics.mgt.grafana.proxy.common/pom.xml | 2 +- .../io.entgra.analytics.mgt.grafana.proxy.core/pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.apimgt.application.extension/pom.xml | 2 +- .../org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml | 2 +- .../org.wso2.carbon.apimgt.keymgt.extension/pom.xml | 2 +- .../org.wso2.carbon.apimgt.webapp.publisher/pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../io.entgra.application.mgt.addons/pom.xml | 2 +- .../application-mgt/io.entgra.application.mgt.api/pom.xml | 2 +- .../io.entgra.application.mgt.common/pom.xml | 2 +- .../application-mgt/io.entgra.application.mgt.core/pom.xml | 2 +- .../io.entgra.application.mgt.publisher.api/pom.xml | 2 +- .../io.entgra.application.mgt.store.api/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.api/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.extensions.logger/pom.xml | 2 +- .../io.entgra.device.mgt.extensions.stateengine/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.carbon.device.mgt.config.api/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.api/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.common/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.core/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.extensions/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.url.printer/pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../io.entgra.server.bootup.heartbeat.beacon/pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.oauth.extensions/pom.xml | 2 +- .../org.wso2.carbon.identity.jwt.client.extension/pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- components/logger/io.entgra.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../org.wso2.carbon.policy.decision.point/pom.xml | 2 +- .../org.wso2.carbon.policy.information.point/pom.xml | 2 +- .../policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml | 2 +- .../policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml | 2 +- .../task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../task-watcher/io.entgra.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml | 2 +- components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../email-sender/org.wso2.carbon.email.sender.core/pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.api/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.common/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.core/pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor/pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../org.wso2.carbon.webapp.authenticator.framework/pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml | 2 +- .../org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../io.entgra.application.mgt.api.feature/pom.xml | 2 +- .../io.entgra.application.mgt.server.feature/pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.api.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.server.feature/pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.extensions.logger.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.api.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.basics.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.extensions.feature/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.server.feature/pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../io.entgra.server.heart.beat.feature/pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../logger/io.entgra.notification.logger.feature/pom.xml | 2 +- features/logger/pom.xml | 2 +- .../org.wso2.carbon.policy.mgt.server.feature/pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- features/task-mgt/io.entgra.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../org.wso2.carbon.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.api.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor.feature/pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 131 files changed, 133 insertions(+), 133 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml index f74a1d0880..bbd9fb5d69 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml index d2610de9fb..7093ac3349 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml index e84d5ee565..0a59c96a80 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 3c858ad42f..0c607aa09c 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 3b385ccefb..9c6a1492cd 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index 1e943eb93c..06542fee80 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 603d58d9c1..cf494874fd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index d38fe0e849..14350fa0c9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 7612b6a2e6..701bfc666a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml index c715d1dbb1..752366b4c1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml @@ -3,7 +3,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml index 3480848e1e..3c065db073 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml @@ -3,7 +3,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 53fe085988..25fa414b15 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 2885a51721..c877688505 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml index f5660866bf..e871bd3179 100644 --- a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml @@ -20,7 +20,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.api/pom.xml index 71c12b9c7c..c330a1f02d 100644 --- a/components/application-mgt/io.entgra.application.mgt.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.application.mgt.common/pom.xml index c6ac200342..e64d926b80 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.application.mgt.core/pom.xml index e2e54a8ac8..f97e04615b 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml index f129a61277..d9cd4fa9c2 100644 --- a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml index 073a4360c5..ad89c630db 100644 --- a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index a36ff45b4b..7d023cae47 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 6ac41a449e..c1b8ff7781 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index e012c94725..f4b7ae80de 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 9c2c252c6c..26b8367795 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -38,7 +38,7 @@ org.wso2.carbon.devicemgt certificate-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index b305c96b59..c04f8724db 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml index 8c93ceef4d..309fe87304 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml @@ -23,7 +23,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml index c4d827240f..3d16f2498d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml index 747f4fc70a..4ff04b6f98 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml @@ -23,7 +23,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 34bc10a209..ea3c6b5c5b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index ce84a89a12..62b123f3a2 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index eab9ddf49c..d9db07fdcd 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index bfd1500e28..4329d10014 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 1a0d77c144..c7ca107625 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 7b48c6fb54..2762460d3e 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 95472f963c..04d6ae4544 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index 6d43ffd85e..067b391697 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index be0ab829d7..8c126c159e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index c5d026d27d..d66968ac06 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index ece6b4cc02..28c260d13d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 10b8e9997a..dd3c62ff6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index 833d477918..c3befb0221 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index f1abf7f061..c3b618cb27 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml index 4dc1a3ca4a..9a60509c64 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heartbeat-management - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 68e8b9bd21..1bd5534a05 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index f87517fb0c..aa248aceec 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index f2f9c80019..ba1e95d9c8 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 1556364599..d71a186726 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.notification.logger/pom.xml b/components/logger/io.entgra.notification.logger/pom.xml index e8a589a226..c9e66cd940 100644 --- a/components/logger/io.entgra.notification.logger/pom.xml +++ b/components/logger/io.entgra.notification.logger/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt logger - 5.0.25 + 5.0.26-SNAPSHOT io.entgra.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index f00b30ef0e..a2ade26cd9 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index aa24a96a29..c02ae657b6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 28c82cdad1..a6da401285 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 240c652685..8b9f7dfb4b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index 73569a10cc..35e0255954 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index ba3256b8cb..4260436547 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml index 8a83dade4f..3e0f0081fc 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt subtype-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 685d8a7092..d0d17deb97 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 52c12193a9..4fccbc4256 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml index 034a212353..774fec0dff 100755 --- a/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml index e37eac0ac8..e7968bec5b 100755 --- a/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-manager - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index df1f091f33..7589285d15 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml index 3a0d7ae10b..0011d8d690 100755 --- a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-watcher - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index f915dc579b..96d2a1bc59 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt task-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml index 0ca08ff365..31fcb58a0a 100644 --- a/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml index fb207fd72a..698ddbf942 100644 --- a/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 21a623e39e..537cac339a 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml index 3b5f0c58fc..9a86790e8e 100644 --- a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 2deb9dec3a..57327359a0 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 5d101e542c..90a4b01e41 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml index 3b6a9a15bd..4da59a95c7 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml index 96686e5fbb..6e1b971f02 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml index f79e0e1304..5d35139a65 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index d2889df91f..a8f3a7deaa 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml index c5a4f55d1d..ae20780b3a 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 49a1a7398b..bbd57a74df 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 4394d61d4a..4d53524fe2 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index f253e90eea..adca7c3fad 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml index d9b5b0d2a1..5acf349d6a 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml index d5cb525a8f..044bb1fed5 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 28795bddc1..1c081eeb9d 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 398cdcbff7..475da067ab 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index 4075d99e35..0c98267809 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index a55b894cb5..0854142aeb 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml index eefb3d4fd3..e0ce7c83a5 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 2040e5154d..b6344f6e45 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 9be30cfb0c..73a5be82ca 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml index 5b5e66d9b0..a67320fd0c 100644 --- a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml index c5b32a54ac..3622decb74 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 807f6ed9a3..6fd0c18f81 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index a92cbe4fe9..cb1ed90b32 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index e55e753c7c..87f9245fc9 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index fada447f19..a2aff59a52 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 826e51ee93..ed646bb429 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml index ea9cf23db6..3e2ca09001 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml index 5bc42eae1d..40bc14ec04 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml index 5f43d24ce1..dbf4c755cf 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index acdf8c282d..6b8d03fef1 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 888a863a27..579ac3c50a 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 39bf6577fb..e461f8bf50 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 35fdff48a3..38206938c6 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 422e23195f..6c974cff3c 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index db161cd47e..366594b560 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index bdfcf93d89..cb58c5fdcc 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index 51e9c25fb8..5685d175dd 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index d36d2f187d..c49b1e826a 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,7 +4,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index c56b01442a..273ec000ad 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index dbbeabe660..5d70664b2e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 82798be5b4..2fc92261d4 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml index 3b3992aa7e..b131d4bf39 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heart-beat-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 701c7837ea..4131bc296b 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index c180f6a68c..03e9edae8f 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt jwt-client-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 8de990c3e9..3b0d86025f 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.notification.logger.feature/pom.xml b/features/logger/io.entgra.notification.logger.feature/pom.xml index 49396a6eaa..ece79e753d 100644 --- a/features/logger/io.entgra.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt logger-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index a887f1b624..a1d28091bd 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index 77cda40df1..8b610a5398 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 4826354966..d6ec921b4d 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml index e3cc7fb122..fdf990a2be 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index dbc40f06dc..5a909a0050 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.task.mgt.feature/pom.xml index fd50e447d6..939aa5f28d 100755 --- a/features/task-mgt/io.entgra.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 7229a4983f..896842812a 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml index 9c2b69a1f5..d1d8f7adf9 100644 --- a/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index ef1ec06c84..085da8ad9c 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index 9a5a000af7..12d37b8f93 100644 --- a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 573147280c..833e4777d4 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index e5cad84b92..764f136e61 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml index 47253acbca..64b7b57cea 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml index 435fb08aa5..34f6d270e5 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 642b3fd0fb..7d9c2d9281 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml index 91cf1cf968..5c77cd533a 100644 --- a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 2f32271b65..e8b191e153 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index db58ecd12e..c9dc9f02a7 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 5.0.25 + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index af16f34637..beeae3ee83 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.25 + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 662effdbe2..b61ce5221b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 5.0.25 + 5.0.26-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1918,7 +1918,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - v5.0.25 + HEAD @@ -2130,7 +2130,7 @@ 1.2.11.wso2v10 - 5.0.25 + 5.0.26-SNAPSHOT 4.7.35 From ac834d03595fc59132e55a67a2d1ec866a03bdd8 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 27 Mar 2023 21:42:25 +0530 Subject: [PATCH 09/29] Automated api calls with http client --- .../pom.xml | 148 ++++++++++++++++++ .../PublisherAPIService.java | 6 + .../PublisherAPIServiceImpl.java | 72 +++++++++ .../dto/AccessTokenInfo.java | 50 ++++++ .../PublisherAPIServiceComponent.java | 33 ++++ .../util/PublisherAPIUtil.java | 72 +++++++++ .../pom.xml | 5 + .../publisher/APIPublisherStartupHandler.java | 8 + components/apimgt-extensions/pom.xml | 19 +++ pom.xml | 5 + 10 files changed, 418 insertions(+) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherAPIUtil.java diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml new file mode 100644 index 0000000000..adb72670cf --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml @@ -0,0 +1,148 @@ + + + + + + + apimgt-extensions + org.wso2.carbon.devicemgt + 5.0.21-SNAPSHOT + ../pom.xml + + + 4.0.0 + io.entgra.devicemgt.apimgt.extension.publisher.api + bundle + Entgra - Device API Management Extension Publisher API + Entgra - Device API Management Extension Publisher API + https://entgra.io + + + + org.apache.httpcomponents.wso2 + httpcore + + + org.wso2.orbit.org.apache.httpcomponents + httpclient + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Publisher API Management Bundle + + io.entgra.devicemgt.apimgt.extension.publisher.api.* + + + javax.net.ssl, + javax.xml.bind, + org.apache.commons.logging, + org.apache.http;version="${httpclient.version.range}", + org.apache.http.client;version="${httpclient.version.range}", + org.apache.http.client.methods;version="${httpclient.version.range}", + org.apache.http.conn.socket, + org.apache.http.conn.ssl, + org.apache.http.entity, + org.apache.http.impl.client, + org.apache.http.util;version="${httpclient.version.range}", + + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + com.sun.jndi.toolkit.ctx, + org.wso2.carbon.utils + + + + + + org.jacoco + jacoco-maven-plugin + + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/site + + + + + + + + + + + + + + + + + + + + true + + + \ No newline at end of file diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java new file mode 100644 index 0000000000..2a37762363 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java @@ -0,0 +1,6 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api; + +public interface PublisherAPIService { + + void registerApplication(); +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java new file mode 100644 index 0000000000..9b33fe4ab1 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java @@ -0,0 +1,72 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContextBuilder; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.entity.StringEntity; + +import javax.xml.bind.DatatypeConverter; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; + +public class PublisherAPIServiceImpl implements PublisherAPIService { + private static final Log log = LogFactory.getLog(PublisherAPIServiceImpl.class); + + @Override + public void registerApplication() { + try { + HttpClient httpclient; + SSLContextBuilder builder = new SSLContextBuilder(); + builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); + httpclient = org.apache.http.impl.client.HttpClients.custom().setSSLSocketFactory(sslsf).useSystemProperties().build(); + + URL url =new URL("https://localhost:9443/client-registration/v0.17/register"); + HttpPost request = new HttpPost(url.toString()); + + String payload = "{\n" + + " \"callbackUrl\":\"www.google.lk\",\n" + + " \"clientName\":\"rest_api_publisher_code\",\n" + + " \"owner\":\"admin\",\n" + + " \"grantType\":\"client_credentials password refresh_token\",\n" + + " \"saasApp\":true\n" + + " }"; + + StringEntity entity = new StringEntity(payload); + request.setEntity(entity); + String encoding = DatatypeConverter.printBase64Binary("admin:admin".getBytes("UTF-8")); + + request.setHeader("Authorization", "Basic " + encoding); + request.setHeader("Content-Type", "application/json"); + + HttpResponse httpResponse = httpclient.execute(request); + + if (httpResponse != null) { + BufferedReader br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); + String readLine; + String response = ""; + while (((readLine = br.readLine()) != null)) { + response += readLine; + } + System.out.println(response); + } + + System.out.println(httpResponse.getStatusLine().getStatusCode()); + + } catch (IOException | NoSuchAlgorithmException | KeyStoreException | + KeyManagementException e) { + log.error("failed to call http client.", e); + } + + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java new file mode 100644 index 0000000000..5c1487451e --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java @@ -0,0 +1,50 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.dto; + +public class AccessTokenInfo { + + private String tokenType; + private long expiresIn; + private String refreshToken; + private String accessToken; + private String scope; + + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + + public long getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(long expiresIn) { + this.expiresIn = expiresIn; + } + + public String getRefreshToken() { + return refreshToken; + } + + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java new file mode 100644 index 0000000000..f7059ac20c --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java @@ -0,0 +1,33 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.internal; + + +import com.sun.jndi.toolkit.ctx.ComponentContext; +import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherAPIService; +import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherAPIServiceImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; + +import java.io.IOException; + +/** + * @scr.component name="io.entgra.devicemgt.apimgt.extension.publisher.api.internal.PublisherAPIServiceComponent" + * immediate="true" + */ +public class PublisherAPIServiceComponent { + + private static Log log = LogFactory.getLog(PublisherAPIServiceComponent.class); + + protected void activate(ComponentContext componentContext) { + if (log.isDebugEnabled()) { + log.debug("Initializing publisher API extension bundle"); + } + + PublisherAPIService publisherAPIService = new PublisherAPIServiceImpl(); + + } + + protected void deactivate(ComponentContext componentContext) { + //do nothing + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherAPIUtil.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherAPIUtil.java new file mode 100644 index 0000000000..028d40f190 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherAPIUtil.java @@ -0,0 +1,72 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContextBuilder; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.wso2.carbon.utils.CarbonUtils; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; + +public class PublisherAPIUtil { + + private static final Log log = LogFactory.getLog(PublisherAPIUtil.class); + private static final String HTTPS_PROTOCOL = "https"; + private static final String TENANT_JWT_CONFIG_LOCATION = File.separator + "jwt-config" + File.separator + "jwt.properties"; + private static final String JWT_CONFIG_FILE_NAME = "jwt.properties"; + private static final String SUPERTENANT_JWT_CONFIG_LOCATION = + CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + JWT_CONFIG_FILE_NAME; + + /** + * Return a http client instance + * + * @param protocol- service endpoint protocol http/https + * @return + */ + public static HttpClient getHttpClient(String protocol) + throws IOException, KeyStoreException, NoSuchAlgorithmException, KeyManagementException { + HttpClient httpclient; + if (HTTPS_PROTOCOL.equals(protocol)) { + SSLContextBuilder builder = new SSLContextBuilder(); + builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); + httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).useSystemProperties().build(); + } else { + httpclient = HttpClients.createDefault(); + } + return httpclient; + } + + public static String getResponseString(HttpResponse httpResponse) throws IOException { + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); + String readLine; + String response = ""; + while (((readLine = br.readLine()) != null)) { + response += readLine; + } + return response; + } finally { + EntityUtils.consumeQuietly(httpResponse.getEntity()); + if (br != null) { + try { + br.close(); + } catch (IOException e) { + log.warn("Error while closing the connection! " + e.getMessage()); + } + } + } + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 25fa414b15..fce4b94496 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -122,6 +122,10 @@ h2-database-engine test + + org.wso2.carbon.devicemgt + io.entgra.devicemgt.apimgt.extension.publisher.api + @@ -165,6 +169,7 @@ org.scannotation;version="1.0", org.scannotation.archiveiterator;version="1.0", org.w3c.dom, + io.entgra.devicemgt.apimgt.extension.publisher.api, org.wso2.carbon.apimgt.annotations.api, org.wso2.carbon.apimgt.api, org.wso2.carbon.apimgt.api.model, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index 949f16c3e9..e491d35d6e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -19,6 +19,7 @@ package org.wso2.carbon.apimgt.webapp.publisher; +import io.entgra.devicemgt.apimgt.extension.publisher.api.ScopeServices; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; @@ -37,6 +38,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { private static Stack currentAPIsStack; private APIPublisherService publisher; + private ScopeServices scopeServices; @Override public void completingServerStartup() { @@ -55,6 +57,12 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.debug("Total number of unpublished APIs: " + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); } + + try { + scopeServices.registerApplication(); + } catch (Exception e) { + throw new RuntimeException(e); + } publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); int retryCount = 0; while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) { diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index c877688505..968c5bb3d1 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -25,6 +25,24 @@ 5.0.26-SNAPSHOT ../../pom.xml + + + org.apache.httpcomponents.wso2 + httpcore + + + org.wso2.orbit.org.apache.httpcomponents + httpclient + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.utils + + 4.0.0 apimgt-extensions @@ -40,6 +58,7 @@ org.wso2.carbon.apimgt.keymgt.extension org.wso2.carbon.apimgt.keymgt.extension.api io.entgra.device.mgt.core.apimgt.analytics.extension + io.entgra.devicemgt.apimgt.extension.publisher.api diff --git a/pom.xml b/pom.xml index b61ce5221b..b5435d623d 100644 --- a/pom.xml +++ b/pom.xml @@ -238,6 +238,11 @@ org.wso2.carbon.apimgt.annotations ${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt + io.entgra.devicemgt.apimgt.extension.publisher.api + ${carbon.device.mgt.version} + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.oauth.extensions From a9bb2fcb93be48ac27870b74cabc15a8f18ab4d7 Mon Sep 17 00:00:00 2001 From: pasindu Date: Sun, 9 Apr 2023 14:32:17 +0530 Subject: [PATCH 10/29] Use apache http client --- .../pom.xml | 33 ++- .../APIApplicationServices.java | 13 ++ .../APIApplicationServicesImpl.java | 151 ++++++++++++++ .../PublisherAPIService.java | 6 - .../PublisherAPIServiceImpl.java | 72 ------- .../PublisherAPIServiceStartupHandler.java | 159 ++++++++++++++ .../PublisherRESTAPIServices.java | 197 ++++++++++++++++++ .../bean/RegistrationProfile.java | 82 ++++++++ .../constants/Constants.java | 52 +++++ .../dto/APIApplicationKey.java | 26 +++ .../dto/AccessTokenInfo.java | 3 + .../PublisherAPIServiceComponent.java | 33 --- .../PublisherRESTAPIServiceComponent.java | 44 ++++ ...APIUtil.java => PublisherRESTAPIUtil.java} | 9 +- .../util/ScopeUtils.java | 59 ++++++ .../pom.xml | 1 + .../publisher/APIPublisherServiceImpl.java | 45 ++-- .../publisher/APIPublisherStartupHandler.java | 7 - .../lifecycle/util/AnnotationProcessor.java | 4 +- components/apimgt-extensions/pom.xml | 28 +++ 20 files changed, 880 insertions(+), 144 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/bean/RegistrationProfile.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/constants/Constants.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java rename components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/{PublisherAPIUtil.java => PublisherRESTAPIUtil.java} (83%) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml index adb72670cf..6601a50112 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml @@ -58,6 +58,22 @@ org.eclipse.osgi org.eclipse.osgi.services + + org.wso2.carbon + org.wso2.carbon.core + + + com.googlecode.json-simple.wso2 + json-simple + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + + + com.squareup.okhttp3 + okhttp + @@ -77,7 +93,11 @@ ${project.artifactId} ${carbon.device.mgt.version} Publisher API Management Bundle + + io.entgra.devicemgt.apimgt.extension.publisher.api.internal + + !io.entgra.devicemgt.apimgt.extension.publisher.api.internal, io.entgra.devicemgt.apimgt.extension.publisher.api.* @@ -95,8 +115,17 @@ org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - com.sun.jndi.toolkit.ctx, - org.wso2.carbon.utils + org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", + org.wso2.carbon.utils, + org.wso2.carbon.core, + org.apache.commons.ssl, + org.json.simple, + org.json.simple.parser, + org.apache.http.client.entity, + org.apache.http.message, + org.apache.commons.httpclient, + org.wso2.carbon.apimgt.api.model, + okhttp3.* diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java new file mode 100644 index 0000000000..342f5aa954 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java @@ -0,0 +1,13 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api; + +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; + +public interface APIApplicationServices { + + APIApplicationKey createAndRetrieveApplicationCredentials(); + + AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret); + AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret); + +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java new file mode 100644 index 0000000000..06c1fe97bf --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java @@ -0,0 +1,151 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api; + +import io.entgra.devicemgt.apimgt.extension.publisher.api.bean.RegistrationProfile; +import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.publisher.api.util.PublisherRESTAPIUtil; +import okhttp3.OkHttpClient; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.ssl.Base64; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.message.BasicNameValuePair; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import java.io.IOException; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; + +public class APIApplicationServicesImpl implements APIApplicationServices { + + private static final Log log = LogFactory.getLog(APIApplicationServicesImpl.class); + private final OkHttpClient client; + + public APIApplicationServicesImpl() { + this.client = new OkHttpClient(); + } + + @Override + public APIApplicationKey createAndRetrieveApplicationCredentials() { + + try { + URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); + HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); + HttpPost request = new HttpPost(url.toString()); + + RegistrationProfile registrationProfile = new RegistrationProfile(); + registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); + registrationProfile.setClientName(Constants.CLIENT_NAME); + registrationProfile.setGrantType(Constants.GRANT_TYPE); + registrationProfile.setOwner(Constants.OWNER); + registrationProfile.setIsSaasApp(true); + + String jsonString = registrationProfile.toJSON(); + StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); + request.setEntity(entity); + + //ToDo: Remove hardcoded value + String basicAuth = getBase64Encode("admin", "admin"); + request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_VALUE_PREFIX + basicAuth); + request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); + + HttpResponse httpResponse = httpclient.execute(request); + + if (httpResponse != null) { + String response = PublisherRESTAPIUtil.getResponseString(httpResponse); + try { + if(response != null){ + JSONParser jsonParser = new JSONParser(); + JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); + APIApplicationKey apiApplicationKey = new APIApplicationKey(); + apiApplicationKey.setClientId((String) jsonPayload.get(Constants.CLIENT_ID)); + apiApplicationKey.setClientSecret((String) jsonPayload.get(Constants.CLIENT_SECRET)); + return apiApplicationKey; + } else { + return null; + } + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + } catch (IOException | NoSuchAlgorithmException | KeyStoreException | + KeyManagementException e) { + log.error("failed to call http client.", e); + } + return null; + } + + @Override + public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) { + List params = new ArrayList<>(); + params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE)); + //ToDo: Remove hardcoded value + params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin")); + params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin")); + params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); + return getToken(params, consumerKey, consumerSecret); + } + + @Override + public AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String consumerKey, String consumerSecret) { + List params = new ArrayList<>(); + params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE)); + params.add(new BasicNameValuePair(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken)); + params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); + return getToken(params, consumerKey, consumerSecret); + } + + public AccessTokenInfo getToken(List nameValuePairs, String clientId, String clientSecret) { + + try { + URL url = new URL("https://localhost:9443/oauth2/token"); + HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); + HttpPost request = new HttpPost(url.toString()); + + request.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + getBase64Encode(clientId, clientSecret)); + request.addHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded"); + request.setEntity(new UrlEncodedFormEntity(nameValuePairs)); + + HttpResponse httpResponse = httpclient.execute(request); + String response = PublisherRESTAPIUtil.getResponseString(httpResponse); + if (log.isDebugEnabled()) { + log.debug(response); + } + JSONParser jsonParser = new JSONParser(); + JSONObject jsonObject = (JSONObject) jsonParser.parse(response); + AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); + String accessToken = (String) jsonObject.get(Constants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); + if (accessToken != null && !accessToken.isEmpty()){ + accessTokenInfo.setAccessToken(accessToken); + accessTokenInfo.setRefreshToken((String) jsonObject.get(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); + accessTokenInfo.setExpiresIn((Long) jsonObject.get(Constants.OAUTH_EXPIRES_IN)); + accessTokenInfo.setTokenType((String) jsonObject.get(Constants.OAUTH_TOKEN_TYPE)); + accessTokenInfo.setScope((String) jsonObject.get(Constants.OAUTH_TOKEN_SCOPE)); + } + return accessTokenInfo; + + } catch (IOException | KeyStoreException | NoSuchAlgorithmException | + KeyManagementException| ParseException e) { + throw new RuntimeException(e); + } + } + + static String getBase64Encode(String key, String value) { + return new String(Base64.encodeBase64((key + ":" + value).getBytes())); + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java deleted file mode 100644 index 2a37762363..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIService.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api; - -public interface PublisherAPIService { - - void registerApplication(); -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java deleted file mode 100644 index 9b33fe4ab1..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.entity.StringEntity; - -import javax.xml.bind.DatatypeConverter; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; - -public class PublisherAPIServiceImpl implements PublisherAPIService { - private static final Log log = LogFactory.getLog(PublisherAPIServiceImpl.class); - - @Override - public void registerApplication() { - try { - HttpClient httpclient; - SSLContextBuilder builder = new SSLContextBuilder(); - builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); - httpclient = org.apache.http.impl.client.HttpClients.custom().setSSLSocketFactory(sslsf).useSystemProperties().build(); - - URL url =new URL("https://localhost:9443/client-registration/v0.17/register"); - HttpPost request = new HttpPost(url.toString()); - - String payload = "{\n" + - " \"callbackUrl\":\"www.google.lk\",\n" + - " \"clientName\":\"rest_api_publisher_code\",\n" + - " \"owner\":\"admin\",\n" + - " \"grantType\":\"client_credentials password refresh_token\",\n" + - " \"saasApp\":true\n" + - " }"; - - StringEntity entity = new StringEntity(payload); - request.setEntity(entity); - String encoding = DatatypeConverter.printBase64Binary("admin:admin".getBytes("UTF-8")); - - request.setHeader("Authorization", "Basic " + encoding); - request.setHeader("Content-Type", "application/json"); - - HttpResponse httpResponse = httpclient.execute(request); - - if (httpResponse != null) { - BufferedReader br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); - String readLine; - String response = ""; - while (((readLine = br.readLine()) != null)) { - response += readLine; - } - System.out.println(response); - } - - System.out.println(httpResponse.getStatusLine().getStatusCode()); - - } catch (IOException | NoSuchAlgorithmException | KeyStoreException | - KeyManagementException e) { - log.error("failed to call http client.", e); - } - - } -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java new file mode 100644 index 0000000000..2b005b0cc0 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java @@ -0,0 +1,159 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api; + +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.core.ServerStartupObserver; + +public class PublisherAPIServiceStartupHandler implements ServerStartupObserver { + + private static final Log log = LogFactory.getLog(PublisherAPIServiceStartupHandler.class); + private PublisherRESTAPIServices publisherRESTAPIServices; + private AccessTokenInfo accessTokenInfo; + + @Override + public void completingServerStartup() { + + } + + @Override + public void completedServerStartup() { + +// String cid = null; +// String cS = null; +// String token = null; +// AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); +// +// try { +// URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); +// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); +// HttpPost request = new HttpPost(url.toString()); +// +// RegistrationProfile registrationProfile = new RegistrationProfile(); +// registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); +// registrationProfile.setClientName(Constants.CLIENT_NAME); +// registrationProfile.setOwner(Constants.OWNER); +// registrationProfile.setGrantType(Constants.GRANT_TYPE); +// registrationProfile.setIsSaasApp(true); +// +// String jsonString = registrationProfile.toJSON(); +// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); +// request.setEntity(entity); +// +// String basicAuth = PublisherRESTAPIServices.getBase64Encode("admin", "admin"); +// +// request.setHeader("Authorization", "Basic " + basicAuth); +// request.setHeader("Content-Type", "application/json"); +// +// HttpResponse httpResponse = httpclient.execute(request); +// +// if (httpResponse != null) { +// +// String response = PublisherRESTAPIUtil.getResponseString(httpResponse); +// try { +// if(response != null){ +// JSONParser jsonParser = new JSONParser(); +// JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); +// String clientId = (String) jsonPayload.get(Constants.CLIENT_ID); +// String clientSecret = (String) jsonPayload.get(Constants.CLIENT_SECRET); +// cid = clientId; +// cS = clientSecret; +// } +// } catch (ParseException e) { +// throw new RuntimeException(e); +// } +// +// System.out.println(response); +// } +// System.out.println(httpResponse.getStatusLine().getStatusCode()); +// +// +// } catch (IOException | NoSuchAlgorithmException | KeyStoreException | +// KeyManagementException e) { +// log.error("failed to call http client.", e); +// } +// +// +// String response = null; +// +// List params = new ArrayList<>(); +// params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE)); +// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin")); +// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin")); +// params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); +// try { +// URL url = new URL("https://localhost:9443/oauth2/token"); +// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); +// HttpPost request = new HttpPost(url.toString()); +// +// request.addHeader("Authorization", "Basic " + PublisherRESTAPIServices.getBase64Encode(cid, cS)); +// request.addHeader("Content-Type", "application/x-www-form-urlencoded"); +// request.setEntity(new UrlEncodedFormEntity(params)); +// HttpResponse httpResponse = httpclient.execute(request); +// response = PublisherRESTAPIUtil.getResponseString(httpResponse); +// JSONParser jsonParser = new JSONParser(); +// JSONObject jsonObject = (JSONObject) jsonParser.parse(response); +// token = (String) jsonObject.get(Constants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); +// if (token != null && !token.isEmpty()){ +// accessTokenInfo.setRefreshToken(token); +// accessTokenInfo.setRefreshToken((String) jsonObject.get(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); +// accessTokenInfo.setExpiresIn((Long) jsonObject.get(Constants.OAUTH_EXPIRES_IN)); +// accessTokenInfo.setTokenType((String) jsonObject.get(Constants.OAUTH_TOKEN_TYPE)); +// accessTokenInfo.setScope((String) jsonObject.get(Constants.OAUTH_TOKEN_SCOPE)); +// } +// System.out.println(accessTokenInfo); +// +// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | +// KeyManagementException| ParseException e) { +// throw new RuntimeException(e); +// } +// +// String key = "perm:sms-handler:view-configuration"; +// String value = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); +// +// +// String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + value; +// try { +// URL url = new URL(getScopeUrl); +// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); +// HttpHead request = new HttpHead(url.toString()); +// +// request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token); +// HttpResponse httpResponse = httpclient.execute(request); +// +// String code = String.valueOf(httpResponse.getStatusLine().getStatusCode()); +// System.out.println(code); +// +// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { +// throw new RuntimeException(e); +// } +// +// String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + "27fce6f1-6741-4ad5-b700-a56427fd3dbb"; +// try { +// URL url = new URL(updateScopeUrl); +// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); +// HttpPut request = new HttpPut(url.toString()); +// +// request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token); +// request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); +// +// +// String jsonString = "{\"name\": \"" + "name" + "\",\"displayName\": \"" + "displayname" + +// "\", \"description\": \"" + "description" + "\"," + "\"bindings\": [" + +// "\"Internal/devicemgt-user\"]}"; +// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); +// request.setEntity(entity); +// +// HttpResponse httpResponse = httpclient.execute(request); +// int code = httpResponse.getStatusLine().getStatusCode(); +// System.out.println(code); +// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { +// throw new RuntimeException(e); +// } + + +// publisherRESTAPIServices = new PublisherRESTAPIServices(); +// publisherRESTAPIServices.isSharedScopeNameExists("perm:sms-handler:view-configuration"); + + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java new file mode 100644 index 0000000000..335680a84d --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java @@ -0,0 +1,197 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api; + +import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.publisher.api.util.PublisherRESTAPIUtil; +import io.entgra.devicemgt.apimgt.extension.publisher.api.util.ScopeUtils; +import org.apache.axis2.databinding.types.xsd._boolean; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.http.HttpHeaders; +import org.apache.http.client.methods.HttpHead; +import org.apache.http.client.methods.HttpPut; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.ssl.Base64; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.wso2.carbon.apimgt.api.model.Scope; + +import java.io.IOException; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; + +public class PublisherRESTAPIServices { + private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); + +// private String clientId; +// private String clientSecret; +// private String accessToken; +// +// public AccessTokenInfo registerApplication() { +// +// try { +// URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); +// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); +// HttpPost request = new HttpPost(url.toString()); +// +// RegistrationProfile registrationProfile = new RegistrationProfile(); +// registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); +// registrationProfile.setClientName(Constants.CLIENT_NAME); +// registrationProfile.setGrantType(Constants.GRANT_TYPE); +// registrationProfile.setOwner(Constants.OWNER); +// registrationProfile.setIsSaasApp(true); +// +// String jsonString = registrationProfile.toJSON(); +// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); +// request.setEntity(entity); +// +// String basicAuth = getBase64Encode("admin", "admin"); +// +// request.setHeader("Authorization", "Basic " + basicAuth); +// request.setHeader("Content-Type", "application/json"); +// +// HttpResponse httpResponse = httpclient.execute(request); +// +// if (httpResponse != null) { +// +// String response = PublisherRESTAPIUtil.getResponseString(httpResponse); +// try { +// if(response != null){ +// JSONParser jsonParser = new JSONParser(); +// JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); +// clientId = (String) jsonPayload.get(Constants.CLIENT_ID); +// clientSecret = (String) jsonPayload.get(Constants.CLIENT_SECRET); +// } +// } catch (ParseException e) { +// throw new RuntimeException(e); +// } +// System.out.println(response); +// } +// System.out.println(httpResponse.getStatusLine().getStatusCode()); +// +// } catch (IOException | NoSuchAlgorithmException | KeyStoreException | +// KeyManagementException e) { +// log.error("failed to call http client.", e); +// } +// return getAccessTokenFromRegisteredApplication(clientId, clientSecret); +// +// } +// +// public AccessTokenInfo getAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) { +// List params = new ArrayList<>(); +// params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE)); +// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin")); +// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin")); +// params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); +// return getToken(params, consumerKey, consumerSecret); +// } +// +// public AccessTokenInfo getToken(List nameValuePairs, String clientId, String clientSecret) { +// +// String token = null; +// String response = null; +// try { +// URL url = new URL("https://localhost:9443/oauth2/token"); +// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); +// HttpPost request = new HttpPost(url.toString()); +// +// request.addHeader("Authorization", "Basic " + getBase64Encode(clientId, clientSecret)); +// request.addHeader("Content-Type", "application/x-www-form-urlencoded"); +// request.setEntity(new UrlEncodedFormEntity(nameValuePairs)); +// HttpResponse httpResponse = httpclient.execute(request); +// response = PublisherRESTAPIUtil.getResponseString(httpResponse); +// JSONParser jsonParser = new JSONParser(); +// JSONObject jsonObject = (JSONObject) jsonParser.parse(response); +// AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); +// token = (String) jsonObject.get(Constants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); +// if (token != null && !token.isEmpty()){ +// accessTokenInfo.setRefreshToken(token); +// accessTokenInfo.setRefreshToken((String) jsonObject.get(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); +// accessTokenInfo.setExpiresIn((Long) jsonObject.get(Constants.OAUTH_EXPIRES_IN)); +// accessTokenInfo.setTokenType((String) jsonObject.get(Constants.OAUTH_TOKEN_TYPE)); +// accessTokenInfo.setScope((String) jsonObject.get(Constants.OAUTH_TOKEN_SCOPE)); +// } +// accessToken = token; +// return accessTokenInfo; +// +// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | +// KeyManagementException| ParseException e) { +// throw new RuntimeException(e); +// } +// } + + public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key){ + + String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); + String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; + try { + URL url = new URL(getScopeUrl); + HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); + HttpHead request = new HttpHead(url.toString()); + + request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessTokenInfo.getAccessToken()); + HttpResponse httpResponse = httpclient.execute(request); + + if (HttpStatus.SC_OK == httpResponse.getStatusLine().getStatusCode()){ + return true; + } else if(HttpStatus.SC_UNAUTHORIZED == httpResponse.getStatusLine().getStatusCode()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret() ); + return isSharedScopeNameExists(apiApplicationKey,refreshedAccessToken, key); + } else{ + return false; + } + + } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { + throw new RuntimeException(e); + } + } + + public void updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope){ + +// String keyValue = new String(Base64.encodeBase64((scope.getKey()).getBytes())).replace("=", ""); +// String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; + String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + scope.getId(); + try { + URL url = new URL(updateScopeUrl); + HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); + HttpPut request = new HttpPut(url.toString()); + + request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccessToken()); + request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); + + ScopeUtils setScope = new ScopeUtils(); + setScope.setKey(scope.getKey()); + setScope.setName(scope.getName()); + setScope.setDescription(scope.getDescription()); + setScope.setRoles(scope.getRoles()); + String jsonString = setScope.toJSON(); + StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); + request.setEntity(entity); + + HttpResponse httpResponse = httpclient.execute(request); + if (HttpStatus.SC_OK != httpResponse.getStatusLine().getStatusCode() && HttpStatus.SC_UNAUTHORIZED == httpResponse.getStatusLine().getStatusCode()){ + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo accessTokenInfo1 = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret() ); + updateSharedScope(apiApplicationKey, accessTokenInfo1, scope); + } else { + String response = httpResponse.toString(); + log.info(response); + } + + } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { + throw new RuntimeException(e); + } + } +// static String getBase64Encode(String key, String value) { +// return new String(Base64.encodeBase64((key + ":" + value).getBytes())); +// } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/bean/RegistrationProfile.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/bean/RegistrationProfile.java new file mode 100644 index 0000000000..242788ed26 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/bean/RegistrationProfile.java @@ -0,0 +1,82 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.bean; + +/** + * This class represents the data that are required to register + * the oauth application. + */ +public class RegistrationProfile { + + private String callbackUrl; + private String clientName; + private String tokenScope; + private String owner; + private String grantType; + private String applicationType; + private boolean isSaasApp; + + private static final String TAG = RegistrationProfile.class.getSimpleName(); + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callBackUrl) { + this.callbackUrl = callBackUrl; + } + + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + this.clientName = clientName; + } + + public String getTokenScope() { + return tokenScope; + } + + public void setTokenScope(String tokenScope) { + this.tokenScope = tokenScope; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getGrantType() { + return grantType; + } + + public void setGrantType(String grantType) { + this.grantType = grantType; + } + + public String getApplicationType() { + return applicationType; + } + + public void setApplicationType(String applicationType) { + this.applicationType = applicationType; + } + + public boolean isSaasApp() { + return isSaasApp; + } + + public void setIsSaasApp(boolean isSaasApp) { + this.isSaasApp = isSaasApp; + } + + public String toJSON() { + String jsonString = + "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + + "\", \"saasApp\" : " + isSaasApp + " }\n"; + return jsonString; + } +} \ No newline at end of file diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/constants/Constants.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/constants/Constants.java new file mode 100644 index 0000000000..0144e129f1 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/constants/Constants.java @@ -0,0 +1,52 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.constants; + +public final class Constants { + + private Constants() { + } + + public static final String EMPTY_STRING = ""; + public static final String CLIENT_NAME = "rest_api_publisher_code"; + public static final String OWNER = "admin"; + public static final String GRANT_TYPE = "client_credentials password refresh_token"; + public static final String REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME = "refresh_token"; + public static final String OAUTH_EXPIRES_IN = "expires_in"; + public static final String OAUTH_TOKEN_SCOPE = "scope"; + public static final String OAUTH_TOKEN_TYPE = "token_type"; + public static final String REFRESH_TOKEN_GRANT_TYPE = "refresh_token"; + public static final String SCOPE_PARAM_NAME = "scope"; + public static final String SCOPES = "apim:api_create apim:api_view apim:shared_scope_manage"; + + public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive"; + public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000; + + public static final int DEFAULT_MIN_THREAD_POOL_SIZE = 8; + public static final int DEFAULT_MAX_THREAD_POOL_SIZE = 100; + public static final int DEFAULT_EXECUTOR_JOB_QUEUE_SIZE = 2000; + public static final long DEFAULT_KEEP_ALIVE_TIME_IN_MILLIS = 20000; + public static final String ADAPTER_MIN_THREAD_POOL_SIZE_NAME = "minThread"; + public static final String ADAPTER_MAX_THREAD_POOL_SIZE_NAME = "maxThread"; + public static final String ADAPTER_KEEP_ALIVE_TIME_NAME = "keepAliveTimeInMillis"; + public static final String ADAPTER_EXECUTOR_JOB_QUEUE_SIZE_NAME = "jobQueueSize"; + + public static final String DEFAULT_CALLBACK = ""; + public static final String DEFAULT_PASSWORD = ""; + public static final String TOKEN_SCOPE = "production"; + public static final String APPLICATION_NAME_PREFIX = "OutputAdapter_"; + public static final String CLIENT_ID = "clientId"; + public static final String CLIENT_SECRET = "clientSecret"; + + public static final String AUTHORIZATION_HEADER_NAME = "Authorization"; + public static final String AUTHORIZATION_HEADER_VALUE_PREFIX = "Basic "; + public static final String AUTHORIZATION_HEADER_PREFIX_BEARER = "Bearer "; + public static final String HEADER_CONTENT_TYPE = "Content-Type"; + public static final String APPLICATION_JSON = "application/json"; + public static final String PASSWORD_GRANT_TYPE = "password"; + public static final String PASSWORD_GRANT_TYPE_USERNAME = "username"; + public static final String PASSWORD_GRANT_TYPE_PASSWORD = "password"; + public static final String PASSWORD_GRANT_TYPE_SCOPES = "scopes"; + public static final String ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME = "access_token"; + public static final String GRANT_TYPE_PARAM_NAME = "grant_type"; +} + + diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java new file mode 100644 index 0000000000..fdd20f2f22 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java @@ -0,0 +1,26 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.dto; + +/** + * This holds api application consumer id and secret. + */ +public class APIApplicationKey { + + private String clientId; + private String clientSecret; + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java index 5c1487451e..e738c71f45 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java @@ -1,5 +1,8 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api.dto; +/** + * This holds the token information that return from the token endpoint. + */ public class AccessTokenInfo { private String tokenType; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java deleted file mode 100644 index f7059ac20c..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherAPIServiceComponent.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.internal; - - -import com.sun.jndi.toolkit.ctx.ComponentContext; -import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherAPIService; -import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherAPIServiceImpl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; - -import java.io.IOException; - -/** - * @scr.component name="io.entgra.devicemgt.apimgt.extension.publisher.api.internal.PublisherAPIServiceComponent" - * immediate="true" - */ -public class PublisherAPIServiceComponent { - - private static Log log = LogFactory.getLog(PublisherAPIServiceComponent.class); - - protected void activate(ComponentContext componentContext) { - if (log.isDebugEnabled()) { - log.debug("Initializing publisher API extension bundle"); - } - - PublisherAPIService publisherAPIService = new PublisherAPIServiceImpl(); - - } - - protected void deactivate(ComponentContext componentContext) { - //do nothing - } -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java new file mode 100644 index 0000000000..612f77a8d9 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java @@ -0,0 +1,44 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.internal; + +import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; +import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherAPIServiceStartupHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.core.ServerShutdownHandler; +import org.wso2.carbon.core.ServerStartupObserver; + +/** + * @scr.component name="io.entgra.devicemgt.apimgt.extension.publisher.api.internal.PublisherRESTAPIServiceComponent" + * immediate="true" + */ +public class PublisherRESTAPIServiceComponent { + + private static Log log = LogFactory.getLog(PublisherRESTAPIServiceComponent.class); + + protected void activate(ComponentContext componentContext) { + if (log.isDebugEnabled()) { + log.debug("Initializing publisher API extension bundle"); + } + try { + BundleContext bundleContext = componentContext.getBundleContext(); + + PublisherAPIServiceStartupHandler publisherAPIServiceStartupHandler = new PublisherAPIServiceStartupHandler(); + bundleContext.registerService(PublisherAPIServiceStartupHandler.class.getName(), publisherAPIServiceStartupHandler, null); + bundleContext.registerService(ServerStartupObserver.class.getName(), publisherAPIServiceStartupHandler, null); + bundleContext.registerService(ServerShutdownHandler.class.getName(), publisherAPIServiceStartupHandler, null); + + PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); + bundleContext.registerService(PublisherRESTAPIServices.class.getName(), publisherRESTAPIServices, null); + + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected void deactivate(ComponentContext componentContext) { + //do nothing + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherAPIUtil.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherRESTAPIUtil.java similarity index 83% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherAPIUtil.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherRESTAPIUtil.java index 028d40f190..1d532d17a7 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherAPIUtil.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherRESTAPIUtil.java @@ -19,14 +19,9 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -public class PublisherAPIUtil { - - private static final Log log = LogFactory.getLog(PublisherAPIUtil.class); +public class PublisherRESTAPIUtil { + private static final Log log = LogFactory.getLog(PublisherRESTAPIUtil.class); private static final String HTTPS_PROTOCOL = "https"; - private static final String TENANT_JWT_CONFIG_LOCATION = File.separator + "jwt-config" + File.separator + "jwt.properties"; - private static final String JWT_CONFIG_FILE_NAME = "jwt.properties"; - private static final String SUPERTENANT_JWT_CONFIG_LOCATION = - CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + JWT_CONFIG_FILE_NAME; /** * Return a http client instance diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java new file mode 100644 index 0000000000..db8011521d --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java @@ -0,0 +1,59 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.util; + +/** + * This class represents the data that are required to register + * the oauth application. + */ +public class ScopeUtils { + + private String key; + private String name; + private String roles; + private String description; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRoles() { + return roles; + } + + public void setRoles(String roles) { + this.roles = roles; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String toJSON() { + String jsonString = + "{\"name\": \"" + key + "\",\"displayName\": \"" + name + + "\", \"description\": \"" + description + "\"," + "\"bindings\": [" + + roles + "]" + " }"; + +// String jsonString = +// "{\"name\": \"" + name + "\",\"displayName\": \"" + name + +// "\", \"description\": \"" + description + "\"," + "\"bindings\": [" + +// "\"Internal/devicemgt-user\"" + +// "]" + " }"; + return jsonString; + } +} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index fce4b94496..0ca58492f5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -170,6 +170,7 @@ org.scannotation.archiveiterator;version="1.0", org.w3c.dom, io.entgra.devicemgt.apimgt.extension.publisher.api, + io.entgra.devicemgt.apimgt.extension.publisher.api.dto, org.wso2.carbon.apimgt.annotations.api, org.wso2.carbon.apimgt.api, org.wso2.carbon.apimgt.api.model, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 0dcc92e638..ea7f2e1108 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -18,6 +18,11 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; +import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; +import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl; +import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -50,7 +55,6 @@ import org.wso2.carbon.user.core.tenant.Tenant; import org.wso2.carbon.user.core.tenant.TenantSearchResult; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.io.BufferedReader; import java.io.File; @@ -357,13 +361,19 @@ public class APIPublisherServiceImpl implements APIPublisherService { WebappPublisherConfig config = WebappPublisherConfig.getInstance(); List tenants = new ArrayList<>(Collections.singletonList(APIConstants.SUPER_TENANT_DOMAIN)); tenants.addAll(config.getTenants().getTenant()); + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + APIApplicationKey apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + AccessTokenInfo accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + try { for (String tenantDomain : tenants) { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); - APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(MultitenantUtils.getTenantAwareUsername( - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration() - .getAdminUserName())); + PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); +// APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(MultitenantUtils.getTenantAwareUsername( +// PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration() +// .getAdminUserName())); try { String fileName = @@ -409,8 +419,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { } scope.setRoles(roleString); - if (apiProvider.isSharedScopeNameExists(scope.getKey(), tenantDomain)) { - apiProvider.updateSharedScope(scope, tenantDomain); +// if (apiProvider.isSharedScopeNameExists(scope.getKey(), tenantDomain)) { +// apiProvider.updateSharedScope(scope, tenantDomain); + if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) { + publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); } else { // todo: come to this level means, that scope is removed from API, but haven't removed from the scope-role-permission-mappings list if (log.isDebugEnabled()) { @@ -424,15 +436,18 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } - } catch (UserStoreException e) { - String msg = "Error occurred while reading tenant admin username"; - log.error(msg, e); - throw new APIManagerPublisherException(e); - } catch (APIManagementException e) { - String msg = "Error occurred while loading api provider"; - log.error(msg, e); - throw new APIManagerPublisherException(e); - } finally { + } +// catch (UserStoreException e) { +// String msg = "Error occurred while reading tenant admin username"; +// log.error(msg, e); +// throw new APIManagerPublisherException(e); +// } +// catch (APIManagementException e) { +// String msg = "Error occurred while loading api provider"; +// log.error(msg, e); +// throw new APIManagerPublisherException(e); +// } + finally { PrivilegedCarbonContext.endTenantFlow(); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index e491d35d6e..bfcafcc2c8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -19,13 +19,11 @@ package org.wso2.carbon.apimgt.webapp.publisher; -import io.entgra.devicemgt.apimgt.extension.publisher.api.ScopeServices; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.core.ServerStartupObserver; - import java.util.Stack; public class APIPublisherStartupHandler implements ServerStartupObserver { @@ -36,13 +34,10 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { private static final int MAX_RETRY_COUNT = 5; private static Stack failedAPIsStack = new Stack<>(); private static Stack currentAPIsStack; - private APIPublisherService publisher; - private ScopeServices scopeServices; @Override public void completingServerStartup() { - } @Override @@ -57,9 +52,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.debug("Total number of unpublished APIs: " + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); } - try { - scopeServices.registerApplication(); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index f41c07967a..7cdede5bcb 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -299,7 +299,7 @@ public class AnnotationProcessor { // if (scope != null) { // resource.setScope(scope); // } else { -// log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) + +// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); // scope = new ApiScope(); // scope.setName(DEFAULT_SCOPE_NAME); @@ -537,7 +537,7 @@ public class AnnotationProcessor { if (scope != null) { apiResource.setScope(scope); } else { -// log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) + +// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); scope = new ApiScope(); scope.setName(DEFAULT_SCOPE_NAME); diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 968c5bb3d1..747eb843dd 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -42,6 +42,34 @@ org.wso2.carbon org.wso2.carbon.utils + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + org.wso2.carbon + org.wso2.carbon.core + + + com.googlecode.json-simple.wso2 + json-simple + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + + + com.squareup.okhttp3 + okhttp + + + io.github.openfeign + feign-okhttp + 4.0.0 From 8e4998ede8f11a6dfd1ca078a412ae4b9b6aeb61 Mon Sep 17 00:00:00 2001 From: pasindu Date: Sun, 9 Apr 2023 20:37:37 +0530 Subject: [PATCH 11/29] Test okhttp --- .../pom.xml | 20 ++- .../APIApplicationServicesImpl.java | 161 +++++++++++++----- 2 files changed, 128 insertions(+), 53 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml index 6601a50112..e5fec434f0 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml @@ -74,6 +74,10 @@ com.squareup.okhttp3 okhttp + + io.github.openfeign + feign-okhttp + @@ -85,7 +89,7 @@ org.apache.felix maven-bundle-plugin - 1.4.0 + 5.1.7 true @@ -102,7 +106,7 @@ javax.net.ssl, - javax.xml.bind, + org.apache.commons.logging, org.apache.http;version="${httpclient.version.range}", org.apache.http.client;version="${httpclient.version.range}", @@ -115,14 +119,14 @@ org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.wso2.carbon.utils, + + org.wso2.carbon.core, org.apache.commons.ssl, - org.json.simple, - org.json.simple.parser, - org.apache.http.client.entity, - org.apache.http.message, + + + + org.apache.commons.httpclient, org.wso2.carbon.apimgt.api.model, okhttp3.* diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java index 06c1fe97bf..8932384f6d 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java @@ -1,11 +1,12 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api; +import com.google.gson.JsonObject; import io.entgra.devicemgt.apimgt.extension.publisher.api.bean.RegistrationProfile; import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; import io.entgra.devicemgt.apimgt.extension.publisher.api.util.PublisherRESTAPIUtil; -import okhttp3.OkHttpClient; +import okhttp3.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.ssl.Base64; @@ -22,71 +23,141 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import java.io.IOException; import java.net.URL; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.List; +import java.util.*; public class APIApplicationServicesImpl implements APIApplicationServices { private static final Log log = LogFactory.getLog(APIApplicationServicesImpl.class); - private final OkHttpClient client; + private static final OkHttpClient client = getOkHttpClient(); - public APIApplicationServicesImpl() { - this.client = new OkHttpClient(); + private static OkHttpClient getOkHttpClient() { + X509TrustManager trustAllCerts = new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[0]; + } + + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + }; + return new OkHttpClient.Builder() + .sslSocketFactory(getSimpleTrustedSSLSocketFactory(), trustAllCerts) + .hostnameVerifier((hostname, sslSession) -> true).build(); } + private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { + try { + TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + } + }; + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + return sc.getSocketFactory(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + return null; + } + + } @Override public APIApplicationKey createAndRetrieveApplicationCredentials() { - try { - URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); - HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); - HttpPost request = new HttpPost(url.toString()); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("callbackUrl",Constants.EMPTY_STRING); + jsonObject.addProperty("clientName",Constants.CLIENT_NAME); + jsonObject.addProperty("grantType",Constants.EMPTY_STRING); + jsonObject.addProperty("owner",Constants.OWNER); + jsonObject.addProperty("saasApp",true); - RegistrationProfile registrationProfile = new RegistrationProfile(); - registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); - registrationProfile.setClientName(Constants.CLIENT_NAME); - registrationProfile.setGrantType(Constants.GRANT_TYPE); - registrationProfile.setOwner(Constants.OWNER); - registrationProfile.setIsSaasApp(true); + MediaType jsonMediaType = MediaType.parse("application/json; charset=utf-8"); + RequestBody requestBody = RequestBody.create(jsonMediaType, jsonObject.toString()); - String jsonString = registrationProfile.toJSON(); - StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); - request.setEntity(entity); + String keyManagerEndpoint = "https://localhost:9443/client-registration/v0.17/register"; - //ToDo: Remove hardcoded value - String basicAuth = getBase64Encode("admin", "admin"); - request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_VALUE_PREFIX + basicAuth); - request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); - - HttpResponse httpResponse = httpclient.execute(request); + Request request = new Request.Builder() + .url(keyManagerEndpoint) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic("admin", "admin")) + .post(requestBody) + .build(); + try { + Response response = client.newCall(request).execute(); + System.out.println(request); + System.out.println("---------------------------"); + System.out.println(response); - if (httpResponse != null) { - String response = PublisherRESTAPIUtil.getResponseString(httpResponse); - try { - if(response != null){ - JSONParser jsonParser = new JSONParser(); - JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); - APIApplicationKey apiApplicationKey = new APIApplicationKey(); - apiApplicationKey.setClientId((String) jsonPayload.get(Constants.CLIENT_ID)); - apiApplicationKey.setClientSecret((String) jsonPayload.get(Constants.CLIENT_SECRET)); - return apiApplicationKey; - } else { - return null; - } - } catch (ParseException e) { - throw new RuntimeException(e); - } - } +// JSONObject responseObj = new JSONObject(Objects.requireNonNull(response.body()).string()); - } catch (IOException | NoSuchAlgorithmException | KeyStoreException | - KeyManagementException e) { - log.error("failed to call http client.", e); + } catch (IOException e) { + throw new RuntimeException(e); } + +// try { +// URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); +// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); +// HttpPost request = new HttpPost(url.toString()); +// +// RegistrationProfile registrationProfile = new RegistrationProfile(); +// registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); +// registrationProfile.setClientName(Constants.CLIENT_NAME); +// registrationProfile.setGrantType(Constants.GRANT_TYPE); +// registrationProfile.setOwner(Constants.OWNER); +// registrationProfile.setIsSaasApp(true); +// +// String jsonString = registrationProfile.toJSON(); +// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); +// request.setEntity(entity); +// +// //ToDo: Remove hardcoded value +// String basicAuth = getBase64Encode("admin", "admin"); +// request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_VALUE_PREFIX + basicAuth); +// request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); +// +// HttpResponse httpResponse = httpclient.execute(request); +// +// if (httpResponse != null) { +// String response = PublisherRESTAPIUtil.getResponseString(httpResponse); +// try { +// if(response != null){ +// JSONParser jsonParser = new JSONParser(); +// JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); +// APIApplicationKey apiApplicationKey = new APIApplicationKey(); +// apiApplicationKey.setClientId((String) jsonPayload.get(Constants.CLIENT_ID)); +// apiApplicationKey.setClientSecret((String) jsonPayload.get(Constants.CLIENT_SECRET)); +// return apiApplicationKey; +// } else { +// return null; +// } +// } catch (ParseException e) { +// throw new RuntimeException(e); +// } +// } +// +// } catch (IOException | NoSuchAlgorithmException | KeyStoreException | +// KeyManagementException e) { +// log.error("failed to call http client.", e); +// } return null; } From f1120baec3878dbfe5ca5709c8b47fa8cce85a84 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 10 Apr 2023 09:33:51 +0530 Subject: [PATCH 12/29] Implement exception handling --- .../pom.xml | 4 + .../APIApplicationServices.java | 8 +- .../APIApplicationServicesImpl.java | 82 +++++++++- .../PublisherRESTAPIServices.java | 140 ++++-------------- .../APIApplicationServicesException.java | 12 ++ .../exceptions/BadRequestException.java | 34 +++++ .../webapp/publisher/APIPublisherService.java | 1 + .../publisher/APIPublisherServiceImpl.java | 23 ++- .../publisher/APIPublisherStartupHandler.java | 1 + 9 files changed, 180 insertions(+), 125 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/APIApplicationServicesException.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml index e5fec434f0..002909f644 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml @@ -78,6 +78,10 @@ io.github.openfeign feign-okhttp + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java index 342f5aa954..5ca41cf6e2 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java @@ -2,12 +2,14 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials(); + APIApplicationKey createAndRetrieveApplicationCredentials() throws BadRequestException, APIApplicationServicesException; - AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret); - AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret); + AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIApplicationServicesException; + AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIApplicationServicesException; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java index 8932384f6d..55c544d25b 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java @@ -5,6 +5,8 @@ import io.entgra.devicemgt.apimgt.extension.publisher.api.bean.RegistrationProfi import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import io.entgra.devicemgt.apimgt.extension.publisher.api.util.PublisherRESTAPIUtil; import okhttp3.*; import org.apache.commons.logging.Log; @@ -37,6 +39,7 @@ import java.util.*; public class APIApplicationServicesImpl implements APIApplicationServices { private static final Log log = LogFactory.getLog(APIApplicationServicesImpl.class); +<<<<<<< HEAD private static final OkHttpClient client = getOkHttpClient(); private static OkHttpClient getOkHttpClient() { @@ -57,6 +60,13 @@ public class APIApplicationServicesImpl implements APIApplicationServices { .sslSocketFactory(getSimpleTrustedSSLSocketFactory(), trustAllCerts) .hostnameVerifier((hostname, sslSession) -> true).build(); } +======= +// private final OkHttpClient client; + +// public APIApplicationServicesImpl() { +// this.client = new OkHttpClient(); +// } +>>>>>>> e76624c1de (Add exceptions) private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { try { @@ -82,7 +92,8 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey createAndRetrieveApplicationCredentials() { + public APIApplicationKey createAndRetrieveApplicationCredentials() + throws APIApplicationServicesException, BadRequestException { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("callbackUrl",Constants.EMPTY_STRING); @@ -109,6 +120,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { // JSONObject responseObj = new JSONObject(Objects.requireNonNull(response.body()).string()); +<<<<<<< HEAD } catch (IOException e) { throw new RuntimeException(e); } @@ -159,10 +171,54 @@ public class APIApplicationServicesImpl implements APIApplicationServices { // log.error("failed to call http client.", e); // } return null; +======= + String jsonString = registrationProfile.toJSON(); + StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); + request.setEntity(entity); + + //ToDo: Remove hardcoded value + String basicAuth = getBase64Encode("admin", "admin"); + request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_VALUE_PREFIX + basicAuth); + request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); + + HttpResponse httpResponse = httpclient.execute(request); + + if (httpResponse != null) { + String response = PublisherRESTAPIUtil.getResponseString(httpResponse); + try { + if(response != null){ + JSONParser jsonParser = new JSONParser(); + JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); + APIApplicationKey apiApplicationKey = new APIApplicationKey(); + apiApplicationKey.setClientId((String) jsonPayload.get(Constants.CLIENT_ID)); + apiApplicationKey.setClientSecret((String) jsonPayload.get(Constants.CLIENT_SECRET)); + return apiApplicationKey; + } else { + String msg = "Request payload is null. Please verify the request payload."; + log.error(msg); + throw new BadRequestException(msg); + } + } catch (ParseException e) { + throw new APIApplicationServicesException("Error when parsing the response " + response, e); + } + } else { + return null; + } + } catch (IOException e) { + throw new APIApplicationServicesException("Error when reading the response from buffer.", e); + } catch (KeyStoreException e) { + throw new APIApplicationServicesException("Failed loading the keystore.", e); + } catch (NoSuchAlgorithmException e) { + throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); + } catch (KeyManagementException e) { + throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); + } +>>>>>>> e76624c1de (Add exceptions) } @Override - public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) { + public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) + throws APIApplicationServicesException { List params = new ArrayList<>(); params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE)); //ToDo: Remove hardcoded value @@ -173,7 +229,8 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String consumerKey, String consumerSecret) { + public AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String consumerKey, String consumerSecret) + throws APIApplicationServicesException { List params = new ArrayList<>(); params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE)); params.add(new BasicNameValuePair(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken)); @@ -181,8 +238,10 @@ public class APIApplicationServicesImpl implements APIApplicationServices { return getToken(params, consumerKey, consumerSecret); } - public AccessTokenInfo getToken(List nameValuePairs, String clientId, String clientSecret) { + public AccessTokenInfo getToken(List nameValuePairs, String clientId, String clientSecret) + throws APIApplicationServicesException{ + String response = null; try { URL url = new URL("https://localhost:9443/oauth2/token"); HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); @@ -193,7 +252,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { request.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse httpResponse = httpclient.execute(request); - String response = PublisherRESTAPIUtil.getResponseString(httpResponse); + response = PublisherRESTAPIUtil.getResponseString(httpResponse); if (log.isDebugEnabled()) { log.debug(response); } @@ -210,9 +269,16 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } return accessTokenInfo; - } catch (IOException | KeyStoreException | NoSuchAlgorithmException | - KeyManagementException| ParseException e) { - throw new RuntimeException(e); + } catch (IOException e) { + throw new APIApplicationServicesException("Error when reading the response from buffer.", e); + } catch (KeyStoreException e) { + throw new APIApplicationServicesException("Failed loading the keystore.", e); + } catch (NoSuchAlgorithmException e) { + throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); + } catch (ParseException e) { + throw new APIApplicationServicesException("Error when parsing the response " + response, e); + } catch (KeyManagementException e) { + throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java index 335680a84d..6e37e01986 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java @@ -3,9 +3,10 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api; import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import io.entgra.devicemgt.apimgt.extension.publisher.api.util.PublisherRESTAPIUtil; import io.entgra.devicemgt.apimgt.extension.publisher.api.util.ScopeUtils; -import org.apache.axis2.databinding.types.xsd._boolean; import org.apache.commons.httpclient.HttpStatus; import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpHead; @@ -28,104 +29,8 @@ import java.security.NoSuchAlgorithmException; public class PublisherRESTAPIServices { private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); -// private String clientId; -// private String clientSecret; -// private String accessToken; -// -// public AccessTokenInfo registerApplication() { -// -// try { -// URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); -// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); -// HttpPost request = new HttpPost(url.toString()); -// -// RegistrationProfile registrationProfile = new RegistrationProfile(); -// registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); -// registrationProfile.setClientName(Constants.CLIENT_NAME); -// registrationProfile.setGrantType(Constants.GRANT_TYPE); -// registrationProfile.setOwner(Constants.OWNER); -// registrationProfile.setIsSaasApp(true); -// -// String jsonString = registrationProfile.toJSON(); -// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); -// request.setEntity(entity); -// -// String basicAuth = getBase64Encode("admin", "admin"); -// -// request.setHeader("Authorization", "Basic " + basicAuth); -// request.setHeader("Content-Type", "application/json"); -// -// HttpResponse httpResponse = httpclient.execute(request); -// -// if (httpResponse != null) { -// -// String response = PublisherRESTAPIUtil.getResponseString(httpResponse); -// try { -// if(response != null){ -// JSONParser jsonParser = new JSONParser(); -// JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); -// clientId = (String) jsonPayload.get(Constants.CLIENT_ID); -// clientSecret = (String) jsonPayload.get(Constants.CLIENT_SECRET); -// } -// } catch (ParseException e) { -// throw new RuntimeException(e); -// } -// System.out.println(response); -// } -// System.out.println(httpResponse.getStatusLine().getStatusCode()); -// -// } catch (IOException | NoSuchAlgorithmException | KeyStoreException | -// KeyManagementException e) { -// log.error("failed to call http client.", e); -// } -// return getAccessTokenFromRegisteredApplication(clientId, clientSecret); -// -// } -// -// public AccessTokenInfo getAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) { -// List params = new ArrayList<>(); -// params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE)); -// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin")); -// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin")); -// params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); -// return getToken(params, consumerKey, consumerSecret); -// } -// -// public AccessTokenInfo getToken(List nameValuePairs, String clientId, String clientSecret) { -// -// String token = null; -// String response = null; -// try { -// URL url = new URL("https://localhost:9443/oauth2/token"); -// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); -// HttpPost request = new HttpPost(url.toString()); -// -// request.addHeader("Authorization", "Basic " + getBase64Encode(clientId, clientSecret)); -// request.addHeader("Content-Type", "application/x-www-form-urlencoded"); -// request.setEntity(new UrlEncodedFormEntity(nameValuePairs)); -// HttpResponse httpResponse = httpclient.execute(request); -// response = PublisherRESTAPIUtil.getResponseString(httpResponse); -// JSONParser jsonParser = new JSONParser(); -// JSONObject jsonObject = (JSONObject) jsonParser.parse(response); -// AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); -// token = (String) jsonObject.get(Constants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); -// if (token != null && !token.isEmpty()){ -// accessTokenInfo.setRefreshToken(token); -// accessTokenInfo.setRefreshToken((String) jsonObject.get(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); -// accessTokenInfo.setExpiresIn((Long) jsonObject.get(Constants.OAUTH_EXPIRES_IN)); -// accessTokenInfo.setTokenType((String) jsonObject.get(Constants.OAUTH_TOKEN_TYPE)); -// accessTokenInfo.setScope((String) jsonObject.get(Constants.OAUTH_TOKEN_SCOPE)); -// } -// accessToken = token; -// return accessTokenInfo; -// -// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | -// KeyManagementException| ParseException e) { -// throw new RuntimeException(e); -// } -// } - - public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key){ + public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) + throws APIApplicationServicesException, BadRequestException { String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; @@ -144,19 +49,28 @@ public class PublisherRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret() ); return isSharedScopeNameExists(apiApplicationKey,refreshedAccessToken, key); - } else{ + } else if (HttpStatus.SC_BAD_REQUEST == httpResponse.getStatusLine().getStatusCode()){ + String response = httpResponse.toString(); + log.info(response); + throw new BadRequestException(response); + } else { return false; } - } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { - throw new RuntimeException(e); + } catch (IOException e) { + throw new APIApplicationServicesException("Error when reading the response from buffer.", e); + } catch (KeyStoreException e) { + throw new APIApplicationServicesException("Failed loading the keystore.", e); + } catch (NoSuchAlgorithmException e) { + throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); + } catch (KeyManagementException e) { + throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); } } - public void updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope){ + public void updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) + throws APIApplicationServicesException, BadRequestException { -// String keyValue = new String(Base64.encodeBase64((scope.getKey()).getBytes())).replace("=", ""); -// String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + scope.getId(); try { URL url = new URL(updateScopeUrl); @@ -182,16 +96,20 @@ public class PublisherRESTAPIServices { AccessTokenInfo accessTokenInfo1 = apiApplicationServices. generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret() ); updateSharedScope(apiApplicationKey, accessTokenInfo1, scope); - } else { + } else if (HttpStatus.SC_BAD_REQUEST == httpResponse.getStatusLine().getStatusCode()){ String response = httpResponse.toString(); log.info(response); + throw new BadRequestException(response); } - } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { - throw new RuntimeException(e); + } catch (IOException e) { + throw new APIApplicationServicesException("Error when reading the response from buffer.", e); + } catch (KeyStoreException e) { + throw new APIApplicationServicesException("Failed loading the keystore.", e); + } catch (NoSuchAlgorithmException e) { + throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); + } catch (KeyManagementException e) { + throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); } } -// static String getBase64Encode(String key, String value) { -// return new String(Base64.encodeBase64((key + ":" + value).getBytes())); -// } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/APIApplicationServicesException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/APIApplicationServicesException.java new file mode 100644 index 0000000000..bd7aa85cd9 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/APIApplicationServicesException.java @@ -0,0 +1,12 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions; + +public class APIApplicationServicesException extends Exception{ + + public APIApplicationServicesException() {super();} + + public APIApplicationServicesException(String message) {super();} + + public APIApplicationServicesException(String message, Throwable cause){super();} + + public APIApplicationServicesException(Throwable cause){super();} +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java new file mode 100644 index 0000000000..1e58e27d7b --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java @@ -0,0 +1,34 @@ +/* + * + * * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * * + * * Entgra (Pvt) Ltd. 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. + * + * + */ + +/** + * Custom exception class for handling bad request exceptions. + */ +package io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions; + +public class BadRequestException extends Exception { + + private static final long serialVersionUID = -2387103750774855056L; + + public BadRequestException(String errorMessage) { + super(errorMessage); + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java index a7299501bd..85dcf72d13 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java @@ -19,6 +19,7 @@ package org.wso2.carbon.apimgt.webapp.publisher; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; /** diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index ea7f2e1108..c6f16436a1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -23,6 +23,8 @@ import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -361,10 +363,21 @@ public class APIPublisherServiceImpl implements APIPublisherService { WebappPublisherConfig config = WebappPublisherConfig.getInstance(); List tenants = new ArrayList<>(Collections.singletonList(APIConstants.SUPER_TENANT_DOMAIN)); tenants.addAll(config.getTenants().getTenant()); + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - APIApplicationKey apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); - AccessTokenInfo accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + APIApplicationKey apiApplicationKey; + AccessTokenInfo accessTokenInfo; + try { + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + } catch (BadRequestException e) { + String errorMsg = "Error while generating application"; + log.error(errorMsg, e); + throw new APIManagerPublisherException(e); + } catch (APIApplicationServicesException e) { + throw new RuntimeException(e); + } try { for (String tenantDomain : tenants) { @@ -433,6 +446,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } catch (IOException | DirectoryIteratorException ex) { log.error("failed to read scopes from file.", ex); + } catch (APIApplicationServicesException | BadRequestException e) { + String errorMsg = "Error while generating an OAuth token"; + log.error(errorMsg, e); + throw new APIManagerPublisherException(e); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index bfcafcc2c8..a530fa5b47 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -19,6 +19,7 @@ package org.wso2.carbon.apimgt.webapp.publisher; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; From 0d7057640110c7ee92f59867fde681a20a124bd7 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 17 Apr 2023 09:49:43 +0530 Subject: [PATCH 13/29] change http client to okhttp --- .../pom.xml | 15 +- .../APIApplicationServices.java | 3 +- .../APIApplicationServicesImpl.java | 104 +++++++++--- .../PublisherAPIServiceStartupHandler.java | 159 ------------------ .../PublisherRESTAPIServices.java | 111 +++++------- .../dto/APIApplicationKey.java | 70 +++++++- .../exceptions/BadRequestException.java | 2 + .../internal/PublisherRESTAPIDataHolder.java | 30 ++++ .../PublisherRESTAPIServiceComponent.java | 23 +-- .../pom.xml | 5 + .../publisher/APIPublisherServiceImpl.java | 9 +- .../publisher/APIPublisherStartupHandler.java | 10 +- components/apimgt-extensions/pom.xml | 46 ----- 13 files changed, 264 insertions(+), 323 deletions(-) delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml index 002909f644..8e25736b1f 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml @@ -79,8 +79,13 @@ feign-okhttp +<<<<<<< HEAD org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api +======= + org.json.wso2 + json +>>>>>>> 2855ef0a30 (change http client to okhttp) @@ -110,7 +115,6 @@ javax.net.ssl, - org.apache.commons.logging, org.apache.http;version="${httpclient.version.range}", org.apache.http.client;version="${httpclient.version.range}", @@ -123,17 +127,12 @@ org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - - org.wso2.carbon.core, org.apache.commons.ssl, - - - - org.apache.commons.httpclient, org.wso2.carbon.apimgt.api.model, - okhttp3.* + okhttp3.*, + org.json diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java index 5ca41cf6e2..401f680214 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java @@ -3,11 +3,10 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials() throws BadRequestException, APIApplicationServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials() throws APIApplicationServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIApplicationServicesException; AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIApplicationServicesException; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java index 55c544d25b..c2aa63c432 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java @@ -1,48 +1,109 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api; -import com.google.gson.JsonObject; -import io.entgra.devicemgt.apimgt.extension.publisher.api.bean.RegistrationProfile; +import com.google.gson.Gson; +import org.json.JSONObject; import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; -import io.entgra.devicemgt.apimgt.extension.publisher.api.util.PublisherRESTAPIUtil; import okhttp3.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.ssl.Base64; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicNameValuePair; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import java.io.IOException; -import java.net.URL; import java.security.KeyManagementException; -import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.util.*; public class APIApplicationServicesImpl implements APIApplicationServices { private static final Log log = LogFactory.getLog(APIApplicationServicesImpl.class); <<<<<<< HEAD private static final OkHttpClient client = getOkHttpClient(); + private static final Gson gson = new Gson(); + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + String msg = null; + // private ApiApplicationConfigurations ApplicationConfig = null; - private static OkHttpClient getOkHttpClient() { + @Override + public APIApplicationKey createAndRetrieveApplicationCredentials() + throws APIApplicationServicesException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("callbackUrl", Constants.EMPTY_STRING); + jsonObject.put("clientName",Constants.CLIENT_NAME); + jsonObject.put("grantType",Constants.GRANT_TYPE); + jsonObject.put("owner",Constants.OWNER); + jsonObject.put("saasApp",true); + + RequestBody requestBody = RequestBody.Companion.create(jsonObject.toString(), JSON); + String keyManagerEndpoint = "https://localhost:9443/client-registration/v0.17/register"; + + Request request = new Request.Builder() + .url(keyManagerEndpoint) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic("admin", "admin")) + .post(requestBody) + .build(); + try { + Response response = client.newCall(request).execute(); + return gson.fromJson(response.body().string(), APIApplicationKey.class); + } catch (IOException e) { + msg = "Error occurred while processing the response"; + throw new APIApplicationServicesException(msg); + } + } + + @Override + public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) + throws APIApplicationServicesException { + JSONObject params = new JSONObject(); + params.put(Constants.GRANT_TYPE_PARAM_NAME,Constants.PASSWORD_GRANT_TYPE); + //ToDo: Remove hardcoded value + params.put(Constants.PASSWORD_GRANT_TYPE_USERNAME,"admin"); + params.put(Constants.PASSWORD_GRANT_TYPE_PASSWORD,"admin"); + params.put(Constants.SCOPE_PARAM_NAME,Constants.SCOPES); + return getToken(params, consumerKey, consumerSecret); + } + + @Override + public AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String consumerKey, String consumerSecret) + throws APIApplicationServicesException { + + JSONObject params = new JSONObject(); + params.put(Constants.GRANT_TYPE_PARAM_NAME,Constants.REFRESH_TOKEN_GRANT_TYPE); + //ToDo: Remove hardcoded value + params.put(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken); + params.put(Constants.SCOPE_PARAM_NAME,Constants.SCOPES); + return getToken(params, consumerKey, consumerSecret); + } + + public AccessTokenInfo getToken(JSONObject nameValuePairs, String clientId, String clientSecret) + throws APIApplicationServicesException{ + + RequestBody requestBody = RequestBody.Companion.create(nameValuePairs.toString(), JSON); + //application/x-www-form-urlencoded + String keyManagerEndpoint = "https://localhost:9443/oauth2/token"; + + Request request = new Request.Builder() + .url(keyManagerEndpoint) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(clientId, clientSecret)) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + return gson.fromJson(response.body().string(), AccessTokenInfo.class); + } catch (IOException e) { + msg = "Error occurred while processing the response"; + throw new APIApplicationServicesException(msg); + } + } + + protected static OkHttpClient getOkHttpClient() { X509TrustManager trustAllCerts = new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return new java.security.cert.X509Certificate[0]; @@ -91,6 +152,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } } +<<<<<<< HEAD @Override public APIApplicationKey createAndRetrieveApplicationCredentials() throws APIApplicationServicesException, BadRequestException { @@ -285,4 +347,6 @@ public class APIApplicationServicesImpl implements APIApplicationServices { static String getBase64Encode(String key, String value) { return new String(Base64.encodeBase64((key + ":" + value).getBytes())); } +======= +>>>>>>> 2855ef0a30 (change http client to okhttp) } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java deleted file mode 100644 index 2b005b0cc0..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherAPIServiceStartupHandler.java +++ /dev/null @@ -1,159 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api; - -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.core.ServerStartupObserver; - -public class PublisherAPIServiceStartupHandler implements ServerStartupObserver { - - private static final Log log = LogFactory.getLog(PublisherAPIServiceStartupHandler.class); - private PublisherRESTAPIServices publisherRESTAPIServices; - private AccessTokenInfo accessTokenInfo; - - @Override - public void completingServerStartup() { - - } - - @Override - public void completedServerStartup() { - -// String cid = null; -// String cS = null; -// String token = null; -// AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); -// -// try { -// URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); -// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); -// HttpPost request = new HttpPost(url.toString()); -// -// RegistrationProfile registrationProfile = new RegistrationProfile(); -// registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); -// registrationProfile.setClientName(Constants.CLIENT_NAME); -// registrationProfile.setOwner(Constants.OWNER); -// registrationProfile.setGrantType(Constants.GRANT_TYPE); -// registrationProfile.setIsSaasApp(true); -// -// String jsonString = registrationProfile.toJSON(); -// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); -// request.setEntity(entity); -// -// String basicAuth = PublisherRESTAPIServices.getBase64Encode("admin", "admin"); -// -// request.setHeader("Authorization", "Basic " + basicAuth); -// request.setHeader("Content-Type", "application/json"); -// -// HttpResponse httpResponse = httpclient.execute(request); -// -// if (httpResponse != null) { -// -// String response = PublisherRESTAPIUtil.getResponseString(httpResponse); -// try { -// if(response != null){ -// JSONParser jsonParser = new JSONParser(); -// JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); -// String clientId = (String) jsonPayload.get(Constants.CLIENT_ID); -// String clientSecret = (String) jsonPayload.get(Constants.CLIENT_SECRET); -// cid = clientId; -// cS = clientSecret; -// } -// } catch (ParseException e) { -// throw new RuntimeException(e); -// } -// -// System.out.println(response); -// } -// System.out.println(httpResponse.getStatusLine().getStatusCode()); -// -// -// } catch (IOException | NoSuchAlgorithmException | KeyStoreException | -// KeyManagementException e) { -// log.error("failed to call http client.", e); -// } -// -// -// String response = null; -// -// List params = new ArrayList<>(); -// params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE)); -// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin")); -// params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin")); -// params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); -// try { -// URL url = new URL("https://localhost:9443/oauth2/token"); -// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); -// HttpPost request = new HttpPost(url.toString()); -// -// request.addHeader("Authorization", "Basic " + PublisherRESTAPIServices.getBase64Encode(cid, cS)); -// request.addHeader("Content-Type", "application/x-www-form-urlencoded"); -// request.setEntity(new UrlEncodedFormEntity(params)); -// HttpResponse httpResponse = httpclient.execute(request); -// response = PublisherRESTAPIUtil.getResponseString(httpResponse); -// JSONParser jsonParser = new JSONParser(); -// JSONObject jsonObject = (JSONObject) jsonParser.parse(response); -// token = (String) jsonObject.get(Constants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); -// if (token != null && !token.isEmpty()){ -// accessTokenInfo.setRefreshToken(token); -// accessTokenInfo.setRefreshToken((String) jsonObject.get(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); -// accessTokenInfo.setExpiresIn((Long) jsonObject.get(Constants.OAUTH_EXPIRES_IN)); -// accessTokenInfo.setTokenType((String) jsonObject.get(Constants.OAUTH_TOKEN_TYPE)); -// accessTokenInfo.setScope((String) jsonObject.get(Constants.OAUTH_TOKEN_SCOPE)); -// } -// System.out.println(accessTokenInfo); -// -// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | -// KeyManagementException| ParseException e) { -// throw new RuntimeException(e); -// } -// -// String key = "perm:sms-handler:view-configuration"; -// String value = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); -// -// -// String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + value; -// try { -// URL url = new URL(getScopeUrl); -// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); -// HttpHead request = new HttpHead(url.toString()); -// -// request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token); -// HttpResponse httpResponse = httpclient.execute(request); -// -// String code = String.valueOf(httpResponse.getStatusLine().getStatusCode()); -// System.out.println(code); -// -// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { -// throw new RuntimeException(e); -// } -// -// String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + "27fce6f1-6741-4ad5-b700-a56427fd3dbb"; -// try { -// URL url = new URL(updateScopeUrl); -// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); -// HttpPut request = new HttpPut(url.toString()); -// -// request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token); -// request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); -// -// -// String jsonString = "{\"name\": \"" + "name" + "\",\"displayName\": \"" + "displayname" + -// "\", \"description\": \"" + "description" + "\"," + "\"bindings\": [" + -// "\"Internal/devicemgt-user\"]}"; -// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); -// request.setEntity(entity); -// -// HttpResponse httpResponse = httpclient.execute(request); -// int code = httpResponse.getStatusLine().getStatusCode(); -// System.out.println(code); -// } catch (IOException | KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) { -// throw new RuntimeException(e); -// } - - -// publisherRESTAPIServices = new PublisherRESTAPIServices(); -// publisherRESTAPIServices.isSharedScopeNameExists("perm:sms-handler:view-configuration"); - - } -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java index 6e37e01986..a0bb43217d 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java @@ -5,111 +5,92 @@ import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; -import io.entgra.devicemgt.apimgt.extension.publisher.api.util.PublisherRESTAPIUtil; -import io.entgra.devicemgt.apimgt.extension.publisher.api.util.ScopeUtils; +import okhttp3.*; import org.apache.commons.httpclient.HttpStatus; -import org.apache.http.HttpHeaders; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpPut; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.ssl.Base64; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; +import org.json.JSONObject; import org.wso2.carbon.apimgt.api.model.Scope; import java.io.IOException; -import java.net.URL; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; +import static io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl.getOkHttpClient; public class PublisherRESTAPIServices { private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); + private static final OkHttpClient client = getOkHttpClient(); + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) throws APIApplicationServicesException, BadRequestException { String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; - try { - URL url = new URL(getScopeUrl); - HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); - HttpHead request = new HttpHead(url.toString()); - - request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessTokenInfo.getAccessToken()); - HttpResponse httpResponse = httpclient.execute(request); - if (HttpStatus.SC_OK == httpResponse.getStatusLine().getStatusCode()){ + Request request = new Request.Builder() + .url(getScopeUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccessToken()) + .head() + .build(); + try { + Response response = client.newCall(request).execute(); + if (response.code() == HttpStatus.SC_OK){ return true; - } else if(HttpStatus.SC_UNAUTHORIZED == httpResponse.getStatusLine().getStatusCode()) { + }else if(HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret() ); + //max attempt count return isSharedScopeNameExists(apiApplicationKey,refreshedAccessToken, key); - } else if (HttpStatus.SC_BAD_REQUEST == httpResponse.getStatusLine().getStatusCode()){ - String response = httpResponse.toString(); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()){ log.info(response); - throw new BadRequestException(response); + throw new BadRequestException(response.toString()); } else { return false; } - } catch (IOException e) { - throw new APIApplicationServicesException("Error when reading the response from buffer.", e); - } catch (KeyStoreException e) { - throw new APIApplicationServicesException("Failed loading the keystore.", e); - } catch (NoSuchAlgorithmException e) { - throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); - } catch (KeyManagementException e) { - throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); + String msg = "Error occurred while processing the response"; + throw new APIApplicationServicesException(msg); } } - public void updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) + public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) throws APIApplicationServicesException, BadRequestException { String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + scope.getId(); - try { - URL url = new URL(updateScopeUrl); - HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); - HttpPut request = new HttpPut(url.toString()); - request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + - accessTokenInfo.getAccessToken()); - request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); + JSONObject setScope = new JSONObject(); + setScope.put("name", scope.getKey()); + setScope.put("displayName", scope.getName()); + setScope.put("description", scope.getDescription()); + setScope.put("bindings", scope.getRoles()); + - ScopeUtils setScope = new ScopeUtils(); - setScope.setKey(scope.getKey()); - setScope.setName(scope.getName()); - setScope.setDescription(scope.getDescription()); - setScope.setRoles(scope.getRoles()); - String jsonString = setScope.toJSON(); - StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); - request.setEntity(entity); + RequestBody requestBody = RequestBody.Companion.create(setScope.toString(), JSON); + Request request = new Request.Builder() + .url(updateScopeUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccessToken()) + .put(requestBody) + .build(); - HttpResponse httpResponse = httpclient.execute(request); - if (HttpStatus.SC_OK != httpResponse.getStatusLine().getStatusCode() && HttpStatus.SC_UNAUTHORIZED == httpResponse.getStatusLine().getStatusCode()){ + try { + Response response = client.newCall(request).execute(); + if (response.code() == HttpStatus.SC_OK) { + return true; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo accessTokenInfo1 = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret() ); - updateSharedScope(apiApplicationKey, accessTokenInfo1, scope); - } else if (HttpStatus.SC_BAD_REQUEST == httpResponse.getStatusLine().getStatusCode()){ - String response = httpResponse.toString(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { log.info(response); - throw new BadRequestException(response); + throw new BadRequestException(response.toString()); + } else { + return false; } - } catch (IOException e) { - throw new APIApplicationServicesException("Error when reading the response from buffer.", e); - } catch (KeyStoreException e) { - throw new APIApplicationServicesException("Failed loading the keystore.", e); - } catch (NoSuchAlgorithmException e) { - throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); - } catch (KeyManagementException e) { - throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); + String msg = "Error occurred while processing the response"; + throw new APIApplicationServicesException(msg); } } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java index fdd20f2f22..d0fc3b9f68 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java @@ -4,9 +4,20 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api.dto; * This holds api application consumer id and secret. */ public class APIApplicationKey { - + private String clientName; private String clientId; private String clientSecret; + private String callBackURL; + private String isSaasApplication; + private String appOwner; + private String jsonString; + private String jsonAppAttribute; + private String tokenType; + + public APIApplicationKey(String clientId, String clientSecret){ + this.clientId = clientId; + this.clientSecret = clientSecret; + } public String getClientId() { return clientId; @@ -23,4 +34,61 @@ public class APIApplicationKey { public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; } + public String getClientName() { + return clientName; + } + + public void setClientName(String clientName) { + this.clientName = clientName; + } + + + public String getCallBackURL() { + return callBackURL; + } + + public void setCallBackURL(String callBackURL) { + this.callBackURL = callBackURL; + } + + public String getIsSaasApplication() { + return isSaasApplication; + } + + public void setIsSaasApplication(String isSaasApplication) { + this.isSaasApplication = isSaasApplication; + } + + public String getAppOwner() { + return appOwner; + } + + public void setAppOwner(String appOwner) { + this.appOwner = appOwner; + } + + public String getJsonString() { + return jsonString; + } + + public void setJsonString(String jsonString) { + this.jsonString = jsonString; + } + + public String getJsonAppAttribute() { + return jsonAppAttribute; + } + + public void setJsonAppAttribute(String jsonAppAttribute) { + this.jsonAppAttribute = jsonAppAttribute; + } + + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java index 1e58e27d7b..427c4b5e35 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java @@ -24,6 +24,8 @@ */ package io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions; +import okhttp3.Response; + public class BadRequestException extends Exception { private static final long serialVersionUID = -2387103750774855056L; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java new file mode 100644 index 0000000000..885f3ead7a --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java @@ -0,0 +1,30 @@ +package io.entgra.devicemgt.apimgt.extension.publisher.api.internal; + +import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; +import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; + +public class PublisherRESTAPIDataHolder { + + private static final PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder(); + + private APIApplicationServices apiApplicationServices; +// +// private PublisherRESTAPIServices publisherRESTAPIServices; + + public static PublisherRESTAPIDataHolder getInstance(){ + return thisInstance; + } + public APIApplicationServices getApiApplicationServices() { + return apiApplicationServices; + } + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { + this.apiApplicationServices = apiApplicationServices; + } +// public PublisherRESTAPIServices getPublisherRESTAPIServices() { +// return publisherRESTAPIServices; +// } +// public void setPublisherRESTAPIServices(PublisherRESTAPIServices publisherRESTAPIServices) { +// this.publisherRESTAPIServices = publisherRESTAPIServices; +// } + +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java index 612f77a8d9..d34012c1f4 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java @@ -1,13 +1,12 @@ package io.entgra.devicemgt.apimgt.extension.publisher.api.internal; +import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; +import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl; import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; -import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherAPIServiceStartupHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.core.ServerShutdownHandler; -import org.wso2.carbon.core.ServerStartupObserver; /** * @scr.component name="io.entgra.devicemgt.apimgt.extension.publisher.api.internal.PublisherRESTAPIServiceComponent" @@ -24,17 +23,19 @@ public class PublisherRESTAPIServiceComponent { try { BundleContext bundleContext = componentContext.getBundleContext(); - PublisherAPIServiceStartupHandler publisherAPIServiceStartupHandler = new PublisherAPIServiceStartupHandler(); - bundleContext.registerService(PublisherAPIServiceStartupHandler.class.getName(), publisherAPIServiceStartupHandler, null); - bundleContext.registerService(ServerStartupObserver.class.getName(), publisherAPIServiceStartupHandler, null); - bundleContext.registerService(ServerShutdownHandler.class.getName(), publisherAPIServiceStartupHandler, null); - - PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); - bundleContext.registerService(PublisherRESTAPIServices.class.getName(), publisherRESTAPIServices, null); +// PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); +// bundleContext.registerService(PublisherRESTAPIServices.class.getName(), publisherRESTAPIServices, null); +// PublisherRESTAPIDataHolder.getInstance().setPublisherRESTAPIServices(publisherRESTAPIServices); + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + bundleContext.registerService(APIApplicationServices.class.getName(), apiApplicationServices, null); + PublisherRESTAPIDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); + if (log.isDebugEnabled()) { + log.debug("API Application bundle has been successfully initialized"); + } } catch (Exception e) { - throw new RuntimeException(e); + log.error("Error occurred while initializing API Application bundle", e); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 0ca58492f5..d9246c253a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -126,6 +126,10 @@ org.wso2.carbon.devicemgt io.entgra.devicemgt.apimgt.extension.publisher.api + + org.wso2.carbon.devicemgt + io.entgra.devicemgt.apimgt.extension.publisher.api + @@ -171,6 +175,7 @@ org.w3c.dom, io.entgra.devicemgt.apimgt.extension.publisher.api, io.entgra.devicemgt.apimgt.extension.publisher.api.dto, + io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions, org.wso2.carbon.apimgt.annotations.api, org.wso2.carbon.apimgt.api, org.wso2.carbon.apimgt.api.model, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index c6f16436a1..2fe4883df5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -371,12 +371,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - } catch (BadRequestException e) { + } catch (APIApplicationServicesException e) { String errorMsg = "Error while generating application"; log.error(errorMsg, e); throw new APIManagerPublisherException(e); - } catch (APIApplicationServicesException e) { - throw new RuntimeException(e); } try { @@ -384,9 +382,6 @@ public class APIPublisherServiceImpl implements APIPublisherService { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); -// APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(MultitenantUtils.getTenantAwareUsername( -// PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration() -// .getAdminUserName())); try { String fileName = @@ -447,7 +442,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { } catch (IOException | DirectoryIteratorException ex) { log.error("failed to read scopes from file.", ex); } catch (APIApplicationServicesException | BadRequestException e) { - String errorMsg = "Error while generating an OAuth token"; + String errorMsg = "Error while Calling APIs"; log.error(errorMsg, e); throw new APIManagerPublisherException(e); } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index a530fa5b47..3933f60716 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -19,6 +19,11 @@ package org.wso2.carbon.apimgt.webapp.publisher; +import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; +import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,10 +58,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.debug("Total number of unpublished APIs: " + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); } - try { - } catch (Exception e) { - throw new RuntimeException(e); - } + publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); int retryCount = 0; while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) { diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 747eb843dd..ae822fd4eb 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -25,52 +25,6 @@ 5.0.26-SNAPSHOT ../../pom.xml - - - org.apache.httpcomponents.wso2 - httpcore - - - org.wso2.orbit.org.apache.httpcomponents - httpclient - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.wso2.carbon - org.wso2.carbon.core - - - com.googlecode.json-simple.wso2 - json-simple - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - - - com.squareup.okhttp3 - okhttp - - - io.github.openfeign - feign-okhttp - - 4.0.0 apimgt-extensions From e920df6da3ff4a9d8f104e9e8027c3e1e6dacfc4 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 17 Apr 2023 13:31:49 +0530 Subject: [PATCH 14/29] Minor changes --- .../pom.xml | 7 +- .../APIApplicationServicesImpl.java | 212 +----------------- .../pom.xml | 5 +- components/apimgt-extensions/pom.xml | 18 ++ 4 files changed, 26 insertions(+), 216 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml index 8e25736b1f..0b2d3f034b 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.21-SNAPSHOT + 5.0.25-SNAPSHOT ../pom.xml @@ -79,13 +79,12 @@ feign-okhttp -<<<<<<< HEAD org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api -======= + + org.json.wso2 json ->>>>>>> 2855ef0a30 (change http client to okhttp) diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java index c2aa63c432..5e6439edbb 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java @@ -9,7 +9,6 @@ import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicat import okhttp3.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.commons.ssl.Base64; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; @@ -22,7 +21,6 @@ import java.security.NoSuchAlgorithmException; public class APIApplicationServicesImpl implements APIApplicationServices { private static final Log log = LogFactory.getLog(APIApplicationServicesImpl.class); -<<<<<<< HEAD private static final OkHttpClient client = getOkHttpClient(); private static final Gson gson = new Gson(); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); @@ -53,6 +51,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { return gson.fromJson(response.body().string(), APIApplicationKey.class); } catch (IOException e) { msg = "Error occurred while processing the response"; + log.error(msg); throw new APIApplicationServicesException(msg); } } @@ -86,10 +85,10 @@ public class APIApplicationServicesImpl implements APIApplicationServices { RequestBody requestBody = RequestBody.Companion.create(nameValuePairs.toString(), JSON); //application/x-www-form-urlencoded - String keyManagerEndpoint = "https://localhost:9443/oauth2/token"; + String tokenEndPoint = "https://localhost:9443/oauth2/token"; Request request = new Request.Builder() - .url(keyManagerEndpoint) + .url(tokenEndPoint) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(clientId, clientSecret)) .post(requestBody) .build(); @@ -99,6 +98,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { return gson.fromJson(response.body().string(), AccessTokenInfo.class); } catch (IOException e) { msg = "Error occurred while processing the response"; + log.error(msg); throw new APIApplicationServicesException(msg); } } @@ -121,13 +121,6 @@ public class APIApplicationServicesImpl implements APIApplicationServices { .sslSocketFactory(getSimpleTrustedSSLSocketFactory(), trustAllCerts) .hostnameVerifier((hostname, sslSession) -> true).build(); } -======= -// private final OkHttpClient client; - -// public APIApplicationServicesImpl() { -// this.client = new OkHttpClient(); -// } ->>>>>>> e76624c1de (Add exceptions) private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { try { @@ -152,201 +145,4 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } } -<<<<<<< HEAD - @Override - public APIApplicationKey createAndRetrieveApplicationCredentials() - throws APIApplicationServicesException, BadRequestException { - - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("callbackUrl",Constants.EMPTY_STRING); - jsonObject.addProperty("clientName",Constants.CLIENT_NAME); - jsonObject.addProperty("grantType",Constants.EMPTY_STRING); - jsonObject.addProperty("owner",Constants.OWNER); - jsonObject.addProperty("saasApp",true); - - MediaType jsonMediaType = MediaType.parse("application/json; charset=utf-8"); - RequestBody requestBody = RequestBody.create(jsonMediaType, jsonObject.toString()); - - String keyManagerEndpoint = "https://localhost:9443/client-registration/v0.17/register"; - - Request request = new Request.Builder() - .url(keyManagerEndpoint) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic("admin", "admin")) - .post(requestBody) - .build(); - try { - Response response = client.newCall(request).execute(); - System.out.println(request); - System.out.println("---------------------------"); - System.out.println(response); - -// JSONObject responseObj = new JSONObject(Objects.requireNonNull(response.body()).string()); - -<<<<<<< HEAD - } catch (IOException e) { - throw new RuntimeException(e); - } - -// try { -// URL url = new URL("https://localhost:9443/client-registration/v0.17/register"); -// HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); -// HttpPost request = new HttpPost(url.toString()); -// -// RegistrationProfile registrationProfile = new RegistrationProfile(); -// registrationProfile.setCallbackUrl(Constants.EMPTY_STRING); -// registrationProfile.setClientName(Constants.CLIENT_NAME); -// registrationProfile.setGrantType(Constants.GRANT_TYPE); -// registrationProfile.setOwner(Constants.OWNER); -// registrationProfile.setIsSaasApp(true); -// -// String jsonString = registrationProfile.toJSON(); -// StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); -// request.setEntity(entity); -// -// //ToDo: Remove hardcoded value -// String basicAuth = getBase64Encode("admin", "admin"); -// request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_VALUE_PREFIX + basicAuth); -// request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); -// -// HttpResponse httpResponse = httpclient.execute(request); -// -// if (httpResponse != null) { -// String response = PublisherRESTAPIUtil.getResponseString(httpResponse); -// try { -// if(response != null){ -// JSONParser jsonParser = new JSONParser(); -// JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); -// APIApplicationKey apiApplicationKey = new APIApplicationKey(); -// apiApplicationKey.setClientId((String) jsonPayload.get(Constants.CLIENT_ID)); -// apiApplicationKey.setClientSecret((String) jsonPayload.get(Constants.CLIENT_SECRET)); -// return apiApplicationKey; -// } else { -// return null; -// } -// } catch (ParseException e) { -// throw new RuntimeException(e); -// } -// } -// -// } catch (IOException | NoSuchAlgorithmException | KeyStoreException | -// KeyManagementException e) { -// log.error("failed to call http client.", e); -// } - return null; -======= - String jsonString = registrationProfile.toJSON(); - StringEntity entity = new StringEntity(jsonString, ContentType.APPLICATION_JSON); - request.setEntity(entity); - - //ToDo: Remove hardcoded value - String basicAuth = getBase64Encode("admin", "admin"); - request.setHeader(HttpHeaders.AUTHORIZATION, Constants.AUTHORIZATION_HEADER_VALUE_PREFIX + basicAuth); - request.setHeader(HttpHeaders.CONTENT_TYPE, Constants.APPLICATION_JSON); - - HttpResponse httpResponse = httpclient.execute(request); - - if (httpResponse != null) { - String response = PublisherRESTAPIUtil.getResponseString(httpResponse); - try { - if(response != null){ - JSONParser jsonParser = new JSONParser(); - JSONObject jsonPayload = (JSONObject) jsonParser.parse(response); - APIApplicationKey apiApplicationKey = new APIApplicationKey(); - apiApplicationKey.setClientId((String) jsonPayload.get(Constants.CLIENT_ID)); - apiApplicationKey.setClientSecret((String) jsonPayload.get(Constants.CLIENT_SECRET)); - return apiApplicationKey; - } else { - String msg = "Request payload is null. Please verify the request payload."; - log.error(msg); - throw new BadRequestException(msg); - } - } catch (ParseException e) { - throw new APIApplicationServicesException("Error when parsing the response " + response, e); - } - } else { - return null; - } - } catch (IOException e) { - throw new APIApplicationServicesException("Error when reading the response from buffer.", e); - } catch (KeyStoreException e) { - throw new APIApplicationServicesException("Failed loading the keystore.", e); - } catch (NoSuchAlgorithmException e) { - throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); - } catch (KeyManagementException e) { - throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); - } ->>>>>>> e76624c1de (Add exceptions) - } - - @Override - public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) - throws APIApplicationServicesException { - List params = new ArrayList<>(); - params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE)); - //ToDo: Remove hardcoded value - params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin")); - params.add(new BasicNameValuePair(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin")); - params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); - return getToken(params, consumerKey, consumerSecret); - } - - @Override - public AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String consumerKey, String consumerSecret) - throws APIApplicationServicesException { - List params = new ArrayList<>(); - params.add(new BasicNameValuePair(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE)); - params.add(new BasicNameValuePair(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken)); - params.add(new BasicNameValuePair(Constants.SCOPE_PARAM_NAME, Constants.SCOPES)); - return getToken(params, consumerKey, consumerSecret); - } - - public AccessTokenInfo getToken(List nameValuePairs, String clientId, String clientSecret) - throws APIApplicationServicesException{ - - String response = null; - try { - URL url = new URL("https://localhost:9443/oauth2/token"); - HttpClient httpclient = PublisherRESTAPIUtil.getHttpClient(url.getProtocol()); - HttpPost request = new HttpPost(url.toString()); - - request.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + getBase64Encode(clientId, clientSecret)); - request.addHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded"); - request.setEntity(new UrlEncodedFormEntity(nameValuePairs)); - - HttpResponse httpResponse = httpclient.execute(request); - response = PublisherRESTAPIUtil.getResponseString(httpResponse); - if (log.isDebugEnabled()) { - log.debug(response); - } - JSONParser jsonParser = new JSONParser(); - JSONObject jsonObject = (JSONObject) jsonParser.parse(response); - AccessTokenInfo accessTokenInfo = new AccessTokenInfo(); - String accessToken = (String) jsonObject.get(Constants.ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME); - if (accessToken != null && !accessToken.isEmpty()){ - accessTokenInfo.setAccessToken(accessToken); - accessTokenInfo.setRefreshToken((String) jsonObject.get(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME)); - accessTokenInfo.setExpiresIn((Long) jsonObject.get(Constants.OAUTH_EXPIRES_IN)); - accessTokenInfo.setTokenType((String) jsonObject.get(Constants.OAUTH_TOKEN_TYPE)); - accessTokenInfo.setScope((String) jsonObject.get(Constants.OAUTH_TOKEN_SCOPE)); - } - return accessTokenInfo; - - } catch (IOException e) { - throw new APIApplicationServicesException("Error when reading the response from buffer.", e); - } catch (KeyStoreException e) { - throw new APIApplicationServicesException("Failed loading the keystore.", e); - } catch (NoSuchAlgorithmException e) { - throw new APIApplicationServicesException("No such algorithm found when loading the ssl socket", e); - } catch (ParseException e) { - throw new APIApplicationServicesException("Error when parsing the response " + response, e); - } catch (KeyManagementException e) { - throw new APIApplicationServicesException("Failed setting up the ssl http client.", e); - } - } - - static String getBase64Encode(String key, String value) { - return new String(Base64.encodeBase64((key + ":" + value).getBytes())); - } -======= ->>>>>>> 2855ef0a30 (change http client to okhttp) } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index d9246c253a..c08735db3f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -125,10 +125,7 @@ org.wso2.carbon.devicemgt io.entgra.devicemgt.apimgt.extension.publisher.api - - - org.wso2.carbon.devicemgt - io.entgra.devicemgt.apimgt.extension.publisher.api + provided diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index ae822fd4eb..137f35b572 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -25,6 +25,24 @@ 5.0.26-SNAPSHOT ../../pom.xml + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + + + org.json.wso2 + json + + + io.github.openfeign + feign-okhttp + + + com.google.code.gson + gson + + 4.0.0 apimgt-extensions From aab94d8fdd5263762c90a9ae3978c3b963b5009f Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 21 Apr 2023 00:26:16 +0530 Subject: [PATCH 15/29] Implement get scopesID API call and rename the module --- .../PublisherRESTAPIServices.java | 96 ------------ .../dto/AccessTokenInfo.java | 53 ------- .../internal/PublisherRESTAPIDataHolder.java | 30 ---- .../util/PublisherRESTAPIUtil.java | 67 --------- .../util/ScopeUtils.java | 59 -------- .../pom.xml | 12 +- .../rest/api}/APIApplicationServices.java | 8 +- .../rest/api}/APIApplicationServicesImpl.java | 57 +++++--- .../rest/api/PublisherRESTAPIServices.java | 137 ++++++++++++++++++ .../rest/api}/bean/RegistrationProfile.java | 2 +- .../rest/api}/constants/Constants.java | 2 +- .../rest/api}/dto/APIApplicationKey.java | 2 +- .../rest/api/dto/AccessTokenInfo.java | 53 +++++++ .../APIApplicationServicesException.java | 2 +- .../api}/exceptions/BadRequestException.java | 4 +- .../internal/PublisherRESTAPIDataHolder.java | 21 +++ .../PublisherRESTAPIServiceComponent.java | 13 +- .../extension/rest/api/util/ScopeUtils.java | 57 ++++++++ .../pom.xml | 15 +- .../webapp/publisher/APIPublisherService.java | 2 - .../publisher/APIPublisherServiceImpl.java | 49 ++++--- .../publisher/APIPublisherStartupHandler.java | 6 - components/apimgt-extensions/pom.xml | 18 ++- pom.xml | 2 +- 24 files changed, 377 insertions(+), 390 deletions(-) delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherRESTAPIUtil.java delete mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api}/pom.xml (96%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/APIApplicationServices.java (58%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/APIApplicationServicesImpl.java (73%) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/bean/RegistrationProfile.java (96%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/constants/Constants.java (97%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/dto/APIApplicationKey.java (97%) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/exceptions/APIApplicationServicesException.java (83%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/exceptions/BadRequestException.java (91%) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api => io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api}/internal/PublisherRESTAPIServiceComponent.java (62%) create mode 100644 components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java deleted file mode 100644 index a0bb43217d..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/PublisherRESTAPIServices.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api; - -import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; -import okhttp3.*; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.ssl.Base64; -import org.json.JSONObject; -import org.wso2.carbon.apimgt.api.model.Scope; - -import java.io.IOException; -import static io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl.getOkHttpClient; - -public class PublisherRESTAPIServices { - private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); - private static final OkHttpClient client = getOkHttpClient(); - private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); - - public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) - throws APIApplicationServicesException, BadRequestException { - - String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); - String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; - - Request request = new Request.Builder() - .url(getScopeUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccessToken()) - .head() - .build(); - try { - Response response = client.newCall(request).execute(); - if (response.code() == HttpStatus.SC_OK){ - return true; - }else if(HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret() ); - //max attempt count - return isSharedScopeNameExists(apiApplicationKey,refreshedAccessToken, key); - } else if (HttpStatus.SC_BAD_REQUEST == response.code()){ - log.info(response); - throw new BadRequestException(response.toString()); - } else { - return false; - } - } catch (IOException e) { - String msg = "Error occurred while processing the response"; - throw new APIApplicationServicesException(msg); - } - } - - public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) - throws APIApplicationServicesException, BadRequestException { - - String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + scope.getId(); - - JSONObject setScope = new JSONObject(); - setScope.put("name", scope.getKey()); - setScope.put("displayName", scope.getName()); - setScope.put("description", scope.getDescription()); - setScope.put("bindings", scope.getRoles()); - - - RequestBody requestBody = RequestBody.Companion.create(setScope.toString(), JSON); - Request request = new Request.Builder() - .url(updateScopeUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccessToken()) - .put(requestBody) - .build(); - - try { - Response response = client.newCall(request).execute(); - if (response.code() == HttpStatus.SC_OK) { - return true; - } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefreshToken(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope); - } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { - log.info(response); - throw new BadRequestException(response.toString()); - } else { - return false; - } - } catch (IOException e) { - String msg = "Error occurred while processing the response"; - throw new APIApplicationServicesException(msg); - } - } -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java deleted file mode 100644 index e738c71f45..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/AccessTokenInfo.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.dto; - -/** - * This holds the token information that return from the token endpoint. - */ -public class AccessTokenInfo { - - private String tokenType; - private long expiresIn; - private String refreshToken; - private String accessToken; - private String scope; - - public String getTokenType() { - return tokenType; - } - - public void setTokenType(String tokenType) { - this.tokenType = tokenType; - } - - public long getExpiresIn() { - return expiresIn; - } - - public void setExpiresIn(long expiresIn) { - this.expiresIn = expiresIn; - } - - public String getRefreshToken() { - return refreshToken; - } - - public void setRefreshToken(String refreshToken) { - this.refreshToken = refreshToken; - } - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java deleted file mode 100644 index 885f3ead7a..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIDataHolder.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.internal; - -import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; -import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; - -public class PublisherRESTAPIDataHolder { - - private static final PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder(); - - private APIApplicationServices apiApplicationServices; -// -// private PublisherRESTAPIServices publisherRESTAPIServices; - - public static PublisherRESTAPIDataHolder getInstance(){ - return thisInstance; - } - public APIApplicationServices getApiApplicationServices() { - return apiApplicationServices; - } - public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { - this.apiApplicationServices = apiApplicationServices; - } -// public PublisherRESTAPIServices getPublisherRESTAPIServices() { -// return publisherRESTAPIServices; -// } -// public void setPublisherRESTAPIServices(PublisherRESTAPIServices publisherRESTAPIServices) { -// this.publisherRESTAPIServices = publisherRESTAPIServices; -// } - -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherRESTAPIUtil.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherRESTAPIUtil.java deleted file mode 100644 index 1d532d17a7..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/PublisherRESTAPIUtil.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.wso2.carbon.utils.CarbonUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; - -public class PublisherRESTAPIUtil { - private static final Log log = LogFactory.getLog(PublisherRESTAPIUtil.class); - private static final String HTTPS_PROTOCOL = "https"; - - /** - * Return a http client instance - * - * @param protocol- service endpoint protocol http/https - * @return - */ - public static HttpClient getHttpClient(String protocol) - throws IOException, KeyStoreException, NoSuchAlgorithmException, KeyManagementException { - HttpClient httpclient; - if (HTTPS_PROTOCOL.equals(protocol)) { - SSLContextBuilder builder = new SSLContextBuilder(); - builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); - httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).useSystemProperties().build(); - } else { - httpclient = HttpClients.createDefault(); - } - return httpclient; - } - - public static String getResponseString(HttpResponse httpResponse) throws IOException { - BufferedReader br = null; - try { - br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); - String readLine; - String response = ""; - while (((readLine = br.readLine()) != null)) { - response += readLine; - } - return response; - } finally { - EntityUtils.consumeQuietly(httpResponse.getEntity()); - if (br != null) { - try { - br.close(); - } catch (IOException e) { - log.warn("Error while closing the connection! " + e.getMessage()); - } - } - } - } -} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java deleted file mode 100644 index db8011521d..0000000000 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/util/ScopeUtils.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.util; - -/** - * This class represents the data that are required to register - * the oauth application. - */ -public class ScopeUtils { - - private String key; - private String name; - private String roles; - private String description; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getRoles() { - return roles; - } - - public void setRoles(String roles) { - this.roles = roles; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String toJSON() { - String jsonString = - "{\"name\": \"" + key + "\",\"displayName\": \"" + name + - "\", \"description\": \"" + description + "\"," + "\"bindings\": [" + - roles + "]" + " }"; - -// String jsonString = -// "{\"name\": \"" + name + "\",\"displayName\": \"" + name + -// "\", \"description\": \"" + description + "\"," + "\"bindings\": [" + -// "\"Internal/devicemgt-user\"" + -// "]" + " }"; - return jsonString; - } -} \ No newline at end of file diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/pom.xml similarity index 96% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/pom.xml index 0b2d3f034b..2471b48fed 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/pom.xml @@ -27,7 +27,7 @@ 4.0.0 - io.entgra.devicemgt.apimgt.extension.publisher.api + io.entgra.devicemgt.apimgt.extension.rest.api bundle Entgra - Device API Management Extension Publisher API Entgra - Device API Management Extension Publisher API @@ -86,6 +86,10 @@ org.json.wso2 json + + com.google.code.gson + gson + @@ -106,11 +110,11 @@ ${carbon.device.mgt.version} Publisher API Management Bundle - io.entgra.devicemgt.apimgt.extension.publisher.api.internal + io.entgra.devicemgt.apimgt.extension.rest.api.internal - !io.entgra.devicemgt.apimgt.extension.publisher.api.internal, - io.entgra.devicemgt.apimgt.extension.publisher.api.* + !io.entgra.devicemgt.apimgt.extension.rest.api.internal, + io.entgra.devicemgt.apimgt.extension.rest.api.* javax.net.ssl, diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java similarity index 58% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java index 401f680214..1816df83d8 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java @@ -1,8 +1,8 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api; +package io.entgra.devicemgt.apimgt.extension.rest.api; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; public interface APIApplicationServices { diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java similarity index 73% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 5e6439edbb..50c6c7d4d4 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -1,12 +1,18 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api; +package io.entgra.devicemgt.apimgt.extension.rest.api; import com.google.gson.Gson; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; import org.json.JSONObject; -import io.entgra.devicemgt.apimgt.extension.publisher.api.constants.Constants; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; -import okhttp3.*; +import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.RequestBody; +import okhttp3.Credentials; +import okhttp3.ConnectionPool; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -17,6 +23,7 @@ import javax.net.ssl.X509TrustManager; import java.io.IOException; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; +import java.util.concurrent.TimeUnit; public class APIApplicationServicesImpl implements APIApplicationServices { @@ -33,16 +40,16 @@ public class APIApplicationServicesImpl implements APIApplicationServices { JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName",Constants.CLIENT_NAME); - jsonObject.put("grantType",Constants.GRANT_TYPE); - jsonObject.put("owner",Constants.OWNER); - jsonObject.put("saasApp",true); + jsonObject.put("clientName", Constants.CLIENT_NAME); + jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("owner", Constants.OWNER); + jsonObject.put("saasApp", true); RequestBody requestBody = RequestBody.Companion.create(jsonObject.toString(), JSON); - String keyManagerEndpoint = "https://localhost:9443/client-registration/v0.17/register"; + String applicationEndpoint = "https://localhost:9443/client-registration/v0.17/register"; Request request = new Request.Builder() - .url(keyManagerEndpoint) + .url(applicationEndpoint) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic("admin", "admin")) .post(requestBody) .build(); @@ -58,13 +65,13 @@ public class APIApplicationServicesImpl implements APIApplicationServices { @Override public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) - throws APIApplicationServicesException { + throws APIApplicationServicesException { JSONObject params = new JSONObject(); - params.put(Constants.GRANT_TYPE_PARAM_NAME,Constants.PASSWORD_GRANT_TYPE); + params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE); //ToDo: Remove hardcoded value - params.put(Constants.PASSWORD_GRANT_TYPE_USERNAME,"admin"); - params.put(Constants.PASSWORD_GRANT_TYPE_PASSWORD,"admin"); - params.put(Constants.SCOPE_PARAM_NAME,Constants.SCOPES); + params.put(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin"); + params.put(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin"); + params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES); return getToken(params, consumerKey, consumerSecret); } @@ -73,18 +80,17 @@ public class APIApplicationServicesImpl implements APIApplicationServices { throws APIApplicationServicesException { JSONObject params = new JSONObject(); - params.put(Constants.GRANT_TYPE_PARAM_NAME,Constants.REFRESH_TOKEN_GRANT_TYPE); + params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE); //ToDo: Remove hardcoded value params.put(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken); - params.put(Constants.SCOPE_PARAM_NAME,Constants.SCOPES); + params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES); return getToken(params, consumerKey, consumerSecret); } public AccessTokenInfo getToken(JSONObject nameValuePairs, String clientId, String clientSecret) - throws APIApplicationServicesException{ + throws APIApplicationServicesException { RequestBody requestBody = RequestBody.Companion.create(nameValuePairs.toString(), JSON); - //application/x-www-form-urlencoded String tokenEndPoint = "https://localhost:9443/oauth2/token"; Request request = new Request.Builder() @@ -117,9 +123,14 @@ public class APIApplicationServicesImpl implements APIApplicationServices { java.security.cert.X509Certificate[] certs, String authType) { } }; - return new OkHttpClient.Builder() + OkHttpClient okHttpClient = new OkHttpClient.Builder() + .connectTimeout(300, TimeUnit.SECONDS) + .writeTimeout(300, TimeUnit.SECONDS) + .readTimeout(300, TimeUnit.SECONDS) + .connectionPool(new ConnectionPool(500, 500, TimeUnit.SECONDS)) .sslSocketFactory(getSimpleTrustedSSLSocketFactory(), trustAllCerts) .hostnameVerifier((hostname, sslSession) -> true).build(); + return okHttpClient; } private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { @@ -129,9 +140,11 @@ public class APIApplicationServicesImpl implements APIApplicationServices { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } + public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) { } + public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) { } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java new file mode 100644 index 0000000000..c2c0202c8a --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -0,0 +1,137 @@ +package io.entgra.devicemgt.apimgt.extension.rest.api; + +import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; +import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.devicemgt.apimgt.extension.rest.api.util.ScopeUtils; + +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.RequestBody; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.ssl.Base64; +import org.json.JSONObject; +import org.wso2.carbon.apimgt.api.model.Scope; + +import java.io.IOException; + +import static io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServicesImpl.getOkHttpClient; + +public class PublisherRESTAPIServices { + private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); + private static final OkHttpClient client = getOkHttpClient(); + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + + public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + throws APIApplicationServicesException, BadRequestException { + + String getScopesUrl = "https://localhost:9443/api/am/publisher/v2/scopes?limit=1000"; + Request request = new Request.Builder() + .url(getScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (response.code() == HttpStatus.SC_OK) { + JSONObject jsonObject = new JSONObject(response.body().string()); + return jsonObject; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getScopes(apiApplicationKey, refreshedAccessToken); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + log.info(response); + throw new BadRequestException(response.toString()); + } else { + return null; + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + throw new APIApplicationServicesException(msg); + } + } + + public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) + throws APIApplicationServicesException, BadRequestException { + + String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); + String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; + + Request request = new Request.Builder() + .url(getScopeUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccess_token()) + .head() + .build(); + try { + Response response = client.newCall(request).execute(); + if (response.code() == HttpStatus.SC_OK) { + return true; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return isSharedScopeNameExists(apiApplicationKey, refreshedAccessToken, key); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + log.info(response); + throw new BadRequestException(response.toString()); + } else { + return false; + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + throw new APIApplicationServicesException(msg); + } + } + + public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) + throws APIApplicationServicesException, BadRequestException { + + String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + scope.getId(); + + ScopeUtils scopeUtil = new ScopeUtils(); + scopeUtil.setKey(scope.getKey()); + scopeUtil.setName(scope.getName()); + scopeUtil.setDescription(scope.getDescription()); + scopeUtil.setRoles(scope.getRoles()); + String scopeString = scopeUtil.toJSON(); + + RequestBody requestBody = RequestBody.create(JSON, scopeString); + Request request = new Request.Builder() + .url(updateScopeUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccess_token()) + .put(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (response.code() == HttpStatus.SC_OK) { + return true; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + log.info(response); + throw new BadRequestException(response.toString()); + } else { + return false; + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + throw new APIApplicationServicesException(msg); + } + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/bean/RegistrationProfile.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java similarity index 96% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/bean/RegistrationProfile.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java index 242788ed26..c454444598 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/bean/RegistrationProfile.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java @@ -1,4 +1,4 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.bean; +package io.entgra.devicemgt.apimgt.extension.rest.api.bean; /** * This class represents the data that are required to register diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/constants/Constants.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java similarity index 97% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/constants/Constants.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java index 0144e129f1..4e92ad6d93 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java @@ -1,4 +1,4 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.constants; +package io.entgra.devicemgt.apimgt.extension.rest.api.constants; public final class Constants { diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java similarity index 97% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java index d0fc3b9f68..e18c4b3d90 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/dto/APIApplicationKey.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java @@ -1,4 +1,4 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.dto; +package io.entgra.devicemgt.apimgt.extension.rest.api.dto; /** * This holds api application consumer id and secret. diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java new file mode 100644 index 0000000000..f9c9a4db67 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java @@ -0,0 +1,53 @@ +package io.entgra.devicemgt.apimgt.extension.rest.api.dto; + +/** + * This holds the token information that return from the token endpoint. + */ +public class AccessTokenInfo { + + private String token_type; + private long expires_in; + private String refresh_token; + private String access_token; + private String scope; + + public String getToken_type() { + return token_type; + } + + public void setToken_type(String token_type) { + this.token_type = token_type; + } + + public long getExpires_in() { + return expires_in; + } + + public void setExpires_in(long expires_in) { + this.expires_in = expires_in; + } + + public String getRefresh_token() { + return refresh_token; + } + + public void setRefresh_token(String refresh_token) { + this.refresh_token = refresh_token; + } + + public String getAccess_token() { + return access_token; + } + + public void setAccess_token(String access_token) { + this.access_token = access_token; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/APIApplicationServicesException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java similarity index 83% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/APIApplicationServicesException.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java index bd7aa85cd9..897146bbcd 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/APIApplicationServicesException.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java @@ -1,4 +1,4 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions; +package io.entgra.devicemgt.apimgt.extension.rest.api.exceptions; public class APIApplicationServicesException extends Exception{ diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java similarity index 91% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java index 427c4b5e35..00d4b423fa 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/exceptions/BadRequestException.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java @@ -22,9 +22,7 @@ /** * Custom exception class for handling bad request exceptions. */ -package io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions; - -import okhttp3.Response; +package io.entgra.devicemgt.apimgt.extension.rest.api.exceptions; public class BadRequestException extends Exception { diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java new file mode 100644 index 0000000000..ce651eeb36 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java @@ -0,0 +1,21 @@ +package io.entgra.devicemgt.apimgt.extension.rest.api.internal; + +import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; + +public class PublisherRESTAPIDataHolder { + + private static final PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder(); + + private APIApplicationServices apiApplicationServices; + + public static PublisherRESTAPIDataHolder getInstance(){ + return thisInstance; + } + public APIApplicationServices getApiApplicationServices() { + return apiApplicationServices; + } + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { + this.apiApplicationServices = apiApplicationServices; + } + +} diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java similarity index 62% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java rename to components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java index d34012c1f4..3817e365a4 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.publisher.api/src/main/java/io.entgra.devicemgt.apimgt.extension.publisher.api/internal/PublisherRESTAPIServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java @@ -1,15 +1,14 @@ -package io.entgra.devicemgt.apimgt.extension.publisher.api.internal; +package io.entgra.devicemgt.apimgt.extension.rest.api.internal; -import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; -import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl; -import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; +import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServicesImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; /** - * @scr.component name="io.entgra.devicemgt.apimgt.extension.publisher.api.internal.PublisherRESTAPIServiceComponent" + * @scr.component name="io.entgra.devicemgt.apimgt.extension.rest.api.internal.PublisherRESTAPIServiceComponent" * immediate="true" */ public class PublisherRESTAPIServiceComponent { @@ -23,10 +22,6 @@ public class PublisherRESTAPIServiceComponent { try { BundleContext bundleContext = componentContext.getBundleContext(); -// PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); -// bundleContext.registerService(PublisherRESTAPIServices.class.getName(), publisherRESTAPIServices, null); -// PublisherRESTAPIDataHolder.getInstance().setPublisherRESTAPIServices(publisherRESTAPIServices); - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); bundleContext.registerService(APIApplicationServices.class.getName(), apiApplicationServices, null); PublisherRESTAPIDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java new file mode 100644 index 0000000000..8a7e6d2fbb --- /dev/null +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java @@ -0,0 +1,57 @@ +package io.entgra.devicemgt.apimgt.extension.rest.api.util; + +/** + * This class represents the data that are required to register + * the oauth application. + */ +public class ScopeUtils { + + private String key; + private String name; + private String roles; + private String description; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRoles() { + return roles; + } + + public void setRoles(String roles) { + this.roles = roles; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String toJSON() { + String jsonString = "{\n" + + " \"name\":\" " + key + "\",\n" + + " \"displayName\":\" " + name + "\",\n" + + " \"description\":\" " + description + " \",\n" + + " \"bindings\":[\n" + + " \" " + roles + " \"\n" + + " ]\n" + + "}"; + return jsonString; + } +} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index c08735db3f..d1bc922c54 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -124,9 +124,13 @@ org.wso2.carbon.devicemgt - io.entgra.devicemgt.apimgt.extension.publisher.api + io.entgra.devicemgt.apimgt.extension.rest.api provided + + org.json.wso2 + json + @@ -170,9 +174,9 @@ org.scannotation;version="1.0", org.scannotation.archiveiterator;version="1.0", org.w3c.dom, - io.entgra.devicemgt.apimgt.extension.publisher.api, - io.entgra.devicemgt.apimgt.extension.publisher.api.dto, - io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions, + io.entgra.devicemgt.apimgt.extension.rest.api, + io.entgra.devicemgt.apimgt.extension.rest.api.dto, + io.entgra.devicemgt.apimgt.extension.rest.api.exceptions, org.wso2.carbon.apimgt.annotations.api, org.wso2.carbon.apimgt.api, org.wso2.carbon.apimgt.api.model, @@ -195,7 +199,8 @@ org.wso2.carbon.utils;version="4.6", org.wso2.carbon.utils.multitenancy;version="4.6", org.wso2.carbon.apimgt.impl.definitions, - org.apache.commons.lang + org.apache.commons.lang, + org.json jsr311-api;scope=compile|runtime;inline=false diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java index 85dcf72d13..fd111a46de 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java @@ -18,8 +18,6 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; - -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; /** diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 2fe4883df5..0aebefbaa4 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -18,18 +18,20 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; -import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; -import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl; -import io.entgra.devicemgt.apimgt.extension.publisher.api.PublisherRESTAPIServices; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; +import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServicesImpl; +import io.entgra.devicemgt.apimgt.extension.rest.api.PublisherRESTAPIServices; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; +import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.BadRequestException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.api.model.Documentation; import org.wso2.carbon.apimgt.api.model.DocumentationType; +import org.json.JSONArray; +import org.json.JSONObject; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.APIProvider; import org.wso2.carbon.apimgt.api.FaultGatewaysException; @@ -382,6 +384,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); + JSONObject scopeObject = publisherRESTAPIServices.getScopes(apiApplicationKey, accessTokenInfo); try { String fileName = @@ -427,8 +430,18 @@ public class APIPublisherServiceImpl implements APIPublisherService { } scope.setRoles(roleString); -// if (apiProvider.isSharedScopeNameExists(scope.getKey(), tenantDomain)) { -// apiProvider.updateSharedScope(scope, tenantDomain); + //Set scope id which related to the scope key + JSONArray scopeList = (JSONArray) scopeObject.get("list"); + JSONObject object = null; + for (int i = 0; i < scopeList.length(); i++) { + JSONObject obj = null; + obj = scopeList.getJSONObject(i); + if (obj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { + object = obj; + } + } + scope.setId(object.getString("id")); + if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) { publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); } else { @@ -449,17 +462,13 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } -// catch (UserStoreException e) { -// String msg = "Error occurred while reading tenant admin username"; -// log.error(msg, e); -// throw new APIManagerPublisherException(e); -// } -// catch (APIManagementException e) { -// String msg = "Error occurred while loading api provider"; -// log.error(msg, e); -// throw new APIManagerPublisherException(e); -// } - finally { + catch (APIApplicationServicesException e) { + log.error(e); + throw new RuntimeException(e); + } catch (BadRequestException e) { + log.error(e); + throw new RuntimeException(e); + } finally { PrivilegedCarbonContext.endTenantFlow(); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index 3933f60716..01b1cd810c 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -19,12 +19,6 @@ package org.wso2.carbon.apimgt.webapp.publisher; -import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServices; -import io.entgra.devicemgt.apimgt.extension.publisher.api.APIApplicationServicesImpl; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.publisher.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.APIApplicationServicesException; -import io.entgra.devicemgt.apimgt.extension.publisher.api.exceptions.BadRequestException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 137f35b572..2c175c1ea1 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -31,17 +31,25 @@ org.wso2.carbon.apimgt.api - org.json.wso2 - json + com.squareup.okhttp3 + okhttp - io.github.openfeign - feign-okhttp + org.json.wso2 + json com.google.code.gson gson + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + 4.0.0 @@ -58,7 +66,7 @@ org.wso2.carbon.apimgt.keymgt.extension org.wso2.carbon.apimgt.keymgt.extension.api io.entgra.device.mgt.core.apimgt.analytics.extension - io.entgra.devicemgt.apimgt.extension.publisher.api + io.entgra.devicemgt.apimgt.extension.rest.api diff --git a/pom.xml b/pom.xml index b5435d623d..e52350555b 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ org.wso2.carbon.devicemgt - io.entgra.devicemgt.apimgt.extension.publisher.api + io.entgra.devicemgt.apimgt.extension.rest.api ${carbon.device.mgt.version} From 34ae40e233885417b9f432460841b9c68101db5d Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 21 Apr 2023 00:53:50 +0530 Subject: [PATCH 16/29] Code format fixes --- .../rest/api/APIApplicationServices.java | 19 +++ .../rest/api/APIApplicationServicesImpl.java | 19 ++- .../rest/api/PublisherRESTAPIServices.java | 18 +++ .../rest/api/bean/RegistrationProfile.java | 116 ++++++++++-------- .../rest/api/constants/Constants.java | 9 -- .../rest/api/dto/APIApplicationKey.java | 23 +++- .../rest/api/dto/AccessTokenInfo.java | 18 +++ .../APIApplicationServicesException.java | 36 +++++- .../api/exceptions/BadRequestException.java | 27 ++-- .../internal/PublisherRESTAPIDataHolder.java | 22 +++- .../PublisherRESTAPIServiceComponent.java | 18 +++ .../extension/rest/api/util/ScopeUtils.java | 21 +++- .../publisher/APIPublisherServiceImpl.java | 12 +- .../publisher/APIPublisherStartupHandler.java | 4 +- .../lifecycle/util/AnnotationProcessor.java | 4 +- components/apimgt-extensions/pom.xml | 26 ---- 16 files changed, 273 insertions(+), 119 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java index 1816df83d8..d420bbc622 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api; import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; @@ -9,6 +27,7 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials() throws APIApplicationServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIApplicationServicesException; + AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIApplicationServicesException; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 50c6c7d4d4..d1613f3d74 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api; import com.google.gson.Gson; @@ -81,7 +99,6 @@ public class APIApplicationServicesImpl implements APIApplicationServices { JSONObject params = new JSONObject(); params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE); - //ToDo: Remove hardcoded value params.put(Constants.REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME, refreshToken); params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES); return getToken(params, consumerKey, consumerSecret); diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java index c2c0202c8a..7148286aa3 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api; import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java index c454444598..97033b6d5c 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api.bean; /** @@ -6,63 +24,63 @@ package io.entgra.devicemgt.apimgt.extension.rest.api.bean; */ public class RegistrationProfile { - private String callbackUrl; - private String clientName; - private String tokenScope; - private String owner; - private String grantType; - private String applicationType; + private String callbackUrl; + private String clientName; + private String tokenScope; + private String owner; + private String grantType; + private String applicationType; private boolean isSaasApp; - private static final String TAG = RegistrationProfile.class.getSimpleName(); + private static final String TAG = RegistrationProfile.class.getSimpleName(); - public String getCallbackUrl() { - return callbackUrl; - } + public String getCallbackUrl() { + return callbackUrl; + } - public void setCallbackUrl(String callBackUrl) { - this.callbackUrl = callBackUrl; - } + public void setCallbackUrl(String callBackUrl) { + this.callbackUrl = callBackUrl; + } - public String getClientName() { - return clientName; - } + public String getClientName() { + return clientName; + } - public void setClientName(String clientName) { - this.clientName = clientName; - } + public void setClientName(String clientName) { + this.clientName = clientName; + } - public String getTokenScope() { - return tokenScope; - } + public String getTokenScope() { + return tokenScope; + } - public void setTokenScope(String tokenScope) { - this.tokenScope = tokenScope; - } + public void setTokenScope(String tokenScope) { + this.tokenScope = tokenScope; + } - public String getOwner() { - return owner; - } + public String getOwner() { + return owner; + } - public void setOwner(String owner) { - this.owner = owner; - } + public void setOwner(String owner) { + this.owner = owner; + } - public String getGrantType() { - return grantType; - } + public String getGrantType() { + return grantType; + } - public void setGrantType(String grantType) { - this.grantType = grantType; - } + public void setGrantType(String grantType) { + this.grantType = grantType; + } - public String getApplicationType() { - return applicationType; - } + public String getApplicationType() { + return applicationType; + } - public void setApplicationType(String applicationType) { - this.applicationType = applicationType; - } + public void setApplicationType(String applicationType) { + this.applicationType = applicationType; + } public boolean isSaasApp() { return isSaasApp; @@ -73,10 +91,10 @@ public class RegistrationProfile { } public String toJSON() { - String jsonString = - "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + - "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + - "\", \"saasApp\" : " + isSaasApp + " }\n"; - return jsonString; - } + String jsonString = + "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + + "\", \"saasApp\" : " + isSaasApp + " }\n"; + return jsonString; + } } \ No newline at end of file diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java index 4e92ad6d93..73b4a3a842 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java @@ -20,15 +20,6 @@ public final class Constants { public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive"; public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000; - public static final int DEFAULT_MIN_THREAD_POOL_SIZE = 8; - public static final int DEFAULT_MAX_THREAD_POOL_SIZE = 100; - public static final int DEFAULT_EXECUTOR_JOB_QUEUE_SIZE = 2000; - public static final long DEFAULT_KEEP_ALIVE_TIME_IN_MILLIS = 20000; - public static final String ADAPTER_MIN_THREAD_POOL_SIZE_NAME = "minThread"; - public static final String ADAPTER_MAX_THREAD_POOL_SIZE_NAME = "maxThread"; - public static final String ADAPTER_KEEP_ALIVE_TIME_NAME = "keepAliveTimeInMillis"; - public static final String ADAPTER_EXECUTOR_JOB_QUEUE_SIZE_NAME = "jobQueueSize"; - public static final String DEFAULT_CALLBACK = ""; public static final String DEFAULT_PASSWORD = ""; public static final String TOKEN_SCOPE = "production"; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java index e18c4b3d90..cbadf626b2 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java @@ -1,7 +1,25 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api.dto; /** - * This holds api application consumer id and secret. + * This holds the consumer application information that return from the register application endpoint */ public class APIApplicationKey { private String clientName; @@ -14,7 +32,7 @@ public class APIApplicationKey { private String jsonAppAttribute; private String tokenType; - public APIApplicationKey(String clientId, String clientSecret){ + public APIApplicationKey(String clientId, String clientSecret) { this.clientId = clientId; this.clientSecret = clientSecret; } @@ -34,6 +52,7 @@ public class APIApplicationKey { public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; } + public String getClientName() { return clientName; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java index f9c9a4db67..061e7e898d 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api.dto; /** diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java index 897146bbcd..35a247a190 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java @@ -1,12 +1,38 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api.exceptions; -public class APIApplicationServicesException extends Exception{ +public class APIApplicationServicesException extends Exception { - public APIApplicationServicesException() {super();} + public APIApplicationServicesException() { + super(); + } - public APIApplicationServicesException(String message) {super();} + public APIApplicationServicesException(String message) { + super(); + } - public APIApplicationServicesException(String message, Throwable cause){super();} + public APIApplicationServicesException(String message, Throwable cause) { + super(); + } - public APIApplicationServicesException(Throwable cause){super();} + public APIApplicationServicesException(Throwable cause) { + super(); + } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java index 00d4b423fa..25cebe82fc 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java @@ -1,22 +1,19 @@ /* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * - * * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * * - * * Entgra (Pvt) Ltd. 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. + * Entgra (Pvt) Ltd. 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. */ /** diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java index ce651eeb36..9545a94fb4 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api.internal; import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; @@ -8,12 +26,14 @@ public class PublisherRESTAPIDataHolder { private APIApplicationServices apiApplicationServices; - public static PublisherRESTAPIDataHolder getInstance(){ + public static PublisherRESTAPIDataHolder getInstance() { return thisInstance; } + public APIApplicationServices getApiApplicationServices() { return apiApplicationServices; } + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { this.apiApplicationServices = apiApplicationServices; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java index 3817e365a4..fdf74638c6 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api.internal; import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java index 8a7e6d2fbb..5716ebfcb1 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java +++ b/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java @@ -1,8 +1,25 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.devicemgt.apimgt.extension.rest.api.util; /** - * This class represents the data that are required to register - * the oauth application. + * This class represents the scope data. */ public class ScopeUtils { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 0aebefbaa4..5452a4f8bd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -432,15 +432,15 @@ public class APIPublisherServiceImpl implements APIPublisherService { //Set scope id which related to the scope key JSONArray scopeList = (JSONArray) scopeObject.get("list"); - JSONObject object = null; + JSONObject jsonObject = null; for (int i = 0; i < scopeList.length(); i++) { - JSONObject obj = null; - obj = scopeList.getJSONObject(i); - if (obj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { - object = obj; + JSONObject scopeObj = null; + scopeObj = scopeList.getJSONObject(i); + if (scopeObj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { + jsonObject = scopeObj; } } - scope.setId(object.getString("id")); + scope.setId(jsonObject.getString("id")); if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) { publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java index 01b1cd810c..949f16c3e9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.core.ServerStartupObserver; + import java.util.Stack; public class APIPublisherStartupHandler implements ServerStartupObserver { @@ -34,10 +35,12 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { private static final int MAX_RETRY_COUNT = 5; private static Stack failedAPIsStack = new Stack<>(); private static Stack currentAPIsStack; + private APIPublisherService publisher; @Override public void completingServerStartup() { + } @Override @@ -52,7 +55,6 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.debug("Total number of unpublished APIs: " + APIPublisherDataHolder.getInstance().getUnpublishedApis().size()); } - publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); int retryCount = 0; while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index 7cdede5bcb..f41c07967a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -299,7 +299,7 @@ public class AnnotationProcessor { // if (scope != null) { // resource.setScope(scope); // } else { -// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + +// log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) + // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); // scope = new ApiScope(); // scope.setName(DEFAULT_SCOPE_NAME); @@ -537,7 +537,7 @@ public class AnnotationProcessor { if (scope != null) { apiResource.setScope(scope); } else { -// log.warn("ScopeUtils is not defined for '" + makeContextURLReady(resourceRootContext) + +// log.warn("Scope is not defined for '" + makeContextURLReady(resourceRootContext) + // makeContextURLReady(subCtx) + "' endpoint, hence assigning the default scope"); scope = new ApiScope(); scope.setName(DEFAULT_SCOPE_NAME); diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 2c175c1ea1..c4bfc0d36d 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -25,32 +25,6 @@ 5.0.26-SNAPSHOT ../../pom.xml - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - - - com.squareup.okhttp3 - okhttp - - - org.json.wso2 - json - - - com.google.code.gson - gson - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - 4.0.0 apimgt-extensions From 07c157e9d6985e989e2dcdd6e8bd44e1b6511678 Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 25 Apr 2023 14:02:19 +0530 Subject: [PATCH 17/29] Fix URL Generation, Make feature, Refactor the module --- .../pom.xml | 58 +++++------------ .../rest/api/APIApplicationServices.java | 14 ++--- .../rest/api/APIApplicationServicesImpl.java | 51 ++++++++------- .../rest/api/PublisherRESTAPIServices.java | 63 +++++++++++-------- .../rest/api/bean/RegistrationProfile.java | 2 +- .../rest/api/constants/Constants.java | 35 ++++++++--- .../rest/api/dto/APIApplicationKey.java | 2 +- .../rest/api/dto/AccessTokenInfo.java | 2 +- .../api/exceptions/APIServicesException.java} | 18 +++--- .../api/exceptions/BadRequestException.java | 2 +- .../internal/PublisherRESTAPIDataHolder.java | 26 ++++++-- .../PublisherRESTAPIServiceComponent.java | 29 +++++++-- .../extension/rest/api/util/ScopeUtils.java | 2 +- .../pom.xml | 8 +-- .../webapp/publisher/APIPublisherService.java | 1 + .../publisher/APIPublisherServiceImpl.java | 35 ++++++----- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 7 +++ pom.xml | 2 +- 19 files changed, 209 insertions(+), 150 deletions(-) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api => io.entgra.device.mgt.core.apimgt.extension.rest.api}/pom.xml (71%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/APIApplicationServices.java (64%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/APIApplicationServicesImpl.java (80%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/PublisherRESTAPIServices.java (72%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/bean/RegistrationProfile.java (97%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/constants/Constants.java (57%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/dto/APIApplicationKey.java (97%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/dto/AccessTokenInfo.java (96%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/APIServicesException.java} (63%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/exceptions/BadRequestException.java (93%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java (52%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java (59%) rename components/apimgt-extensions/{io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt => io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core}/apimgt/extension/rest/api/util/ScopeUtils.java (96%) diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml similarity index 71% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/pom.xml rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 2471b48fed..7fb3f1726f 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -27,21 +27,13 @@ 4.0.0 - io.entgra.devicemgt.apimgt.extension.rest.api + io.entgra.device.mgt.core.apimgt.extension.rest.api bundle - Entgra - Device API Management Extension Publisher API - Entgra - Device API Management Extension Publisher API + Entgra - Device Management Extension for APIM REST API + Entgra - Device Management Extension for APIM REST API https://entgra.io - - org.apache.httpcomponents.wso2 - httpcore - - - org.wso2.orbit.org.apache.httpcomponents - httpclient - org.wso2.carbon org.wso2.carbon.logging @@ -90,6 +82,11 @@ com.google.code.gson gson + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.impl + provided + @@ -110,31 +107,23 @@ ${carbon.device.mgt.version} Publisher API Management Bundle - io.entgra.devicemgt.apimgt.extension.rest.api.internal + io.entgra.device.mgt.core.apimgt.extension.rest.api.internal - !io.entgra.devicemgt.apimgt.extension.rest.api.internal, - io.entgra.devicemgt.apimgt.extension.rest.api.* + !io.entgra.device.mgt.core.apimgt.extension.rest.api.internal, + io.entgra.device.mgt.core.apimgt.extension.rest.api.* javax.net.ssl, - org.apache.commons.logging, - org.apache.http;version="${httpclient.version.range}", - org.apache.http.client;version="${httpclient.version.range}", - org.apache.http.client.methods;version="${httpclient.version.range}", - org.apache.http.conn.socket, - org.apache.http.conn.ssl, - org.apache.http.entity, - org.apache.http.impl.client, - org.apache.http.util;version="${httpclient.version.range}", - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.core, - org.apache.commons.ssl, - org.apache.commons.httpclient, + org.wso2.carbon.core;version="4.6", + org.wso2.carbon.core.util;version="4.6", org.wso2.carbon.apimgt.api.model, okhttp3.*, + org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}", + org.wso2.carbon.apimgt.impl.utils;version="${carbon.api.mgt.version.range}", + org.wso2.carbon.apimgt.impl.internal;version="${carbon.api.mgt.version.range}", org.json @@ -166,22 +155,7 @@ - - - - - - - - - - - - - - true - \ No newline at end of file diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java similarity index 64% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index d420bbc622..51d7d20b17 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -16,18 +16,18 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api; +package io.entgra.device.mgt.core.apimgt.extension.rest.api; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials() throws APIApplicationServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; - AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIApplicationServicesException; + AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; - AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIApplicationServicesException; + AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIServicesException; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java similarity index 80% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index d1613f3d74..bffb97893a 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -16,14 +16,14 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api; +package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import org.json.JSONObject; -import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -33,6 +33,8 @@ import okhttp3.Credentials; import okhttp3.ConnectionPool; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; +import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; @@ -50,22 +52,24 @@ public class APIApplicationServicesImpl implements APIApplicationServices { private static final Gson gson = new Gson(); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); String msg = null; - // private ApiApplicationConfigurations ApplicationConfig = null; + APIManagerConfiguration config = ServiceReferenceHolder.getInstance(). + getAPIManagerConfigurationService().getAPIManagerConfiguration(); @Override public APIApplicationKey createAndRetrieveApplicationCredentials() - throws APIApplicationServicesException { + throws APIServicesException { + + String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); + String owner = config.getFirstProperty(Constants.SERVER_USER); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); jsonObject.put("clientName", Constants.CLIENT_NAME); jsonObject.put("grantType", Constants.GRANT_TYPE); - jsonObject.put("owner", Constants.OWNER); + jsonObject.put("owner", owner); jsonObject.put("saasApp", true); RequestBody requestBody = RequestBody.Companion.create(jsonObject.toString(), JSON); - String applicationEndpoint = "https://localhost:9443/client-registration/v0.17/register"; - Request request = new Request.Builder() .url(applicationEndpoint) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic("admin", "admin")) @@ -76,26 +80,29 @@ public class APIApplicationServicesImpl implements APIApplicationServices { return gson.fromJson(response.body().string(), APIApplicationKey.class); } catch (IOException e) { msg = "Error occurred while processing the response"; - log.error(msg); - throw new APIApplicationServicesException(msg); + log.error(msg, e); + throw new APIServicesException(e); } } @Override public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) - throws APIApplicationServicesException { + throws APIServicesException { + + String userName = config.getFirstProperty(Constants.SERVER_USER); + String userPassword = config.getFirstProperty(Constants.SERVER_PASSWORD); + JSONObject params = new JSONObject(); params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.PASSWORD_GRANT_TYPE); - //ToDo: Remove hardcoded value - params.put(Constants.PASSWORD_GRANT_TYPE_USERNAME, "admin"); - params.put(Constants.PASSWORD_GRANT_TYPE_PASSWORD, "admin"); + params.put(Constants.PASSWORD_GRANT_TYPE_USERNAME, userName); + params.put(Constants.PASSWORD_GRANT_TYPE_PASSWORD, userPassword); params.put(Constants.SCOPE_PARAM_NAME, Constants.SCOPES); return getToken(params, consumerKey, consumerSecret); } @Override public AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String consumerKey, String consumerSecret) - throws APIApplicationServicesException { + throws APIServicesException { JSONObject params = new JSONObject(); params.put(Constants.GRANT_TYPE_PARAM_NAME, Constants.REFRESH_TOKEN_GRANT_TYPE); @@ -105,11 +112,11 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } public AccessTokenInfo getToken(JSONObject nameValuePairs, String clientId, String clientSecret) - throws APIApplicationServicesException { + throws APIServicesException { - RequestBody requestBody = RequestBody.Companion.create(nameValuePairs.toString(), JSON); - String tokenEndPoint = "https://localhost:9443/oauth2/token"; + String tokenEndPoint = config.getFirstProperty(Constants.TOKE_END_POINT); + RequestBody requestBody = RequestBody.Companion.create(nameValuePairs.toString(), JSON); Request request = new Request.Builder() .url(tokenEndPoint) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(clientId, clientSecret)) @@ -121,8 +128,8 @@ public class APIApplicationServicesImpl implements APIApplicationServices { return gson.fromJson(response.body().string(), AccessTokenInfo.class); } catch (IOException e) { msg = "Error occurred while processing the response"; - log.error(msg); - throw new APIApplicationServicesException(msg); + log.error(msg, e); + throw new APIServicesException(e); } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java similarity index 72% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java index 7148286aa3..5fedcca952 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -16,14 +16,14 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api; +package io.entgra.device.mgt.core.apimgt.extension.rest.api; -import io.entgra.devicemgt.apimgt.extension.rest.api.constants.Constants; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; -import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.BadRequestException; -import io.entgra.devicemgt.apimgt.extension.rest.api.util.ScopeUtils; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; import okhttp3.MediaType; import okhttp3.OkHttpClient; @@ -39,26 +39,31 @@ import org.wso2.carbon.apimgt.api.model.Scope; import java.io.IOException; -import static io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServicesImpl.getOkHttpClient; +import static io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl.getOkHttpClient; public class PublisherRESTAPIServices { private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); private static final OkHttpClient client = getOkHttpClient(); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private static final String host = System.getProperty(Constants.IOT_CORE_HOST); + private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT); + public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) - throws APIApplicationServicesException, BadRequestException { + throws APIServicesException, BadRequestException { + - String getScopesUrl = "https://localhost:9443/api/am/publisher/v2/scopes?limit=1000"; + String getAllScopesUrl = "https://" + "://" + host + ":" + port + Constants.GET_ALL_SCOPES; Request request = new Request.Builder() - .url(getScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccess_token()) + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) .get() .build(); try { Response response = client.newCall(request).execute(); - if (response.code() == HttpStatus.SC_OK) { + if (HttpStatus.SC_OK == response.code()) { JSONObject jsonObject = new JSONObject(response.body().string()); return jsonObject; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { @@ -68,22 +73,24 @@ public class PublisherRESTAPIServices { //TODO: max attempt count return getScopes(apiApplicationKey, refreshedAccessToken); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { - log.info(response); - throw new BadRequestException(response.toString()); + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); } else { return null; } } catch (IOException e) { String msg = "Error occurred while processing the response"; - throw new APIApplicationServicesException(msg); + log.error(msg, e); + throw new APIServicesException(e); } } public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) - throws APIApplicationServicesException, BadRequestException { + throws APIServicesException, BadRequestException { String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); - String getScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + keyValue; + String getScopeUrl = "https://" + "://" + host + ":" + port + Constants.GET_SCOPE + keyValue; Request request = new Request.Builder() .url(getScopeUrl) @@ -101,21 +108,23 @@ public class PublisherRESTAPIServices { //TODO: max attempt count return isSharedScopeNameExists(apiApplicationKey, refreshedAccessToken, key); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { - log.info(response); - throw new BadRequestException(response.toString()); + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); } else { return false; } } catch (IOException e) { String msg = "Error occurred while processing the response"; - throw new APIApplicationServicesException(msg); + log.error(msg, e); + throw new APIServicesException(e); } } public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) - throws APIApplicationServicesException, BadRequestException { + throws APIServicesException, BadRequestException { - String updateScopeUrl = "https://localhost:9443/api/am/publisher/v2/scopes/" + scope.getId(); + String updateScopeUrl = "https://" + "://" + host + ":" + port + Constants.GET_SCOPE + scope.getId(); ScopeUtils scopeUtil = new ScopeUtils(); scopeUtil.setKey(scope.getKey()); @@ -142,14 +151,16 @@ public class PublisherRESTAPIServices { //TODO: max attempt count return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { - log.info(response); - throw new BadRequestException(response.toString()); + String msg = "Bad Request, Invalid scope object"; + log.error(msg); + throw new BadRequestException(msg); } else { return false; } } catch (IOException e) { String msg = "Error occurred while processing the response"; - throw new APIApplicationServicesException(msg); + log.error(msg, e); + throw new APIServicesException(e); } } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/RegistrationProfile.java similarity index 97% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/RegistrationProfile.java index 97033b6d5c..455c4704d1 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/bean/RegistrationProfile.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/RegistrationProfile.java @@ -16,7 +16,7 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.bean; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean; /** * This class represents the data that are required to register diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java similarity index 57% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index 73b4a3a842..11b056298a 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -1,4 +1,22 @@ -package io.entgra.devicemgt.apimgt.extension.rest.api.constants; +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.apimgt.extension.rest.api.constants; public final class Constants { @@ -7,7 +25,8 @@ public final class Constants { public static final String EMPTY_STRING = ""; public static final String CLIENT_NAME = "rest_api_publisher_code"; - public static final String OWNER = "admin"; + public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; + public static final String SERVER_PASSWORD = "ServerPassword"; public static final String GRANT_TYPE = "client_credentials password refresh_token"; public static final String REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME = "refresh_token"; public static final String OAUTH_EXPIRES_IN = "expires_in"; @@ -16,14 +35,10 @@ public final class Constants { public static final String REFRESH_TOKEN_GRANT_TYPE = "refresh_token"; public static final String SCOPE_PARAM_NAME = "scope"; public static final String SCOPES = "apim:api_create apim:api_view apim:shared_scope_manage"; - + public static final String DCR_END_POINT = "WorkflowConfigurations.DCREndPoint"; + public static final String TOKE_END_POINT = "WorkflowConfigurations.TokenEndPoint"; public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive"; public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000; - - public static final String DEFAULT_CALLBACK = ""; - public static final String DEFAULT_PASSWORD = ""; - public static final String TOKEN_SCOPE = "production"; - public static final String APPLICATION_NAME_PREFIX = "OutputAdapter_"; public static final String CLIENT_ID = "clientId"; public static final String CLIENT_SECRET = "clientSecret"; @@ -38,6 +53,10 @@ public final class Constants { public static final String PASSWORD_GRANT_TYPE_SCOPES = "scopes"; public static final String ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME = "access_token"; public static final String GRANT_TYPE_PARAM_NAME = "grant_type"; + public static final String IOT_CORE_HOST = "iot.core.host"; + public static final String IOT_CORE_HTTPS_PORT = "iot.core.https.port"; + public static final String GET_ALL_SCOPES = "/api/am/publisher/v2/scopes?limit=1000"; + public static final String GET_SCOPE = "/api/am/publisher/v2/scopes/"; } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/APIApplicationKey.java similarity index 97% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/APIApplicationKey.java index cbadf626b2..a4b4660bb8 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/APIApplicationKey.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/APIApplicationKey.java @@ -16,7 +16,7 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.dto; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto; /** * This holds the consumer application information that return from the register application endpoint diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/AccessTokenInfo.java similarity index 96% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/AccessTokenInfo.java index 061e7e898d..95bc2b34ba 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/dto/AccessTokenInfo.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/AccessTokenInfo.java @@ -16,7 +16,7 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.dto; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto; /** * This holds the token information that return from the token endpoint. diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/APIServicesException.java similarity index 63% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/APIServicesException.java index 35a247a190..3b9c4cfc7d 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/APIApplicationServicesException.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/APIServicesException.java @@ -16,23 +16,23 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.exceptions; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions; -public class APIApplicationServicesException extends Exception { +public class APIServicesException extends Exception { - public APIApplicationServicesException() { + public APIServicesException() { super(); } - public APIApplicationServicesException(String message) { - super(); + public APIServicesException(String message) { + super(message); } - public APIApplicationServicesException(String message, Throwable cause) { - super(); + public APIServicesException(String message, Throwable cause) { + super(message); } - public APIApplicationServicesException(Throwable cause) { - super(); + public APIServicesException(Throwable cause) { + super(cause); } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/BadRequestException.java similarity index 93% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/BadRequestException.java index 25cebe82fc..6aa9be1130 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/exceptions/BadRequestException.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/BadRequestException.java @@ -19,7 +19,7 @@ /** * Custom exception class for handling bad request exceptions. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.exceptions; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions; public class BadRequestException extends Exception { diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java similarity index 52% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java index 9545a94fb4..18398af9d5 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java @@ -16,17 +16,22 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.internal; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal; -import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; +import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; public class PublisherRESTAPIDataHolder { - private static final PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder(); - private APIApplicationServices apiApplicationServices; + private APIManagerConfigurationService apiManagerConfigurationService; + + private static PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder(); + + private PublisherRESTAPIDataHolder() { + } - public static PublisherRESTAPIDataHolder getInstance() { + static PublisherRESTAPIDataHolder getInstance() { return thisInstance; } @@ -38,4 +43,15 @@ public class PublisherRESTAPIDataHolder { this.apiApplicationServices = apiApplicationServices; } + public void setAPIManagerConfiguration(APIManagerConfigurationService apiManagerConfigurationService) { + this.apiManagerConfigurationService = apiManagerConfigurationService; + } + + public APIManagerConfigurationService getAPIManagerConfigurationService() { + if (apiManagerConfigurationService == null) { + throw new IllegalStateException("API Manager Configuration service is not initialized properly"); + } + return apiManagerConfigurationService; + } + } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java similarity index 59% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java index fdf74638c6..989a547729 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java @@ -16,18 +16,25 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.internal; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal; -import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; -import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServicesImpl; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; /** - * @scr.component name="io.entgra.devicemgt.apimgt.extension.rest.api.internal.PublisherRESTAPIServiceComponent" + * @scr.component name="internal.io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServiceComponent" * immediate="true" + * @scr.reference name="user.apimanagerconfigurationservice.default" + * interface="org.wso2.carbon.apimgt.impl.APIManagerConfigurationService" + * cardinality="1..1" + * policy="dynamic" + * bind="setAPIManagerConfigurationService" + * unbind="unsetAPIManagerConfigurationService" */ public class PublisherRESTAPIServiceComponent { @@ -55,4 +62,18 @@ public class PublisherRESTAPIServiceComponent { protected void deactivate(ComponentContext componentContext) { //do nothing } + + protected void setAPIManagerConfigurationService(APIManagerConfigurationService apiManagerConfigurationService) { + if (log.isDebugEnabled()) { + log.debug("Setting API Manager Configuration Service"); + } + PublisherRESTAPIDataHolder.getInstance().setAPIManagerConfiguration(apiManagerConfigurationService); + } + + protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService apiManagerConfigurationService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting API Manager Configuration Service"); + } + PublisherRESTAPIDataHolder.getInstance().setAPIManagerConfiguration(null); + } } diff --git a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/ScopeUtils.java similarity index 96% rename from components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java rename to components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/ScopeUtils.java index 5716ebfcb1..18944c945c 100644 --- a/components/apimgt-extensions/io.entgra.devicemgt.apimgt.extension.rest.api/src/main/java/io/entgra/devicemgt/apimgt/extension/rest/api/util/ScopeUtils.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/ScopeUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package io.entgra.devicemgt.apimgt.extension.rest.api.util; +package io.entgra.device.mgt.core.apimgt.extension.rest.api.util; /** * This class represents the scope data. diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index d1bc922c54..21c7df3235 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -124,7 +124,7 @@ org.wso2.carbon.devicemgt - io.entgra.devicemgt.apimgt.extension.rest.api + io.entgra.device.mgt.core.apimgt.extension.rest.api provided @@ -174,9 +174,9 @@ org.scannotation;version="1.0", org.scannotation.archiveiterator;version="1.0", org.w3c.dom, - io.entgra.devicemgt.apimgt.extension.rest.api, - io.entgra.devicemgt.apimgt.extension.rest.api.dto, - io.entgra.devicemgt.apimgt.extension.rest.api.exceptions, + io.entgra.device.mgt.core.apimgt.extension.rest.api, + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto, + io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions, org.wso2.carbon.apimgt.annotations.api, org.wso2.carbon.apimgt.api, org.wso2.carbon.apimgt.api.model, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java index fd111a46de..a7299501bd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherService.java @@ -18,6 +18,7 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; + import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; /** diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 5452a4f8bd..ef429bbf50 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -18,13 +18,13 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; -import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServices; -import io.entgra.devicemgt.apimgt.extension.rest.api.APIApplicationServicesImpl; -import io.entgra.devicemgt.apimgt.extension.rest.api.PublisherRESTAPIServices; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.APIApplicationKey; -import io.entgra.devicemgt.apimgt.extension.rest.api.dto.AccessTokenInfo; -import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.APIApplicationServicesException; -import io.entgra.devicemgt.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -373,7 +373,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - } catch (APIApplicationServicesException e) { + } catch (APIServicesException e) { String errorMsg = "Error while generating application"; log.error(errorMsg, e); throw new APIManagerPublisherException(e); @@ -436,7 +436,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { for (int i = 0; i < scopeList.length(); i++) { JSONObject scopeObj = null; scopeObj = scopeList.getJSONObject(i); - if (scopeObj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { + if (scopeObj.getString("name").equals(scopeMapping[2] != null ? + StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { jsonObject = scopeObj; } } @@ -454,20 +455,22 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } catch (IOException | DirectoryIteratorException ex) { log.error("failed to read scopes from file.", ex); - } catch (APIApplicationServicesException | BadRequestException e) { - String errorMsg = "Error while Calling APIs"; + } catch (APIServicesException | BadRequestException e) { + String errorMsg = "Error while calling APIs"; log.error(errorMsg, e); throw new APIManagerPublisherException(e); } } } - catch (APIApplicationServicesException e) { - log.error(e); - throw new RuntimeException(e); + catch (APIServicesException e) { + String errorMsg = "Error while processing Publisher REST API response"; + log.error(errorMsg, e); + throw new APIManagerPublisherException(e); } catch (BadRequestException e) { - log.error(e); - throw new RuntimeException(e); + String errorMsg = "Error while calling Publisher REST APIs"; + log.error(errorMsg, e); + throw new APIManagerPublisherException(e); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index c4bfc0d36d..c2586135da 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -40,7 +40,7 @@ org.wso2.carbon.apimgt.keymgt.extension org.wso2.carbon.apimgt.keymgt.extension.api io.entgra.device.mgt.core.apimgt.analytics.extension - io.entgra.devicemgt.apimgt.extension.rest.api + io.entgra.device.mgt.core.apimgt.extension.rest.api diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index b6344f6e45..de2739b199 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -51,6 +51,10 @@ io.swagger swagger-annotations + + org.wso2.carbon.devicemgt + io.entgra.device.mgt.core.apimgt.extension.rest.api + @@ -143,6 +147,9 @@ io.swagger:swagger-annotations:${swagger.version} + + org.wso2.carbon.devicemgt:io.entgra.device.mgt.core.apimgt.extension.rest.api:${carbon.device.mgt.version} + org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/pom.xml b/pom.xml index e52350555b..e968600416 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ org.wso2.carbon.devicemgt - io.entgra.devicemgt.apimgt.extension.rest.api + io.entgra.device.mgt.core.apimgt.extension.rest.api ${carbon.device.mgt.version} From 50fbb5120a5c17fa4492dac99e6ccc2443652ae2 Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 25 Apr 2023 15:11:10 +0530 Subject: [PATCH 18/29] Minor fixes --- .../pom.xml | 9 +++++++++ .../rest/api/APIApplicationServicesImpl.java | 7 ++++--- .../rest/api/PublisherRESTAPIServices.java | 18 +++++++++--------- .../rest/api/constants/Constants.java | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 7fb3f1726f..17dbdbf866 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -34,6 +34,14 @@ https://entgra.io + + org.apache.httpcomponents.wso2 + httpcore + + + org.wso2.orbit.org.apache.httpcomponents + httpclient + org.wso2.carbon org.wso2.carbon.logging @@ -119,6 +127,7 @@ org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.core;version="4.6", org.wso2.carbon.core.util;version="4.6", + org.apache.commons.ssl, org.wso2.carbon.apimgt.api.model, okhttp3.*, org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index bffb97893a..d3ffe4b4d4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -60,19 +60,20 @@ public class APIApplicationServicesImpl implements APIApplicationServices { throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); - String owner = config.getFirstProperty(Constants.SERVER_USER); + String serverUser = config.getFirstProperty(Constants.SERVER_USER); + String serverPassword = config.getFirstProperty(Constants.SERVER_PASSWORD); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); jsonObject.put("clientName", Constants.CLIENT_NAME); jsonObject.put("grantType", Constants.GRANT_TYPE); - jsonObject.put("owner", owner); + jsonObject.put("owner", serverUser); jsonObject.put("saasApp", true); RequestBody requestBody = RequestBody.Companion.create(jsonObject.toString(), JSON); Request request = new Request.Builder() .url(applicationEndpoint) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic("admin", "admin")) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(serverUser, serverPassword)) .post(requestBody) .build(); try { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java index 5fedcca952..8ca7fb6172 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -45,15 +45,13 @@ public class PublisherRESTAPIServices { private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); private static final OkHttpClient client = getOkHttpClient(); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); - private static final String host = System.getProperty(Constants.IOT_CORE_HOST); private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT); public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws APIServicesException, BadRequestException { - - String getAllScopesUrl = "https://" + "://" + host + ":" + port + Constants.GET_ALL_SCOPES; + String getAllScopesUrl = "https://" + host + ":" + port + Constants.GET_ALL_SCOPES; Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER @@ -90,16 +88,17 @@ public class PublisherRESTAPIServices { throws APIServicesException, BadRequestException { String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); - String getScopeUrl = "https://" + "://" + host + ":" + port + Constants.GET_SCOPE + keyValue; + String getScopeUrl = "https://" + host + ":" + port + Constants.GET_SCOPE + keyValue; Request request = new Request.Builder() .url(getScopeUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccess_token()) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) .head() .build(); try { Response response = client.newCall(request).execute(); - if (response.code() == HttpStatus.SC_OK) { + if (HttpStatus.SC_OK == response.code()) { return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); @@ -124,7 +123,7 @@ public class PublisherRESTAPIServices { public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) throws APIServicesException, BadRequestException { - String updateScopeUrl = "https://" + "://" + host + ":" + port + Constants.GET_SCOPE + scope.getId(); + String updateScopeUrl = "https://" + host + ":" + port + Constants.GET_SCOPE + scope.getId(); ScopeUtils scopeUtil = new ScopeUtils(); scopeUtil.setKey(scope.getKey()); @@ -136,13 +135,14 @@ public class PublisherRESTAPIServices { RequestBody requestBody = RequestBody.create(JSON, scopeString); Request request = new Request.Builder() .url(updateScopeUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, "Bearer " + accessTokenInfo.getAccess_token()) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) .put(requestBody) .build(); try { Response response = client.newCall(request).execute(); - if (response.code() == HttpStatus.SC_OK) { + if (HttpStatus.SC_OK == response.code()) { return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index 11b056298a..bdc557d3e4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -26,7 +26,7 @@ public final class Constants { public static final String EMPTY_STRING = ""; public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; - public static final String SERVER_PASSWORD = "ServerPassword"; + public static final String SERVER_PASSWORD = "WorkflowConfigurations.ServerPassword"; public static final String GRANT_TYPE = "client_credentials password refresh_token"; public static final String REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME = "refresh_token"; public static final String OAUTH_EXPIRES_IN = "expires_in"; From 9ced84a2dff7f5fabe84075cbdb1db7857862d6b Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 25 Apr 2023 17:45:06 +0530 Subject: [PATCH 19/29] Fix scope id issue --- .../apimgt/webapp/publisher/APIPublisherServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index ef429bbf50..a38b3cacf8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -432,16 +432,14 @@ public class APIPublisherServiceImpl implements APIPublisherService { //Set scope id which related to the scope key JSONArray scopeList = (JSONArray) scopeObject.get("list"); - JSONObject jsonObject = null; for (int i = 0; i < scopeList.length(); i++) { JSONObject scopeObj = null; scopeObj = scopeList.getJSONObject(i); if (scopeObj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { - jsonObject = scopeObj; + scope.setId(scopeObj.getString("id")); } } - scope.setId(jsonObject.getString("id")); if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getKey())) { publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); From ba5effbf65303726bfd1b20a0751106403a620d7 Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 25 Apr 2023 18:22:13 +0530 Subject: [PATCH 20/29] Remove unwanted dependencies and minor fixes --- .../pom.xml | 8 -------- .../extension/rest/api/PublisherRESTAPIServices.java | 10 ++++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 17dbdbf866..7ecbdf7900 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -34,14 +34,6 @@ https://entgra.io - - org.apache.httpcomponents.wso2 - httpcore - - - org.wso2.orbit.org.apache.httpcomponents - httpclient - org.wso2.carbon org.wso2.carbon.logging diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java index 8ca7fb6172..f7c4430880 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -24,7 +24,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; - import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -67,7 +66,8 @@ public class PublisherRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); //TODO: max attempt count return getScopes(apiApplicationKey, refreshedAccessToken); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { @@ -103,7 +103,8 @@ public class PublisherRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); //TODO: max attempt count return isSharedScopeNameExists(apiApplicationKey, refreshedAccessToken, key); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { @@ -147,7 +148,8 @@ public class PublisherRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); //TODO: max attempt count return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { From 2ca425819e09851b90df9d7a62e3353682c92d4f Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 25 Apr 2023 23:23:29 +0530 Subject: [PATCH 21/29] Get hardcoded values as constats and fix exception error handling --- .../rest/api/APIApplicationServicesImpl.java | 1 + .../extension/rest/api/PublisherRESTAPIServices.java | 12 ++++++++---- .../extension/rest/api/constants/Constants.java | 5 +++++ .../webapp/publisher/APIPublisherServiceImpl.java | 3 +-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index d3ffe4b4d4..210a710455 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -179,6 +179,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { sc.init(null, trustAllCerts, new java.security.SecureRandom()); return sc.getSocketFactory(); } catch (KeyManagementException | NoSuchAlgorithmException e) { + log.error("Error while creating the SSL socket factory due to " + e.getMessage(), e); return null; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java index f7c4430880..60d93890b2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -50,7 +50,8 @@ public class PublisherRESTAPIServices { public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws APIServicesException, BadRequestException { - String getAllScopesUrl = "https://" + host + ":" + port + Constants.GET_ALL_SCOPES; + String getAllScopesUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON + + port + Constants.GET_ALL_SCOPES; Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER @@ -87,8 +88,10 @@ public class PublisherRESTAPIServices { public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) throws APIServicesException, BadRequestException { - String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace("=", ""); - String getScopeUrl = "https://" + host + ":" + port + Constants.GET_SCOPE + keyValue; + String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace(Constants.QUERY_KEY_VALUE_SEPARATOR, + Constants.EMPTY_STRING); + String getScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON + + port + Constants.GET_SCOPE + keyValue; Request request = new Request.Builder() .url(getScopeUrl) @@ -124,7 +127,8 @@ public class PublisherRESTAPIServices { public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) throws APIServicesException, BadRequestException { - String updateScopeUrl = "https://" + host + ":" + port + Constants.GET_SCOPE + scope.getId(); + String updateScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + + Constants.COLON + port + Constants.GET_SCOPE + scope.getId(); ScopeUtils scopeUtil = new ScopeUtils(); scopeUtil.setKey(scope.getKey()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index bdc557d3e4..e4dd49b381 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -53,6 +53,11 @@ public final class Constants { public static final String PASSWORD_GRANT_TYPE_SCOPES = "scopes"; public static final String ACCESS_TOKEN_GRANT_TYPE_PARAM_NAME = "access_token"; public static final String GRANT_TYPE_PARAM_NAME = "grant_type"; + public static final String HTTPS_PROTOCOL = "https"; + public static final String HTTP_PROTOCOL = "http"; + public static final String SCHEME_SEPARATOR = "://"; + public static final String COLON = ":"; + public static final String QUERY_KEY_VALUE_SEPARATOR = "="; public static final String IOT_CORE_HOST = "iot.core.host"; public static final String IOT_CORE_HTTPS_PORT = "iot.core.https.port"; public static final String GET_ALL_SCOPES = "/api/am/publisher/v2/scopes?limit=1000"; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index a38b3cacf8..fb4509858d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -433,8 +433,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { //Set scope id which related to the scope key JSONArray scopeList = (JSONArray) scopeObject.get("list"); for (int i = 0; i < scopeList.length(); i++) { - JSONObject scopeObj = null; - scopeObj = scopeList.getJSONObject(i); + JSONObject scopeObj = scopeList.getJSONObject(i); if (scopeObj.getString("name").equals(scopeMapping[2] != null ? StringUtils.trim(scopeMapping[2]) : StringUtils.EMPTY)) { scope.setId(scopeObj.getString("id")); From eb11036b6ccf7549fd220b03a1579ce64eacb2ee Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 26 Apr 2023 10:02:40 +0530 Subject: [PATCH 22/29] Change version snd remove unwanted dependencies --- .../pom.xml | 43 ++++++++----------- .../rest/api/APIApplicationServicesImpl.java | 2 +- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 7ecbdf7900..2dca4947db 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.25-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -37,43 +37,29 @@ org.wso2.carbon org.wso2.carbon.logging + provided org.wso2.carbon org.wso2.carbon.utils - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + provided org.wso2.carbon org.wso2.carbon.core + provided - com.googlecode.json-simple.wso2 - json-simple - - - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - - - com.squareup.okhttp3 - okhttp - - - io.github.openfeign - feign-okhttp + org.eclipse.osgi + org.eclipse.osgi + provided - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api + org.eclipse.osgi + org.eclipse.osgi.services + provided + org.json.wso2 json @@ -81,12 +67,18 @@ com.google.code.gson gson + provided org.wso2.carbon.apimgt org.wso2.carbon.apimgt.impl provided + + com.squareup.okhttp3 + okhttp + compile + @@ -114,7 +106,6 @@ io.entgra.device.mgt.core.apimgt.extension.rest.api.* - javax.net.ssl, org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.core;version="4.6", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 210a710455..0fc1f4792e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import org.json.JSONObject; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; From 455917f21e0ea3d73411f7b38b9e14ad3006b662 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 26 Apr 2023 20:35:56 +0530 Subject: [PATCH 23/29] Implement method for Https ssl trustmanager and improve exception --- .../rest/api/APIApplicationServicesImpl.java | 54 +---- .../rest/api/PublisherRESTAPIServices.java | 21 +- .../UnexpectedResponseException.java | 31 +++ .../rest/api/util/HttpsTrustManagerUtils.java | 229 ++++++++++++++++++ .../publisher/APIPublisherServiceImpl.java | 7 +- 5 files changed, 280 insertions(+), 62 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/UnexpectedResponseException.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 0fc1f4792e..abf383b501 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; import org.json.JSONObject; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; @@ -48,7 +49,7 @@ import java.util.concurrent.TimeUnit; public class APIApplicationServicesImpl implements APIApplicationServices { private static final Log log = LogFactory.getLog(APIApplicationServicesImpl.class); - private static final OkHttpClient client = getOkHttpClient(); + private static final OkHttpClient client = new OkHttpClient(HttpsTrustManagerUtils.getSSLClient().newBuilder()); private static final Gson gson = new Gson(); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); String msg = null; @@ -133,55 +134,4 @@ public class APIApplicationServicesImpl implements APIApplicationServices { throw new APIServicesException(e); } } - - protected static OkHttpClient getOkHttpClient() { - X509TrustManager trustAllCerts = new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[0]; - } - - public void checkClientTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - - public void checkServerTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - }; - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .connectTimeout(300, TimeUnit.SECONDS) - .writeTimeout(300, TimeUnit.SECONDS) - .readTimeout(300, TimeUnit.SECONDS) - .connectionPool(new ConnectionPool(500, 500, TimeUnit.SECONDS)) - .sslSocketFactory(getSimpleTrustedSSLSocketFactory(), trustAllCerts) - .hostnameVerifier((hostname, sslSession) -> true).build(); - return okHttpClient; - } - - private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { - try { - TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkClientTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - - public void checkServerTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - } - }; - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - return sc.getSocketFactory(); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - log.error("Error while creating the SSL socket factory due to " + e.getMessage(), e); - return null; - } - - } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java index 60d93890b2..c74b227289 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -23,6 +23,8 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; import okhttp3.MediaType; import okhttp3.OkHttpClient; @@ -38,17 +40,15 @@ import org.wso2.carbon.apimgt.api.model.Scope; import java.io.IOException; -import static io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl.getOkHttpClient; - public class PublisherRESTAPIServices { private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); - private static final OkHttpClient client = getOkHttpClient(); + private static final OkHttpClient client = new OkHttpClient(HttpsTrustManagerUtils.getSSLClient().newBuilder()); private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); private static final String host = System.getProperty(Constants.IOT_CORE_HOST); private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT); public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) - throws APIServicesException, BadRequestException { + throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON + port + Constants.GET_ALL_SCOPES; @@ -76,7 +76,8 @@ public class PublisherRESTAPIServices { log.error(msg); throw new BadRequestException(msg); } else { - return null; + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); } } catch (IOException e) { String msg = "Error occurred while processing the response"; @@ -86,7 +87,7 @@ public class PublisherRESTAPIServices { } public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) - throws APIServicesException, BadRequestException { + throws APIServicesException, BadRequestException, UnexpectedResponseException { String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace(Constants.QUERY_KEY_VALUE_SEPARATOR, Constants.EMPTY_STRING); @@ -115,7 +116,8 @@ public class PublisherRESTAPIServices { log.error(msg); throw new BadRequestException(msg); } else { - return false; + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); } } catch (IOException e) { String msg = "Error occurred while processing the response"; @@ -125,7 +127,7 @@ public class PublisherRESTAPIServices { } public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) - throws APIServicesException, BadRequestException { + throws APIServicesException, BadRequestException, UnexpectedResponseException { String updateScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON + port + Constants.GET_SCOPE + scope.getId(); @@ -161,7 +163,8 @@ public class PublisherRESTAPIServices { log.error(msg); throw new BadRequestException(msg); } else { - return false; + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); } } catch (IOException e) { String msg = "Error occurred while processing the response"; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/UnexpectedResponseException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/UnexpectedResponseException.java new file mode 100644 index 0000000000..898caba26e --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/exceptions/UnexpectedResponseException.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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. + */ + +/** + * Custom exception class for handling unexpected server response exceptions. + */ +package io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions; + +public class UnexpectedResponseException extends Exception { + + private static final long serialVersionUID = -2387103750774855056L; + + public UnexpectedResponseException(String errorMessage) { + super(errorMessage); + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java new file mode 100644 index 0000000000..8b47d77a34 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.apimgt.extension.rest.api.util; + +import okhttp3.ConnectionPool; +import okhttp3.OkHttpClient; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.ServerConfiguration; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.net.ssl.SSLSession; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.HostnameVerifier; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.URI; + +import java.security.*; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +public class HttpsTrustManagerUtils { + + private static final Log log = LogFactory.getLog(HttpsTrustManagerUtils.class); + private static final String KEY_STORE_TYPE = "JKS"; + /** + * Default truststore type of the client + */ + private static final String TRUST_STORE_TYPE = "JKS"; + /** + * Default keymanager type of the client + */ + private static final String KEY_MANAGER_TYPE = "SunX509"; //Default Key Manager Type + /** + * Default trustmanager type of the client + */ + private static final String TRUST_MANAGER_TYPE = "SunX509"; //Default Trust Manager Type + private static final String SSLV3 = "SSLv3"; + private static final String DEFAULT_HOST = "localhost"; + private static final String DEFAULT_HOST_IP = "127.0.0.1"; + private static final int TIMEOUT = 100; + + public static OkHttpClient getSSLClient() { + + boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System.getProperty("org.wso2" + + ".ignoreHostnameVerification")); + OkHttpClient okHttpClient; + final String proxyHost = System.getProperty("http.proxyHost"); + final String proxyPort = System.getProperty("http.proxyPort"); + final String nonProxyHostsValue = System.getProperty("http.nonProxyHosts"); + + final ProxySelector proxySelector = new ProxySelector() { + @Override + public List select(URI uri) { + List proxyList = new ArrayList<>(); + String host = uri.getHost(); + + if (!StringUtils.isEmpty(host)) { + if (host.startsWith(DEFAULT_HOST_IP) || host.startsWith(DEFAULT_HOST) || StringUtils + .isEmpty(nonProxyHostsValue) || StringUtils.contains(nonProxyHostsValue, host) || + StringUtils.isEmpty(proxyHost) || StringUtils.isEmpty(proxyPort)) { + proxyList.add(Proxy.NO_PROXY); + } else { + proxyList.add(new Proxy(Proxy.Type.HTTP, + new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)))); + } + } else { + log.error("Host is null. Host could not be empty or null"); + } + return proxyList; + } + + @Override + public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { + throw new UnsupportedOperationException("Not supported yet."); + } + }; + + X509TrustManager trustAllCerts = new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[0]; + } + + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + }; + + if (isIgnoreHostnameVerification) { + okHttpClient = new OkHttpClient.Builder() + .connectTimeout(TIMEOUT, TimeUnit.SECONDS) + .writeTimeout(TIMEOUT, TimeUnit.SECONDS) + .readTimeout(TIMEOUT, TimeUnit.SECONDS) + .connectionPool(new ConnectionPool(TIMEOUT, TIMEOUT, TimeUnit.SECONDS)) + .sslSocketFactory(getSimpleTrustedSSLSocketFactory(), trustAllCerts) + .hostnameVerifier(new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }).proxySelector(proxySelector).build(); + return okHttpClient; + } else { + SSLSocketFactory trustedSSLSocketFactory = getTrustedSSLSocketFactory(); + okHttpClient = new OkHttpClient.Builder() + .connectTimeout(TIMEOUT, TimeUnit.SECONDS) + .writeTimeout(TIMEOUT, TimeUnit.SECONDS) + .readTimeout(TIMEOUT, TimeUnit.SECONDS) + .connectionPool(new ConnectionPool(TIMEOUT, TIMEOUT, TimeUnit.SECONDS)) + .sslSocketFactory(trustedSSLSocketFactory) + .proxySelector(proxySelector).build(); + return okHttpClient; + } + } + + private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { + try { + TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + } + }; + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new SecureRandom()); + return sc.getSocketFactory(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + log.error("Error while creating the SSL socket factory due to " + e.getMessage(), e); + return null; + } + } + + private static SSLSocketFactory getTrustedSSLSocketFactory() { + try { + String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); + String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location"); + String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty( + "Security.TrustStore.Password"); + String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty( + "Security.TrustStore.Location"); + KeyStore keyStore = loadKeyStore(keyStoreLocation, keyStorePassword, KEY_STORE_TYPE); + KeyStore trustStore = loadTrustStore(trustStoreLocation, trustStorePassword); + + return initSSLConnection(keyStore, keyStorePassword, trustStore); + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException + | CertificateException | IOException | UnrecoverableKeyException e) { + log.error("Error while creating the SSL socket factory due to " + e.getMessage(), e); + return null; + } + } + + private static SSLSocketFactory initSSLConnection(KeyStore keyStore, String keyStorePassword, KeyStore trustStore) + throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException { + KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE); + keyManagerFactory.init(keyStore, keyStorePassword.toCharArray()); + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE); + trustManagerFactory.init(trustStore); + + // Create and initialize SSLContext for HTTPS communication + SSLContext sslContext = SSLContext.getInstance(SSLV3); + sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); + SSLContext.setDefault(sslContext); + return sslContext.getSocketFactory(); + } + + private static KeyStore loadKeyStore(String keyStorePath, String ksPassword, String type) + throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { + InputStream fileInputStream = null; + try { + char[] keypassChar = ksPassword.toCharArray(); + KeyStore keyStore = KeyStore.getInstance(type); + fileInputStream = new FileInputStream(keyStorePath); + keyStore.load(fileInputStream, keypassChar); + return keyStore; + } finally { + if (fileInputStream != null) { + fileInputStream.close(); + } + } + } + + private static KeyStore loadTrustStore(String trustStorePath, String tsPassword) + throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { + return loadKeyStore(trustStorePath, tsPassword, TRUST_STORE_TYPE); + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index fb4509858d..e4a63f456a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -25,6 +25,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -468,7 +469,11 @@ public class APIPublisherServiceImpl implements APIPublisherService { String errorMsg = "Error while calling Publisher REST APIs"; log.error(errorMsg, e); throw new APIManagerPublisherException(e); - } finally { + } catch (UnexpectedResponseException e) { + String errorMsg = "Unexpected response from the server"; + log.error(errorMsg, e); + throw new APIManagerPublisherException(e); + }finally { PrivilegedCarbonContext.endTenantFlow(); } } From 6b6b303d87420e3bc4dd1f3ec0d00ea3b9107109 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 26 Apr 2023 23:20:21 +0530 Subject: [PATCH 24/29] Create interface for Publlisher rest api services --- .../rest/api/APIApplicationServicesImpl.java | 11 +- .../rest/api/PublisherRESTAPIServices.java | 150 +-------------- .../api/PublisherRESTAPIServicesImpl.java | 174 ++++++++++++++++++ .../publisher/APIPublisherServiceImpl.java | 3 +- 4 files changed, 184 insertions(+), 154 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index abf383b501..68faf24b80 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; import org.json.JSONObject; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; @@ -31,20 +31,11 @@ import okhttp3.Request; import okhttp3.Response; import okhttp3.RequestBody; import okhttp3.Credentials; -import okhttp3.ConnectionPool; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; import java.io.IOException; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.util.concurrent.TimeUnit; public class APIApplicationServicesImpl implements APIApplicationServices { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java index c74b227289..2ea0a51f34 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServices.java @@ -18,158 +18,22 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.RequestBody; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.ssl.Base64; import org.json.JSONObject; import org.wso2.carbon.apimgt.api.model.Scope; -import java.io.IOException; +public interface PublisherRESTAPIServices { -public class PublisherRESTAPIServices { - private static final Log log = LogFactory.getLog(PublisherRESTAPIServices.class); - private static final OkHttpClient client = new OkHttpClient(HttpsTrustManagerUtils.getSSLClient().newBuilder()); - private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); - private static final String host = System.getProperty(Constants.IOT_CORE_HOST); - private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT); + JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + throws APIServicesException, BadRequestException, UnexpectedResponseException; - public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) - throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) + throws APIServicesException, BadRequestException, UnexpectedResponseException; - String getAllScopesUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON - + port + Constants.GET_ALL_SCOPES; - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) - .get() - .build(); - - try { - Response response = client.newCall(request).execute(); - if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; - } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - //TODO: max attempt count - return getScopes(apiApplicationKey, refreshedAccessToken); - } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { - String msg = "Bad Request, Invalid request"; - log.error(msg); - throw new BadRequestException(msg); - } else { - String msg = "Response : " + response.code() + response.body(); - throw new UnexpectedResponseException(msg); - } - } catch (IOException e) { - String msg = "Error occurred while processing the response"; - log.error(msg, e); - throw new APIServicesException(e); - } - } - - public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) - throws APIServicesException, BadRequestException, UnexpectedResponseException { - - String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace(Constants.QUERY_KEY_VALUE_SEPARATOR, - Constants.EMPTY_STRING); - String getScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON - + port + Constants.GET_SCOPE + keyValue; - - Request request = new Request.Builder() - .url(getScopeUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) - .head() - .build(); - try { - Response response = client.newCall(request).execute(); - if (HttpStatus.SC_OK == response.code()) { - return true; - } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - //TODO: max attempt count - return isSharedScopeNameExists(apiApplicationKey, refreshedAccessToken, key); - } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { - String msg = "Bad Request, Invalid request"; - log.error(msg); - throw new BadRequestException(msg); - } else { - String msg = "Response : " + response.code() + response.body(); - throw new UnexpectedResponseException(msg); - } - } catch (IOException e) { - String msg = "Error occurred while processing the response"; - log.error(msg, e); - throw new APIServicesException(e); - } - } - - public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) - throws APIServicesException, BadRequestException, UnexpectedResponseException { - - String updateScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host - + Constants.COLON + port + Constants.GET_SCOPE + scope.getId(); - - ScopeUtils scopeUtil = new ScopeUtils(); - scopeUtil.setKey(scope.getKey()); - scopeUtil.setName(scope.getName()); - scopeUtil.setDescription(scope.getDescription()); - scopeUtil.setRoles(scope.getRoles()); - String scopeString = scopeUtil.toJSON(); - - RequestBody requestBody = RequestBody.create(JSON, scopeString); - Request request = new Request.Builder() - .url(updateScopeUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) - .put(requestBody) - .build(); - - try { - Response response = client.newCall(request).execute(); - if (HttpStatus.SC_OK == response.code()) { - return true; - } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - //TODO: max attempt count - return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope); - } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { - String msg = "Bad Request, Invalid scope object"; - log.error(msg); - throw new BadRequestException(msg); - } else { - String msg = "Response : " + response.code() + response.body(); - throw new UnexpectedResponseException(msg); - } - } catch (IOException e) { - String msg = "Error occurred while processing the response"; - log.error(msg, e); - throw new APIServicesException(e); - } - } + boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) + throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java new file mode 100644 index 0000000000..9a5bf73a84 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.apimgt.extension.rest.api; + +import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; +import okhttp3.*; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.ssl.Base64; +import org.json.JSONObject; +import org.wso2.carbon.apimgt.api.model.Scope; + +import java.io.IOException; + +public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices { + private static final Log log = LogFactory.getLog(PublisherRESTAPIServicesImpl.class); + private static final OkHttpClient client = new OkHttpClient(HttpsTrustManagerUtils.getSSLClient().newBuilder()); + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private static final String host = System.getProperty(Constants.IOT_CORE_HOST); + private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT); + + @Override + public JSONObject getScopes(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON + + port + Constants.GET_ALL_SCOPES; + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + JSONObject jsonObject = new JSONObject(response.body().string()); + return jsonObject; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getScopes(apiApplicationKey, refreshedAccessToken); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(e); + } + } + + @Override + public boolean isSharedScopeNameExists(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String key) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String keyValue = new String(Base64.encodeBase64((key).getBytes())).replace(Constants.QUERY_KEY_VALUE_SEPARATOR, + Constants.EMPTY_STRING); + String getScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + Constants.COLON + + port + Constants.GET_SCOPE + keyValue; + + Request request = new Request.Builder() + .url(getScopeUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .head() + .build(); + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return true; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return isSharedScopeNameExists(apiApplicationKey, refreshedAccessToken, key); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(e); + } + } + + @Override + public boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String updateScopeUrl = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + + Constants.COLON + port + Constants.GET_SCOPE + scope.getId(); + + ScopeUtils scopeUtil = new ScopeUtils(); + scopeUtil.setKey(scope.getKey()); + scopeUtil.setName(scope.getName()); + scopeUtil.setDescription(scope.getDescription()); + scopeUtil.setRoles(scope.getRoles()); + String scopeString = scopeUtil.toJSON(); + + RequestBody requestBody = RequestBody.create(JSON, scopeString); + Request request = new Request.Builder() + .url(updateScopeUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .put(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return true; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return updateSharedScope(apiApplicationKey, refreshedAccessToken, scope); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid scope object"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(e); + } + } +} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index e4a63f456a..0725998e7f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -21,6 +21,7 @@ package org.wso2.carbon.apimgt.webapp.publisher; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServicesImpl; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; @@ -384,7 +385,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { for (String tenantDomain : tenants) { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); - PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServices(); + PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServicesImpl(); JSONObject scopeObject = publisherRESTAPIServices.getScopes(apiApplicationKey, accessTokenInfo); try { From bb325f7c46b2f9076255b916eff5ee451655516e Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 27 Apr 2023 09:32:04 +0530 Subject: [PATCH 25/29] Remove wild card imports --- .../extension/rest/api/PublisherRESTAPIServicesImpl.java | 6 +++++- .../extension/rest/api/util/HttpsTrustManagerUtils.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java index 9a5bf73a84..819b91210d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/PublisherRESTAPIServicesImpl.java @@ -26,7 +26,11 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequest import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; -import okhttp3.*; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.RequestBody; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java index 8b47d77a34..b55857af37 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/util/HttpsTrustManagerUtils.java @@ -43,7 +43,12 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.URI; -import java.security.*; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.SecureRandom; import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.List; From 06ec100ae195b338522a3660228e14e4341b9a52 Mon Sep 17 00:00:00 2001 From: kavindya_devindi Date: Thu, 27 Apr 2023 17:52:51 +0530 Subject: [PATCH 26/29] Fix dependency issue in subtype mgt component --- .../subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml | 5 ++++- pom.xml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml index 905ed65f0f..70203fa428 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/pom.xml @@ -83,7 +83,8 @@ com.google.gson.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.*, - com.fasterxml.jackson.annotation.* + com.fasterxml.jackson.annotation.*, + com.google.common.cache.*, !io.entgra.device.mgt.subtype.mgt.internal, @@ -340,6 +341,8 @@ com.google.guava guava + ${guava.version} + provided org.json diff --git a/pom.xml b/pom.xml index b7c402aeb8..c835c9e7ba 100644 --- a/pom.xml +++ b/pom.xml @@ -2165,6 +2165,7 @@ 20220924 2.4.5 + 27.0.1-jre 1.60.0.wso2v1 From d69809b3195fadf71e95666fc2e5b7e40855cbdd Mon Sep 17 00:00:00 2001 From: dilini Date: Thu, 27 Apr 2023 21:39:13 +0530 Subject: [PATCH 27/29] Fix : Web-app url not updating --- .../application/mgt/core/impl/ApplicationManagerImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java index 3861744c56..fd23dd64ea 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java @@ -3186,8 +3186,8 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!StringUtils.isEmpty(webAppReleaseWrapper.getVersion())) { applicationReleaseDTO.get().setVersion(webAppReleaseWrapper.getVersion()); } - if (!StringUtils.isEmpty(webAppReleaseWrapper.getVersion())) { - applicationReleaseDTO.get().setVersion(webAppReleaseWrapper.getVersion()); + if (!StringUtils.isEmpty(webAppReleaseWrapper.getUrl())) { + applicationReleaseDTO.get().setInstallerName(webAppReleaseWrapper.getUrl()); } if (!StringUtils.isEmpty(webAppReleaseWrapper.getDescription())) { applicationReleaseDTO.get().setDescription(webAppReleaseWrapper.getDescription()); From 00b2c06ec0e679fe1f9a42291795e845a759b49b Mon Sep 17 00:00:00 2001 From: Nishan Sangeeth Date: Fri, 5 May 2023 07:22:02 +0000 Subject: [PATCH 28/29] Fix-invite-users-issue Co-authored-by: Nishan Sangeeth Co-committed-by: Nishan Sangeeth --- .../src/test/resources/carbon-home/dbscripts/dm-db-h2.sql | 3 +-- .../src/main/resources/dbscripts/cdm/h2.sql | 3 +-- .../src/main/resources/dbscripts/cdm/mssql.sql | 3 +-- .../src/main/resources/dbscripts/cdm/mysql.sql | 3 +-- .../src/main/resources/dbscripts/cdm/oracle.sql | 3 +-- .../src/main/resources/dbscripts/cdm/postgresql.sql | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 9737fd3df0..15c1604d31 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -588,8 +588,7 @@ CREATE TABLE IF NOT EXISTS DM_OTP_DATA ( CREATED_AT TIMESTAMP NOT NULL, EXPIRY_TIME INT NOT NULL DEFAULT 3600, IS_EXPIRED BOOLEAN DEFAULT false, - PRIMARY KEY (ID), - CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) + PRIMARY KEY (ID) ); -- END OF DM_OTP_DATA TABLE -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 30ef1d7d79..417964f133 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -600,8 +600,7 @@ CREATE TABLE IF NOT EXISTS DM_OTP_DATA ( CREATED_AT TIMESTAMP NOT NULL, EXPIRY_TIME INT NOT NULL DEFAULT 3600, IS_EXPIRED BOOLEAN DEFAULT false, - PRIMARY KEY (ID), - CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) + PRIMARY KEY (ID) ); -- END OF DM_OTP_DATA TABLE -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index af29b96e1a..b0f2ab6b70 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -660,8 +660,7 @@ CREATE TABLE DM_OTP_DATA ( CREATED_AT DATETIME2(0) NOT NULL, EXPIRY_TIME INT NOT NULL DEFAULT 3600, IS_EXPIRED BIT DEFAULT 0, - PRIMARY KEY (ID), - CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) + PRIMARY KEY (ID) ); -- END OF DM_OTP_DATA TABLE -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index afebcf6150..e17cafcd0b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -657,8 +657,7 @@ CREATE TABLE IF NOT EXISTS DM_OTP_DATA ( CREATED_AT TIMESTAMP NOT NULL, EXPIRY_TIME INT NOT NULL DEFAULT 3600, IS_EXPIRED BOOLEAN DEFAULT false, - PRIMARY KEY (ID), - CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) + PRIMARY KEY (ID) ); -- END OF DM_OTP_DATA TABLE -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 73dcb320b4..1735b70372 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1006,8 +1006,7 @@ CREATE TABLE DM_OTP_DATA ( CREATED_AT TIMESTAMP(0) NOT NULL, EXPIRY_TIME NUMBER(10) DEFAULT 3600 NOT NULL, IS_EXPIRED CHAR(1) DEFAULT false, - PRIMARY KEY (ID), - CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) + PRIMARY KEY (ID) ); -- Generate ID using sequence and trigger diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 530083d967..78a21e52d4 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -662,8 +662,7 @@ CREATE TABLE IF NOT EXISTS DM_OTP_DATA ( CREATED_AT TIMESTAMP(0) NOT NULL, EXPIRY_TIME INT NOT NULL DEFAULT 3600, IS_EXPIRED BOOLEAN DEFAULT false, - PRIMARY KEY (ID), - CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) + PRIMARY KEY (ID) ); -- END OF OPT-DATA TABLE -- From d7d28b187996080d2e91bd8c092d230d91777a82 Mon Sep 17 00:00:00 2001 From: Oshani Silva Date: Fri, 5 May 2023 07:28:25 +0000 Subject: [PATCH 29/29] Fix billing issues Co-authored-by: Oshani Silva Co-committed-by: Oshani Silva --- .../service/impl/MetadataServiceImpl.java | 2 ++ .../DeviceManagementAdminServiceImpl.java | 1 + .../impl/group/PostgreSQLGroupDAOImpl.java | 2 +- .../dao/util/DeviceManagementDAOUtil.java | 4 +-- .../mgt/MetadataManagementServiceImpl.java | 4 +-- .../DeviceManagementProviderServiceImpl.java | 25 ++++++++----------- .../mgt/core/util/DeviceManagerUtil.java | 8 ++++++ 7 files changed, 26 insertions(+), 20 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java index 559ecc41ec..398a6427c1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java @@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.jaxrs.beans.MetadataList; import org.wso2.carbon.device.mgt.jaxrs.service.api.MetadataService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; @@ -127,6 +128,7 @@ public class MetadataServiceImpl implements MetadataService { RequestValidationUtil.validateMetadata(metadata); try { Metadata updatedMetadata = DeviceMgtAPIUtils.getMetadataManagementService().updateMetadata(metadata); + DeviceManagerUtil.removeBillingCache(); return Response.status(Response.Status.OK).entity(updatedMetadata).build(); } catch (MetadataManagementException e) { String msg = "Error occurred while updating the metadata entry for metaKey:" + metadata.getMetaKey(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java index 1137beceed..47fb8964b8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java @@ -53,6 +53,7 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.exceptions.UserNotFoundException; import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index a01ef5b6b8..2a88f536ac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -70,7 +70,7 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { "VALUES (?, ?, ?, ?) RETURNING ID"; } else { sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + - "VALUES (?, ?, ?, ?, ?) RETURNING ID"; + "VALUES (?, ?, ?, ?, ?, ?) RETURNING ID"; hasStatus = true; } stmt = conn.prepareStatement(sql); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index 0fd111d76e..23b89af670 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -239,8 +239,8 @@ public final class DeviceManagementDAOUtil { Device device = new Device(); device.setId(rs.getInt("DEVICE_ID")); device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); - device.setName(rs.getString("DESCRIPTION")); - device.setDescription(rs.getString("NAME")); + device.setName(rs.getString("NAME")); + device.setDescription(rs.getString("DESCRIPTION")); device.setEnrolmentInfo(loadEnrolmentBilling(rs)); return device; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java index 5ba8888301..2d7aa3ca61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java @@ -92,8 +92,8 @@ public class MetadataManagementServiceImpl implements MetadataManagementService try { MetadataManagementDAOFactory.openConnection(); int tenantId; - if (metaKey.equals("EVALUATE_TENANTS")){ - // for getting evaluate tenant list to provide the live chat feature + if (metaKey.equals("EVALUATE_TENANTS") || metaKey.equals("PER_DEVICE_COST")){ + // for getting per device cost and evaluate tenant list to provide the billing feature and live chat feature tenantId = MultitenantConstants.SUPER_TENANT_ID; } else { tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index d3363717ad..7380baa807 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -48,7 +48,6 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.protocol.HTTP; -import org.opensaml.xmlsec.signature.P; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -98,6 +97,7 @@ import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; import org.wso2.carbon.device.mgt.common.exceptions.UnauthorizedDeviceAccessException; import org.wso2.carbon.device.mgt.common.exceptions.UserNotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; @@ -107,6 +107,7 @@ import org.wso2.carbon.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitati import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; +import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; @@ -183,7 +184,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.TimeUnit; -import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService, @@ -1044,8 +1044,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv double totalCost = 0.0; try { - MetadataManagementDAOFactory.openConnection(); - Metadata metadata = metadataDAO.getMetadata(MultitenantConstants.SUPER_TENANT_ID, DeviceManagementConstants.META_KEY); + MetadataManagementService meta = DeviceManagementDataHolder + .getInstance().getMetadataManagementService(); + Metadata metadata = meta.retrieveMetadata(DeviceManagementConstants.META_KEY); Gson g = new Gson(); Collection costData = null; @@ -1061,19 +1062,19 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.setDeviceStatusInfo(getDeviceStatusHistory(device, null, endDate, true)); List deviceStatus = device.getDeviceStatusInfo(); if (device.getEnrolmentInfo().getDateOfEnrolment() < startDate.getTime()) { - if (!deviceStatus.isEmpty() && deviceStatus.get(0).getStatus().equals("REMOVED")) { + if (!deviceStatus.isEmpty() && String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED")) { if (deviceStatus.get(0).getUpdateTime().getTime() >= startDate.getTime()) { dateDiff = deviceStatus.get(0).getUpdateTime().getTime() - startDate.getTime(); } - } else if (!deviceStatus.isEmpty() && !deviceStatus.get(0).getStatus().equals("REMOVED")) { + } else if (!deviceStatus.isEmpty() && !String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED")) { dateDiff = endDate.getTime() - startDate.getTime(); } } else { - if (!deviceStatus.isEmpty() && deviceStatus.get(0).getStatus().equals("REMOVED")) { + if (!deviceStatus.isEmpty() && String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED")) { if (deviceStatus.get(0).getUpdateTime().getTime() >= device.getEnrolmentInfo().getDateOfEnrolment()) { dateDiff = deviceStatus.get(0).getUpdateTime().getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } - } else if (!deviceStatus.isEmpty() && !deviceStatus.get(0).getStatus().equals("REMOVED")) { + } else if (!deviceStatus.isEmpty() && !String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED")) { dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } } @@ -1095,16 +1096,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String msg = "Error occurred calculating cost of devices"; log.error(msg, e); throw new DeviceManagementException(msg, e); - } catch (SQLException e) { - String msg = "Error when retrieving data"; - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } catch (MetadataManagementDAOException e) { + } catch (MetadataManagementException e) { String msg = "Error when retrieving metadata of billing feature"; log.error(msg, e); throw new DeviceManagementException(msg, e); - } finally { - MetadataManagementDAOFactory.closeConnection(); } if (!deviceStatusNotAvailable.isEmpty()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 65a26d1330..37aa456130 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -696,6 +696,14 @@ public final class DeviceManagerUtil { } } + /** + * Enable Billing caching according to the configurations provided by cdm-config.xml + */ + public static void removeBillingCache() { + CacheManager manager = getCacheManager(); + manager.removeCache(DeviceManagementConstants.BILLING_CACHE); + } + /** * Enable Geofence caching according to the configurations proviced by cdm-config.xml */